1
我使用的MPMoviePlayerController發揮視頻到我的申請沒有得到完善。以下是我播放視頻的代碼。的MPMoviePlayerController:當我們停止的MPMoviePlayerController
**NSURL *url=[[NSURL alloc] initFileURLWithPath:urlPath];
if(moviePlayer)
{
[moviePlayer.view removeFromSuperview];
moviePlayer = nil;
}
moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:url];
moviePlayer.repeatMode = MPMovieRepeatModeOne;
moviePlayer.currentPlaybackTime = 0.0;
moviePlayer.view.frame = _viewMoviePlayer.frame;
moviePlayer.controlStyle = MPMovieControlStyleNone;
moviePlayer.shouldAutoplay = YES;
[_viewMoviePlayer addSubview:moviePlayer.view];
[moviePlayer prepareToPlay];
[moviePlayer play];
[self.view sendSubviewToBack:_viewMoviePlayer];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayBackDidFinish:) name:MPMoviePlayerPlaybackDidFinishNotification object:moviePlayer];**
當viewWillDisappear叫,然後我就停止moviePlayer並從視圖中刪除它。 但我的默認音樂播放器正在運行,但沒有聽到它。當我關閉我的應用程序時,它會。
-(void)viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];
[moviePlayer stop];
[moviePlayer.view removeFromSuperview];
moviePlayer = nil;
[_viewMoviePlayer removeFromSuperview];
_viewMoviePlayer = nil;
}
任何人都可以告訴哪個代碼出錯了嗎?所以我釋放了moviePlayer,然後它會播放默認音樂。 當我檢查當前音樂的音樂,然後它的哦,並且它的演出歌曲在音樂應用程序中運行。但沒有聽起來。