I'm having difficulties writing a audio file's metadata:
AudioFileID fileID = nil;
AudioFileOpenURL((__bridge CFURLRef) url, kAudioFileReadWritePermission, 0, &fileID );
CFDictionaryRef piDict = nil;
UInt32 piDataSize = sizeof(piDict);
AudioFileGetProperty( fileID, kAudioFilePropertyInfoDictionary, &piDataSize, &piDict );
NSLog(@"%@", (__bridge NSDictionary *)piDict);
NSMutableDictionary *dict = (__bridge NSMutableDictionary*)piDict;
[dict setObject:@"NEW ALBUM NAME" forKey:@"album"];
piDict = (__bridge CFDictionaryRef)dict;
piDataSize = sizeof(dict);
OSStatus status = AudioFileSetProperty(fileID, kAudioFilePropertyInfoDictionary, piDataSize, &piDict);
The NSLog on line #6 gives me a nice dictionary with ID3 information. But when I want to alter (for instance the album name, line #9) I get an OSStatus 'pty?' in return.
Anyone who can give me pointers on what I'm doing wrong. Or maybe even a better / simpler / quicker way to edit ID3 tags / metadata for audio files.
Doing almost the same thing here. You can check the OSStatus error with the following code.
NSError *error = [NSError errorWithDomain:NSOSStatusErrorDomain code:status userInfo:nil];
NSLog(@"Error: %@", [error description]);
And what I got is:
Error: Error Domain=NSOSStatusErrorDomain Code=1886681407 "The operation couldn’t be completed. (OSStatus error 1886681407.)"
Could it be that iOS just doesn't allow you to modify kAudioFilePropertyInfoDictionary?
Update:
I just ported idlib3 to iOS and you can use it to modify the ID3 tag. An example project is also included. Check it here https://github.com/rjyo/libid3-ios
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With