How to write rating

ryan's Avatar

ryan

16 Nov, 2016 08:17 AM

Thanks.. I have a quick Q about the AudioMetaData class ..is there a method which can read / write a tag that doesn't have a get/set method defined? in this case most other programs write the rating to POPULARIMETER .. I'd like to read that and then write it to the song with setRating() so iTunes reflects what's stored in IDv3

  1. Support Staff 1 Posted by hendrik on 16 Nov, 2016 08:24 AM

    hendrik's Avatar

    First of all, AudioMetaData is the class that writes directly to an audio file. It does not update any values in iTunes. If you want to write to a file and update stuff in iTunes, simply use an AudioSong object returned to you by the ITunesMusicLibrary. It manages lots of stuff under the hood. AudioMetaData implements the AudioSong interface, so whatever you get from the library has the same API.

    The problem with the POPM frame is, that it's tied to an email address. Unless you use the same address as the software of your choice, it may get ignored.

    Why aren't you simply using setRating()? It's mapped to POPM.

    If you post a little code sample, I'd be happy to take a look and make suggestions!

  2. 2 Posted by ryan on 16 Nov, 2016 08:14 PM

    ryan's Avatar

    Hi Hendrik,

    I'm using AudioMetaData.getRating() to read the rating from the file then AudioSong.setRating() to save it to iTunes. If the rating is blank in iTunes it works the first time but when I change the rating in another program and run then script to update it in iTunes AudioMetaData.getRating() appears to be the same value as what's in iTunes and not the POM value.

    Sent from my iPad

  3. Support Staff 3 Posted by hendrik on 17 Nov, 2016 08:52 AM

    hendrik's Avatar

    Hey Ryan,

    If the rating is blank in iTunes it works the first time but when I change the rating in another program and run then script to update it in iTunes AudioMetaData.getRating() appears to be the same value as what's in iTunes and not the POM value.

    When using an iTunes-based collection, beaTunes works in a mode that is optimized to work with just iTunes. This means that any modifications by third party programs may not be noticed either by iTunes or beaTunes.

    So when you modify the rating with some third party software, iTunes won't display this change until you actually play the file. This makes sense, cause otherwise iTunes would need to constantly monitor and re-read all files.

    beaTunes (when in iTunes-library mode!) only picks up changes caused by iTunes, which are exported by iTunes in its Library.xml file. This is done this way, because it is far more efficient than to scan though all files all the time.

    What happens when you change the rating in your third party software, then play that song in iTunes, and then synchronize beaTunes? Do iTunes and beaTunes show the new rating?

    That aside, to force reading the third party rating in beaTunes, first get the AudioMetaData object, read the current rating/popm that's in the file. Then write some random value using the AudioSong object you received from the beaTunes library. Then write the value you got from AudioMetaData using the AudioSong's setRating() method.

    Reasoning: beaTunes does not propagate any values to iTunes when they haven't changed. First changing to some random value forces a change.

    If this does not work for whatever reason, please post code samples.

    Thanks,

    -hendrik

  4. 4 Posted by ryan on 17 Nov, 2016 07:18 PM

    ryan's Avatar

    Thanks so much Hendrik ..

    So reading from the file using AudioMetaData.getRating() doesn't
    actually re-read the file's metatdata it's reads from iTunes.xml?

  5. Support Staff 5 Posted by hendrik on 17 Nov, 2016 08:40 PM

    hendrik's Avatar

    So reading from the file using AudioMetaData.getRating() doesn't actually re-read the file's metatdata it's reads from iTunes.xml?

    No. Using AudioMetaData you're always reading from the audio file, not from the iTunes Library.xml file.

    As a matter of fact, there is no documented API in beaTunes that lets you read the iTunes Library.xml file directly. You are either reading from the internal beaTunes database (which is based on the iTunes Library.xml file through synchronization) or you are reading from the file itself (via an AudioMetaData subclass).

  6. 6 Posted by ryan on 17 Nov, 2016 11:56 PM

    ryan's Avatar

    Ok .. so this whole issue of mine with a CloudStation folder (similar to
    Dropbox) containing all my tracks interferes with file write permissions
    from time to time .. i.e won't let tags be written while it's syncing
    the file and after it's synced it .. seems to keep a lock on the file
    which is screwing with my testing. Realising this has also solved my
    issues reported in this discussion:
    http://help.beatunes.com/discussions/problems/44201-comment-field-not-being-written

    So after pausing the syncing app. I can confirm
    AudioMetaData.getRating() is reading the POPULARIMETER from the file. So
    I can save my ratings made in Traktor or Rekordbox etc. back to iTunes
    now. Great.

    Is the a priority of which rating tag AudioMetaData.getRating()
    retrieves? I can see POPULARIMETER and FMPS_RATING in the file (see
    screen shot).

    Perhaps a method that can grab any tag such as
    AudioMetaData.getId3Tag(TAG_NAME) would be handy??

    Thanks
    Ryan
    ------------------------------------------------------------------------

  7. Support Staff 7 Posted by hendrik on 18 Nov, 2016 07:48 AM

    hendrik's Avatar

    FMPS_RATING is only read as fallback, if there is no regular POPM frame.

    AudioMetaData is a more or less smart wrapper around JAudioTagger, which is used under the hood. If your goal is to get fine-grained control over ID3 tags or the like, you might want to use the JAudioTagger API.

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:

»

Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac