处理与音频队列中断 [英] Handling interruptions with Audio queue

查看:166
本文介绍了处理与音频队列中断的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开发的音频流光并宣布中断监听器保存状态的一首歌,当中断发生 - 就像来电或短信

I am developing an audio streamer and have declared an interruption listener to save state of a song when an interruption occurs - like an incoming call or an sms.

下面是相关code

在我的AppDelegate,我有这个

In my AppDelegate, I have this

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

这是中断监听器是什么样子

This is what the interruption listener looks like

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得到这个错误

When I get a phone call the interruption listener is called and if the user declines the call the playback resume method is also called. But before the resumePlayback method is called, I get this error in the console for AudioQueueEnqueueBuffer

错误: TCA 错误INT: 560030580

有没有人对如何流音频文件时要正确处理音频中断的想法。

Does anyone have an idea of how to correctly handle audio interruptions when streaming audio files.

感谢。

推荐答案

此链接显示的问题是什么。可以帮助别人。

This link shows what the problem is. Might help someone.

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

这篇关于处理与音频队列中断的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆