电影在 MPMoviePlayerController 中播放得很好。但是当我按下按钮时,视频必须改变黑白或复古效果。
- (IBAction)videoCameraRoll:(id)sender
{
UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
imagePicker.delegate = self;
imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
imagePicker.mediaTypes = [[NSArray alloc] initWithObjects:(NSString *)kUTTypeMovie, nil];
[self presentViewController:imagePicker animated:YES completion:NULL];
}
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
NSURL *movieURL;
NSString *mediaType = [info objectForKey: UIImagePickerControllerMediaType];
if (CFStringCompare ((__bridge CFStringRef) mediaType, kUTTypeMovie, 0) == kCFCompareEqualTo)
{
movieURL=(NSURL*)[info objectForKey:UIImagePickerControllerMediaURL];
}
movieController = [[MPMoviePlayerController alloc] initWithContentURL:movieURL];
movieController.view.frame = CGRectMake(0, 56, 320, 200);
movieController.controlStyle = MPMovieControlStyleEmbedded;
movieController.shouldAutoplay = YES;
movieController.scalingMode=MPMovieScalingModeFill;
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(moviePlayBackDidFinish:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:self.movieController];
[self.view addSubview:movieController.view];
[movieController prepareToPlay];
[movieController setFullscreen:NO animated:NO];
[picker dismissViewControllerAnimated:YES completion:NULL];
}
- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker
{
[picker dismissViewControllerAnimated:YES completion:NULL];
}
// Video Play Back Did Finish
- (void)moviePlayBackDidFinish:(NSNotification *)notification {
[[NSNotificationCenter defaultCenter]removeObserver:self name:MPMoviePlayerPlaybackDidFinishNotification object:nil];
[self.movieController stop];
[self.movieController.view removeFromSuperview];
self.movieController = nil;
}