0
我必須背對背播放兩個音頻文件。 我有一個通用文件,它說: 「我的名字是」在MPMoviePlayerController中播放音頻
然後跟隨另一個音頻文件,其中有另一個音頻字符串。
例如:說a.mp3有 「我的名字是」 b.mp3有 「約翰」
但是,當我設置的MPMoviePlayerController的的contentURL。它跳過第一個音頻並播放第二個音頻。
這裏是我的代碼:
- (void) playPromptAudio
{[appDelegate.globalPlayer setContentURL:[NSURL
URLWithString:@"http://localhost/a.mp3"]];
[appDelegate.globalPlayer prepareToPlay];
[appDelegate.globalPlayer play];
while (appDelegate.globalPlayer.playbackState == MPMoviePlaybackStatePlaying) {
// dirty hack, do gracefully
// do nothing
}
[appDelegate.globalPlayer setContentURL:[NSURL URLWithString:@"http://localhost/b.mp3"]];
[appDelegate.globalPlayer prepareToPlay];
[appDelegate.globalPlayer play];
}
但是當我運行的代碼,唯一的「約翰」被播放。
調試完代碼後,我看到音頻在執行完整個函數後開始播放,因此很顯然「約翰」是從最後設置開始播放的。但是有沒有辦法阻止這種行爲?
謝謝,但鏈接是爲MPMusicPlayerController – krammer 2012-04-26 13:00:36
好吧,現在我更新答案...! – Dinesh 2012-04-26 13:04:34
我更新的答案試試這個..! – Dinesh 2012-04-26 13:11:42