- -(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];
- }
posted @
2015-11-16 21:09
赵小磊2015
阅读(
79)
评论()
收藏
举报