2009-09-30 111 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; 
}