Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
889 views
in Technique[技术] by (71.8m points)

iphone - 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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...