Now I'm trying to export an mp3 file that was a player using AVPlayer (using the url), so it does not need to be downloaded twice.
This is my sample code:
I tried every outputFileType ...
self.exporter = [[AVAssetExportSession alloc] initWithAsset:self.asset presetName:AVAssetExportPresetPassthrough]; } NSError *error; NSLog(@"export.supportedFileTypes : %@",self.exporter.supportedFileTypes); // "com.apple.quicktime-movie", // "com.apple.m4a-audio", // "public.mpeg-4", // "com.apple.m4v-video", // "public.3gpp", // "org.3gpp.adaptive-multi-rate-audio", // "com.microsoft.waveform-audio", // "public.aiff-audio", // "public.aifc-audio", // "com.apple.coreaudio-format" self.exporter.outputFileType = @"public.aiff-audio"; self.exporter.shouldOptimizeForNetworkUse = YES; NSURL *a = [[NSFileManager defaultManager] URLForDirectory:NSDocumentDirectory inDomain:NSUserDomainMask appropriateForURL:nil create:YES error:&error]; NSURL *url = [a URLByAppendingPathComponent:@"filename.mp3"]; NSString *filePath = [url absoluteString]; self.exporter.outputURL = url; if (![[NSFileManager defaultManager] fileExistsAtPath:filePath]){ [self.exporter exportAsynchronouslyWithCompletionHandler:^{ if (self.exporter.status == AVAssetExportSessionStatusCompleted) { if (![[NSFileManager defaultManager] fileExistsAtPath:filePath]){ NSLog(@"File doesn't exist at path"); }else { NSLog@"File saved!"); } } else if(self.exporter.status == AVAssetExportSessionStatusFailed){ NSLog(@"Failed"); }else if(self.exporter.status == AVAssetExportSessionStatusUnknown){ NSLog(@"Unknown"); }else if(self.exporter.status == AVAssetExportSessionStatusCancelled){ NSLog(@"Cancelled"); }else if(self.exporter.status == AVAssetExportSessionStatusWaiting){ NSLog(@"Waiting"); }else if(self.exporter.status == AVAssetExportSessionStatusExporting){ NSLog(@"Exporting"); } NSLog(@"Exporter error! : %@",self.exporter.error); }]; }}else{ NSLog(@"File already exists at path"); }
If this is not possible, is there any work?
Also, since I can change the format of the audio file. What is the ideal type to work with AVAudioPlayer?
ios audio mp3 avplayer avassetexportsession
jonypz
source share