Note that there are some explanatory texts on larger screens.

plurals
  1. POSaving ID3 tags on iOS
    text
    copied!<p>So I want to make my app edit and save ID3 tags. I found on some site a long time ago on how to read them, here is this code in my app:</p> <pre><code>-(NSDictionary*)MP3InfoDictionary { AudioFileID fileID = nil; OSStatus err = noErr; err = AudioFileOpenURL( (CFURLRef) self, kAudioFileReadPermission, 0, &amp;fileID); if (err != noErr) { //NSLog(@"AudioFileOpenURL failed"); } UInt32 id3DataSize = 0; char * rawID3Tag = NULL; err = AudioFileGetPropertyInfo(fileID, kAudioFilePropertyID3Tag, &amp;id3DataSize, NULL); if (err != noErr) { NSLog(@"AudioFileGetPropeetyInfo failed for ID3 tag"); } //NSLog(@"id3 data size is %lu bytes",id3DataSize); rawID3Tag = (char *) malloc(id3DataSize); if (rawID3Tag == NULL) { //NSLog(@"could not allocated %lu bytes of memory for ID3 tag", id3DataSize); } err = AudioFileGetProperty(fileID, kAudioFilePropertyID3Tag, &amp;id3DataSize, rawID3Tag); if (err != noErr) { NSLog(@"AudioFileGetProperty failed for ID3 tag"); } //NSLog(@"read %lu bytes of ID3 info", id3DataSize); CFDictionaryRef piDict = nil; UInt32 piDataSize = sizeof(piDict); free(rawID3Tag); err = AudioFileGetProperty(fileID, kAudioFilePropertyInfoDictionary, &amp;piDataSize, &amp;piDict); if (err != noErr) { //NSLog(@"AudioFileGetProperty failed for property info dictionary"); } //NSLog(@"Property info:%@", (NSDictionary*)piDict); //CFShow(piDict); NSDictionary *MP3InfoDictionary = (NSDictionary*)piDict; if (MP3InfoDictionary != NULL) { return MP3InfoDictionary; } return nil; } </code></pre> <p>This code is in a NSURL category, the url is a file url of a mp3 in the documents directory of the iOS. It works 100%, I get all the titles, artwork, lyrics, etc. But now I want to save and overwrite values of the mp3 like artist, title, etc. On another post on here a guy posted that you use AudioFileSetProperty(), how do I use it correctly?</p> <p>Apparently it's because of the kAudioFileReadPermission but It tells me that the mp3 is only readable, but that can't be true because another app I have can change ID3 tags and can on the same mp3 I've tried to edit.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload