我試圖將視頻編碼到我的iPhone應用程序中,下面的代碼完美地工作,但唯一的是我寧願視頻不會在用戶自動開始播放時打開頁面。我希望他們能夠按下播放按鈕。下面的代碼位於我的viewcontroller.m文件中。如何讓視頻播放器在使用MPMoviePlayerController時不自動播放
(void)viewDidLoad
{
NSString *url = [[NSBundle mainBundle] pathForResource:@"77860_00_01_MM02_welcome"
ofType:@"mov"];
player = [[MPMoviePlayerController alloc]
initWithContentURL:[NSURL fileURLWithPath:url]];
[[NSNotificationCenter defaultCenter]
addObserver:self selector:@selector(movieFinishedCallback:) name:MPMoviePlayerPlaybackDidFinishNotification object:player];
player.view.frame = CGRectMake(10, 235, 150, 125);
[self.view addSubview:player.view];
[player play];
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void) movieFinishedCallback:(NSNotification*) aNotification {
MPMoviePlayerController *moviePlayer = [aNotification object];
[[NSNotificationCenter defaultCenter]
removeObserver:self
name:MPMoviePlayerPlaybackDidFinishNotification object:moviePlayer];
[moviePlayer.view removeFromSuperview];
[player play];
}