- -(void)playMovie:(NSString *)fileName{
-
- NSString *path = [[NSBundle mainBundle] pathForResource:fileName ofType:@"mp4"];
-
- NSURL *url = [NSURL fileURLWithPath:path];
-
- MPMoviePlayerController *movie = [[MPMoviePlayerController alloc] initWithContentURL:url];
- movie.controlStyle = MPMovieControlStyleFullscreen;
- [movie.view setFrame:self.view.bounds];
- movie.initialPlaybackTime = -1;
- [self.view addSubview:movie.view];
-
- [[NSNotificationCenter defaultCenter] addObserver:self
- selector:@selector(myMovieFinishedCallback:)
- name:MPMoviePlayerPlaybackDidFinishNotification
- object:movie];
- [movie play];
- }
-
- #pragma mark -------------------视频播放结束委托--------------------
-
- -(void)myMovieFinishedCallback:(NSNotification*)notify
- {
-
- MPMoviePlayerController* theMovie = [notify object];
-
- [[NSNotificationCenter defaultCenter] removeObserver:self
- name:MPMoviePlayerPlaybackDidFinishNotification
- object:theMovie];
- [theMovie.view removeFromSuperview];
-
- [theMovie release];
- }
视屏播放
原文:http://www.cnblogs.com/zhaoxiaolei2015/p/4970073.html