Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AudioFileSetProperty returning 'kAudioFileUnsupportedPropertyError (pty?)'

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.

like image 217
basvk Avatar asked Oct 10 '22 03:10

basvk


1 Answers

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

like image 86
rjyo Avatar answered Oct 13 '22 09:10

rjyo