get error code -11843 while exporting mp3 file in ipod library since iOS 5.1

后端 未结 1 1810
不知归路
不知归路 2020-12-03 12:44

I use the AVAssetExportSession to export mp3/m4a files in ipod library. This method works well on iOS 5.0 and earlier. However after upgrade iOS to 5.1, this method doesn\'t

相关标签:
1条回答
  • 2020-12-03 13:08

    Finally found a workaround.

    Use AVAssetExportSession to export but append ".mov" at the end of export url. This should make AVAssetExportSession successfully export the song. Last step, rename the exported file with NSFileManager, remove the ".mov" at end.

    To rename a file saved in documents directory, you can use NSFileManager as below:

    NSString *exportFile = ... //.. path of saved *.mov file in documents directory
    NSString *newPath = [[exportFile stringByDeletingLastPathComponent] stringByAppendingPathComponent:@"newFileName.mp3"];
    
    NSError *renameError = nil;
    [[NSFileManager defaultManager] moveItemAtPath:exportFile toPath:newPath error:&renameError];
    
    if (renameError) {
        NSLog (@"renameError=%@",renameError.localizedDescription);
    }else {
        NSLog (@" No renameError(Success) :: newPath=%@",newPath);
    }
    
    0 讨论(0)
提交回复
热议问题