iPhone應用中使用MPMoviePlayerController視頻播放是本文要介紹的內容,內容很少,主要是基於代碼來實現如何使用MPMoviePlayerController視頻播放的內容,具體內容來看本文詳解, html
//http://www.baisoujs.com
- -(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視頻播放的內容介紹完了,但願經過本文的學習能對你有所幫助! 學習
原文: http://www.baisoujs.com/detail_136976458092290.html