我正在使用此代码使用MPMoviePlayerController*mpc
播放视频:
NSString *stringPath = [[NSBundle mainBundle]pathForResource:@"movie" ofType:@"mp4"];
NSURL *url = [NSURL fileURLWithPath:stringPath];
mpc = [[MPMoviePlayerController alloc]initWithContentURL:url];
[mpc prepareToPlay];
CGRect frame = self.view.frame;
frame.origin = CGPointZero;
mpc.view.frame = frame;
mpc.allowsAirPlay = NO;
mpc.shouldAutoplay = NO;
mpc.movieSourceType = MPMovieSourceTypeFile;
mpc.scalingMode = MPMovieScalingModeFill;
mpc.controlStyle = MPMovieControlStyleNone;
mpc.view.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
dispatch_async(dispatch_get_main_queue(), ^{
[self.view addSubview:mpc.view];
});
[mpc play];
我想在播放视频的过程中记录用户使用前置摄像头的反应并保存。我怎么能这样做?
EDIT1: 这是我记录反应的代码。
- (void)recordReactions{
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
videoRecorder = [[UIImagePickerController alloc]init];
videoRecorder.delegate = self;
videoRecorder.sourceType = UIImagePickerControllerSourceTypeCamera;
NSArray *sourceTypes = [UIImagePickerController availableMediaTypesForSourceType:videoRecorder.sourceType];
NSLog(@"Available types for source as camera = %@", sourceTypes);
videoRecorder.cameraDevice=UIImagePickerControllerCameraDeviceFront;
videoRecorder.mediaTypes = [NSArray arrayWithObject:(NSString*)kUTTypeMovie];
videoRecorder.videoQuality = UIImagePickerControllerQualityTypeLow;
videoRecorder.videoMaximumDuration = 120;
[self presentViewController:videoRecorder animated:YES completion:nil];
[self presentViewController:videoRecorder animated:NO completion:nil];
int64_t delayInSeconds = 2.0;
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, delayInSeconds * NSEC_PER_SEC);
dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
[videoRecorder startVideoCapture];
[videoRecorder performSelector:@selector(stopVideoCapture) withObject:nil afterDelay:5];
videoRecorder.showsCameraControls=YES;
});
}
else {
NSLog(@"Error");
}
}
这会记录呈现视图的视频。但我想在播放主流视频时使用前置摄像头录制视频。