2010-10-25 98 views
1

我有一個iPhone應用程序,需要我在應用程序的整個生命週期中播放循環mp3音效。在iPhone應用程序中播放連續聲音

但基於用戶執行的某些操作,此mp3應該停止/暫停,而&另一個MP3應該播放&然後這個MP3應該繼續播放。

我還沒有真正使用iPhone上的任何音頻API,但我只是使用AudioToolbox播放聲音按鈕水龍頭這就是所有。

那麼你們建議我應該怎麼做。 任何指針...?建議....?

回答

1

正如我在這個post寫道,你可以使用AVAudioPlayer

代碼片段:

NSString *soundFilePath = [[NSBundle mainBundle] pathForResource:@"mySound" ofType:@"mp3"]; 
NSURL *soundFileURL = [NSURL URLForString:soundFilePath]; 
AVAudioPlayer *player = [[AVAudioPlayer alloc]initWithContentsOfURL:soundFileURL]; 
player.numberOfLoops = -1; //infinite 

[player play]; 

,你可以暫停:

[player pause]; 
+0

是我沒有找到這個解決方案後, googling多一點..儘管如此,謝謝你的答覆 – 2011-01-04 19:01:50

相關問題