2013-03-31 36 views
0

我目前正在使用AVAudioPlayer在我的應用程序的背景中播放循環音樂。但是,當siri在我的應用程序中打開時,會關閉它。我非常熟悉客觀的C,但我似乎無法得到這個工作。有什麼方法可以告訴用戶何時打開siri,以便在停止後再次啓動AVAudioPlayer。請幫忙! P.S我試圖不斷播放音頻,但然後siri不會工作。開幕Siri停止AVAudioPlayer

+0

您是否收到音頻中斷通知?你在使用什麼音頻會話類別? –

回答

2

您可以使用AVAudioPlayerDelegate的audioPlayerEndInterruption:withOptions:

- (void)audioPlayerEndInterruption:(AVAudioPlayer *)player withOptions:(NSUInteger)flags { 
     [player play]; 
} 
+0

非常感謝!你讓我非常沮喪。 –

0

其他任何人來此,endInterruption委託別再從我調用時我的應用程序被通過Siri的中斷。當它再次變爲活動狀態時(使用通知),我必須讓應用繼續播放。

+0

[看起來](https://developer.apple.com/library/prerelease/ios/documentation/AVFoundation/Reference/AVAudioPlayerDelegateProtocolReference/index.html#//apple_ref/occ/intfm/AVAudioPlayerDelegate/audioPlayerBeginInterruption :)就像調用iOS8.0中不推薦使用audioPlayerBeginInterruption和audioPlayerEndInterruption。我放棄了試圖通過這些手段來處理Siri打擾,並且正在和你一樣走下去。 – Mike