1

我有一个按钮可以触发 mpmovieplayercontroller 播放一些流式音频。当控制器正在播放时,一切都按预期工作,我看到了灰色的 quicktime 背景。

但是,当我停止播放器并再次按下按钮时,我仍然听到声音,但背景现在是黑色的。而且,如果我在播放 mp3 之前切换到视频流,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;
}
4

1 回答 1

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;
}
于 2009-09-30T14:34:13.783 回答