Search code examples
iositunesnsfilemanager

iOS: Saving audio file visible in iTunes Library


I am trying to save a mp3 file into a folder where the file could be visible in iTunes Library. I read somewhere that if I save it on NSDocumentDirectory, it would work, but I had no luck on trying that.

I also tried NSMusicDirectory and NSLibraryDirectory.

this is how I'm saving it:

NSArray *documentPath = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *docDirectory = [documentPath objectAtIndex:0];
NSString *savePath = [docDirectory stringByAppendingPathComponent:@"file.mp3"];
[_oneNSDataFile writeToFile:savePath atomically:YES];

thanks for your time!


Solution

  • Sorry, bad news :) The iPod Library Access API in iOS doesn't allow third party apps to modify the contents of the user's music library. In addition to that, adding a media file into the library directory won't work, because the library uses a (binary) index file to determine the contents of the library, and the locations of the media assets.