Hello everyone,
I was wondering if anyone has experience reading & writing metadata to an audio file in iOS. So far we've tried:
- AudioFileGet/SetProperty
- kAudioFilePropertyInfoDictionary
- kAFInfoDictionary_Comments
- kAudioFilePropertyID3Tag
I'm getting the 'pty?' error code returned when I try to write to the info dictionary or read the ID3 tag. Also, the only "visible" key/value pair when I get the dictionary is the "approximate duration." I've attached some code to demonstrate how I'm trying to use these functions.
Thanks in advance!
Brian
P.S.
My colleague also posted to Apple's Core Audio support forum:
{
NSURL* url = [ NSURL fileURLWithPath: path2 ];
OSStatus err;
AudioFileID fileID;
err = AudioFileOpenURL ((CFURLRef)url, kAudioFileReadWritePermission, kAudioFileWAVEType,&fileID );
if (err == noErr)
{
CFDictionaryRef fileDict = nil;
UInt32 size = sizeof(fileDict);
err = AudioFileGetProperty(fileID, kAudioFilePropertyInfoDictionary, &size, &fileDict);
if (err == noErr)
{
NSDictionary* dict = (NSDictionary*) fileDict;
NSLog(@"%@",dict);
NSMutableDictionary* dict2 = [ [ NSMutableDictionary alloc ] init ];
[ dict2 addEntriesFromDictionary:dict ];
[ dict2 setObject:@"test" forKey: [ NSString stringWithUTF8String:kAFInfoDictionary_Comments ] ];
err = AudioFileSetProperty(fileID, kAudioFilePropertyInfoDictionary, size, dict2);
if (err == noErr)
{
// this point isn't reached
NSLog(@"saved");
}
}
AudioFileClose(fileID);
}
}
...
{
UInt32 outDataSize = 0;
UInt32 isWritable = 0;
// 'pty?' error here
err = AudioFileGetPropertyInfo(fileID,kAudioFilePropertyID3Tag,&outDataSize,&isWritable);
NSLog(@"outDataSize %d isWritable %d",outDataSize,isWritable);
unsigned char* id3data = malloc(outDataSize);
err = AudioFileGetProperty(fileID, kAudioFilePropertyID3Tag, &outDataSize, id3data);
err++;
}