我目前正在使用AVAudioPlayer在我的應用程序的背景中播放循環音樂。但是,當siri在我的應用程序中打開時,會關閉它。我非常熟悉客觀的C,但我似乎無法得到這個工作。有什麼方法可以告訴用戶何時打開siri,以便在停止後再次啓動AVAudioPlayer。請幫忙! P.S我試圖不斷播放音頻,但然後siri不會工作。開幕Siri停止AVAudioPlayer
回答
您可以使用AVAudioPlayerDelegate的audioPlayerEndInterruption:withOptions:
- (void)audioPlayerEndInterruption:(AVAudioPlayer *)player withOptions:(NSUInteger)flags {
[player play];
}
非常感謝!你讓我非常沮喪。 –
其他任何人來此,endInterruption
委託別再從我調用時我的應用程序被通過Siri的中斷。當它再次變爲活動狀態時(使用通知),我必須讓應用繼續播放。
[看起來](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
- 1. iPhone:MPMusicPlayerController停止AVAudioPlayer
- 2. 停止的AVAudioPlayer
- 3. 停止AVAudioPlayer
- 4. 如何停止AVAudioPlayer
- 5. 停止執行()開幕
- 6. 玩AVAudioPlayer後停止音頻
- 7. iOS5,iOS6爲什麼AVAudioPlayer播放在屏幕鎖定時停止?
- 8. iOS AVAudioPlayer聲音在屏幕鎖定時停止播放
- 9. iPhone AVAudioPlayer停止背景音樂
- 10. AVAudioPlayer立即停止播放ARC
- 11. AVAudioPlayer「滴答」停止或恢復時,
- 12. AVAudioPlayer在播放時不會停止
- 13. AVAudioPlayer停止聲音並從頭播放
- 14. AVAudioPlayer停止聲音iPhone SDK目標C
- 15. 如何安全地停止AVAudioPlayer
- 16. 使用AVAudioPlayer幫助停止音頻
- 17. AVAudioPlayer在文件結束前停止
- 18. 問題啓動和停止AVAudioPlayer
- 19. AVAudioPlayer不停止玩Touch Up Inside
- 20. 在另一個類別中停止AVAudioPlayer
- 21. 停止不同類別的AVAudioplayer
- 22. 一鍵停止所有音頻AVAudioPlayer
- 23. AVAudioPlayer在呼叫停止時崩潰
- 24. AVAudioPlayer沒有響應停止命令?
- 25. 暫停按鈕停止AVAudioPlayer而不是暫停
- 26. 開源Siri克隆
- 27. 即使類別爲AVAudioSessionCategoryPlayback,AVAudioPlayer也會停止在屏幕鎖定上播放
- 28. 爲什麼AVAudioplayer在viewWillDisappear時不停止/暫停?
- 29. AVAudioPlayer播放/暫停/停止和UIViewController發佈/ dealloc
- 30. 暫停AVAudioplayer幾秒
您是否收到音頻中斷通知?你在使用什麼音頻會話類別? –