iOS: Saving audio file visible in iTunes Library

2019-07-18 05:36发布

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!

2条回答
混吃等死
2楼-- · 2019-07-18 05:48

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.

查看更多
我命由我不由天
3楼-- · 2019-07-18 05:50

try saving files to NSMusicDirectory .

查看更多
登录 后发表回答