I'm generating an .m4a from a video recorded during a AVCaptureVideoPreviewLayer session (using the wonderful PBJVision). I then generate an m4a file from the video captured:
AVAssetExportSession *exportSession=[AVAssetExportSession exportSessionWithAsset:myasset presetName:AVAssetExportPresetAppleM4A];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *audioPath = [documentsDirectory stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.m4a",audioFileName]];
exportSession.outputURL=[NSURL fileURLWithPath:audioPath];
exportSession.outputFileType=AVFileTypeAppleM4A;
[exportSession exportAsynchronouslyWithCompletionHandler:^{
if (exportSession.status==AVAssetExportSessionStatusFailed) {
NSLog(@"failed");
}
else {
[_audioFilePaths setObject:audioPath forKey:audioFileName]
}
and then i try to play
AVAudioPlayer *player = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:[_audioFilePaths objectForKey:square]] error:&error];
NSError *error;
player.numberOfLoops =0;
if (player == nil){
NSLog(@"%@", [error description]);
}
else {
[player play];
}
but nothing plays. I am not ending the video capture session but i've verified the m4a is processed and recorded on the device. i've tried loaded mp3s in the project but they also dont work.
thought this was relevant but didn't help (though i just put it in the didViewLoad call.) AVAudioPlayer turns off iPod - how to work around?
lastly, this is a class within a spritekit project.