iOS 9 ReplayKit随机杀死AVAudioPlayer

时间:2015-09-25 10:33:40

标签: avaudioplayer ios9 xcode7

我只是将新ReplayKit添加到我的iOS游戏中,并尝试使用startRecordingWithMicrophoneEnabled开始记录。但是,通过AVAudioPlayer,游戏的背景音乐将在1或2秒后被杀死。我检查了AVAudioPlayerDelegate中的所有接口,但没有触发这些接口:

audioPlayerDidFinishPlaying
audioPlayerBeginInterruption
audioPlayerEndInterruption

有人对此有想法吗?

1 个答案:

答案 0 :(得分:1)

不知道原因,但找到了一个散步。

我无法说明原因,但似乎工作<?php $ch = curl_init("http://www.googles123.com/"); // Send request curl_exec($ch); // Check for errors and display the error message if($errno = curl_errno($ch)) { $error_message = curl_strerror($errno); echo "cURL error ({$errno}):\n {$error_message}"; } // Close the handle curl_close($ch); ?> 实例将变为无效状态而不触发AVAudioPlayer的任何接口。如此简单地在实例上调用AVAudioPlayerDelegate / pause是没用的。

我尝试过的是杀死正在运行的resume实例并创建一个新实例,以便在AVAudioPlayerstartRecordingWithMicrophoneEnabled的两个回调中再次播放相同的音乐。

音乐可能会暂停几毫秒,但优于沉默。