I've noticed that getting artist/album/title metadata from audio files via AudioFileGetPropertyInfo / AudioFileGetProperty works for .mp3's (in that getting the kAudioFilePropertyInfoDictionary property returns a CFDictionaryRef with non-trivial data), but not for iTunes .m4a's, for which the dictionary contains only an approximate duration.
I noticed the user data functions, and wondered if those might be where I could find this metadata for an .m4a, analogous to the user data atom of a QuickTime file.
Thing is, I don't see any examples that use the user data functions, or a list of what four-char-codes might be amenable to them... which probably makes sense if the user data 4ccs are format dependent.
The other problem is that the call to AudioFileCountUserData isn't even working for me. I took a shot in the dark and tried to get the 4cc that iTunes uses for track number:
// debug - look at user data UInt32 item4CC = 'trkn'; UInt32 itemCount = 0; err = AudioFileCountUserData (audioFile, item4CC, &itemCount); if (err == noErr) { NSLog (@"Got %d user data items"); } else { CFErrorRef error = CFErrorCreate(NULL, kCFErrorDomainOSStatus, err, NULL); NSLog (@"Error: %@", error); CFRelease (error); }
The result is an error:
2009-01-22 14:35:55.654 SimpleAudioPlayer[3531:20b] Error: Error Domain=NSOSStatusErrorDomain Code=1869627199 UserInfo=0x52c5b0 "Operation could not be completed. (OSStatus error 1869627199.)"
Any suggestions are welcome. This is on iPhone, but I'm broadly interested in mastering the Audio File * APIs on both iPhone and Mac.
--Chris
BTW, while I'm being a nuisance... I could swear there's a CF function that lets you pass in a 4CC as a string and returns you a UInt32. Is there such a thing? |