1

mpmovieplayercontroller をトリガーしてストリーミング オーディオを再生するボタンがあります。コントローラーが再生されているとき、すべてが期待どおりに機能し、灰色のクイックタイムの背景が表示されます。

ただし、プレーヤーを停止してもう一度ボタンを押すと、音声は聞こえますが、背景が黒くなります。また、mp3 を再生する前にビデオ ストリームに切り替えると、クイックタイムの背景が再び表示されます。

クイックタイムの背景が消えるのを止める方法を知っている人はいますか?

どんな助けでも大歓迎です。

-(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 に答える