iPhone应用中使用MPMoviePlayerController视频播放是本文要介绍的内容,内容不多,主要是基于代码来实现如何使用MPMoviePlayerController视频播放的内容,具体内容来看本文详解,
- -(void)openMovie:(id)sender
- {
- NSString *path = [[NSBundle mainBundle] pathForResource:@"movie" ofType:@"m4v"];
- MPMoviePlayerController *movieController = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL fileURLWithPath:path]];
- //设置要播放的视频的位置
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(movieFinish:) name:
- MPMoviePlayerPlaybackDidFinishNotification object:movieController]; //设置视频播放结束后的回调处理
- [movieController play]; //视频播放
- }
- -(void)movieFinish:(NSNotification*)notification
- MPMoviePlayerController *movieController = [notification object];
- [[NSNotificationCenter defaultCenter] removeObserver:self name:MPMoviePlayerPlaybackDidFinishNotification object:movieController];
- [movieController release]; //释放资源
- movieController = nil;
- [[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationPortrait animated:YES];
小结:iPhone应用中使用MPMoviePlayerController视频播放的内容介绍完了,希望通过本文的学习能对你有所帮助!