I am capturing a five seconds long mp4 file. I would for the User to be able to play and review the video before uploading it to Parse. I don't want to save the video to the local photo library, I just want to replay. Should I be saving the file to the temporary directory like so:
NSString *outputPath = [NSTemporaryDirectory() stringByAppendingPathComponent:@"output.mov"];
NSURL *outputURL = [[NSURL alloc] initFileURLWithPath:outputPath];
NSFileManager *fileManager = [NSFileManager defaultManager];
if ([fileManager fileExistsAtPath:outputPath])
{
NSError *error;
if ([fileManager removeItemAtPath:outputPath error:&error] == NO){
NSLog(@"File removed from outputPath");
};
}
[MovieFileOutput startRecordingToOutputFileURL:[NSURL fileURLWithPath:outputPath]
recordingDelegate:self];
Can I play the video using this method?
- (IBAction)playVideo:(id)sender {
NSString *filePath = [NSTemporaryDirectory() stringByAppendingPathComponent:@"Output.mp4"];
NSURL *fileURL = [NSURL URLWithString:filePath];
self.avPlayer = [AVPlayer playerWithURL:fileURL];
AVPlayerLayer *movieLayer = [AVPlayerLayer playerLayerWithPlayer:self.avPlayer];
self.avPlayer.actionAtItemEnd = AVPlayerActionAtItemEndNone;
[_avPlayer play];
}