iPhone應(yīng)用中使用MPMoviePlayerController視頻播放
作者:佚名
iPhone應(yīng)用中使用MPMoviePlayerController視頻播放是本文要介紹的內(nèi)容,內(nèi)容不多,主要是基于代碼來實現(xiàn)如何使用MPMoviePlayerController視頻播放的內(nèi)容,具體內(nèi)容來看本文詳解,
iPhone應(yīng)用中使用MPMoviePlayerController視頻播放是本文要介紹的內(nèi)容,內(nèi)容不多,主要是基于代碼來實現(xiàn)如何使用MPMoviePlayerController視頻播放的內(nèi)容,具體內(nèi)容來看本文詳解,
- -(void)openMovie:(id)sender
- {
- NSString *path = [[NSBundle mainBundle] pathForResource:@"movie" ofType:@"m4v"];
- MPMoviePlayerController *movieController = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL fileURLWithPath:path]];
- //設(shè)置要播放的視頻的位置
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(movieFinish:) name:
- MPMoviePlayerPlaybackDidFinishNotification object:movieController]; //設(shè)置視頻播放結(jié)束后的回調(diào)處理
- [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];
小結(jié):iPhone應(yīng)用中使用MPMoviePlayerController視頻播放的內(nèi)容介紹完了,希望通過本文的學習能對你有所幫助!
責任編輯:zhaolei
來源:
互聯(lián)網(wǎng)