iphone - 使用音频队列处理中断

标签 iphone audio streaming

我正在开发一个音频流媒体,并声明了一个中断监听器,以便在发生中断(例如来电或短信)时保存歌曲的状态。

这是相关代码

在我的 AppDelegate 中,我有这个

AudioSessionInitialize (NULL, NULL, interruptionListenerCallback, self);
AudioSessionSetActive(YES);

这就是中断监听器的样子

void interruptionListenerCallback (void *inUserData, UInt32 interruptionState) {
// This callback, being outside the implementation block, needs a reference 
//to the AudioPlayer object
MyPlayer *player = (MyPlayer *)inUserData;

if (interruptionState == kAudioSessionBeginInterruption) {
    if ([player audioStreamer]) {
        // if currently playing, pause
        [player pausePlayback];
        player.interruptedOnPlayback = YES;
    }

} else if ((interruptionState == kAudioSessionEndInterruption) && player.interruptedOnPlayback) {
    // if the interruption was removed, and the app had been playing, resume playback
    [player resumePlayback];
    player.interruptedOnPlayback = NO;
}

}

当我接到电话时,会调用中断监听器,如果用户拒绝接听电话,还会调用播放恢复方法。但是在调用resumePlayback方法之前,我在AudioQueueEnqueueBuffer的控制台中收到此错误

error: tca! error int: 560030580

有谁知道如何在流式传输音频文件时正确处理音频中断。

谢谢。

最佳答案

此链接显示了问题所在。可能会帮助某人。

https://devforums.apple.com/message/31758#31758

关于iphone - 使用音频队列处理中断,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/673381/

相关文章:

iphone - iPhone内存崩溃:信号0

ios - UITableViewAutomaticDimension 在滚动 iOS8 之前不起作用

Android - 使用 Intent 打开音频内容 uri

用于基于视频的应用程序的 Java : Good choice?

flash - 在Flex移动应用程序中处理多个音频流

ios - 当 UITableView 完成请求数据时得到通知?

ios - SWIFT TableView 没有响应

ios - AVAssetResourceLoaderDelegate 方法覆盖 loadingRequest

ffmpeg - `ffplay`如何检测到来自管道连接的ffmpeg的声音文件已经完成?

nginx - 使用 nginx-rtmp 模块的 HLS 片段长度和播放列表长度