2009-09-30 112 views
1

我有一個按鈕,觸發mpmovieplayercontroller播放一些流式音頻。當控制器播放一切正常,我看到灰色的QuickTime背景。iphone mpmovieplayercontroller mp3顯示黑色背景

但是,當我停止播放器並再次按下按鈕時,我仍然聽到音頻,但背景現在變成黑色。而且,如果我在播放mp3之前切換到視頻流,QuickTime背景會重新出現。

是否有人知道如何阻止quicktime背景消失。

任何幫助,非常感謝。

-(IBAction) playmp3 { 
NSString *medialink = @"http://someWebAddress.mp3"; 
self.player = [[[MPMoviePlayerController alloc] initWithContentURL:[NSURL URLWithString:medialink]] autorelease]; 
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayerDidFinish:) name:@"MPMoviePlayerPlaybackDidFinishNotification" object:self.player]; 
[self.player play]; 
} 

- (void)moviePlayerDidFinish:(NSNotification *)obj { 
[[NSNotificationCenter defaultCenter] removeObserver:self name:@"MPMoviePlayerPlaybackDidFinishNotification" object:self.player]; 
self.player = nil; 
} 

回答

1

發現答案基本上與玩家不能正確停止有關。您需要將DidFinish功能更改爲以下內容

- (void)moviePlayerDidFinish:(NSNotification *)obj { 
[[NSNotificationCenter defaultCenter] removeObserver:self name:@"MPMoviePlayerPlaybackDidFinishNotification" object:self.player]; 
self.player.initialPlaybackTime = -1.0; 
[self.player stop]; 
self.player = nil; 
}