我試圖通過單擊按鈕啓動電影。當我點擊電影播放器出現並工作正常。電影一直播放到最後,電影播放器消失。它消失後,我的應用程序崩潰...當我的電影完成播放時,應用程序崩潰
我用在標籤欄的應用我的視圖控制器,此代碼:
- (void)moviePlayBackDidFinish:(NSNotification *) aNotification{
MPMoviePlayerController *player = [aNotification object];
[player setFullscreen:NO animated:YES];
[player.view removeFromSuperview];
[player stop];
player.initialPlaybackTime = -1.0;
[[NSNotificationCenter defaultCenter] removeObserver:self name:MPMoviePlayerPlaybackDidFinishNotification object:player];
[player release];
player=nil;
}
- (IBAction)playVideo:(UIButton *)playButton{
NSString *url = [[NSBundle mainBundle] pathForResource:@"Teaser 04" ofType:@"mov"];
MPMoviePlayerController *player = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL fileURLWithPath:url]];
player.shouldAutoplay = YES;
player.view.frame = CGRectMake(0., 44., self.view.bounds.size.width, self.view.bounds.size.height-44);
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayBackDidFinish:) name:MPMoviePlayerPlaybackDidFinishNotification object:player];
[self.view addSubview:player.view];
[player play];
}
我不知道我做錯了。我只是想設置一個按鈕,開始播放視頻,並在視頻結束時,MoviePlayer查看消失,應用回到我最初的.xib
謝謝您的幫助
感謝您的鏈接,但這不是關於此。我通過movieFinishedCallBack切換功能moviePlayBackDidFinish – Mitch 2011-03-16 20:16:30
他不是釋放播放器,而是釋放它。 – Till 2011-03-31 09:25:43
他不是通過在那裏調用「release」來有效地釋放它嗎? – 2011-04-06 21:03:08