AudioQueueStart 失败 -12985 [英] AudioQueueStart fail -12985

查看:13
本文介绍了AudioQueueStart 失败 -12985的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我制作了一个流媒体音乐播放器,它在前台运行良好.但在iOS4后台,它不会自动播放下一首歌曲.(遥控工作)原因是AudioQueueStart return -12985.

I made a streaming music player and it works fine in the foreground. But in the background iOS4, it doesn't play the next song automatically. ( remote control works ) The reason is AudioQueueStart return -12985.

我已经检查了音频会话.就好了.我在开始播放音乐时使用 AudioQueueStart.如何删除 AudioQueueStart?

I already check the audio session. it just fine. I use AudioQueueStart when it start to play the music. How can you remove AudioQueueStart?

- (void)play
{
    [self setupAudioQueueBuffers];    // calcluate the size to use for each audio queue buffer, and calculate the // number of packets to read into each buffer
    OSStatus status = AudioQueueStart(self.queueObject, NULL); 
}

<小时>

我在网上阅读了关于 AudioQueueStart 失败主题的答案.

要检查的一点是 AudioSession 首先是活动的.就我而言,我之前在开始新歌曲之前将会话设置为在歌曲更改之间处于非活动状态:AudioSessionSetActive(false);

One thing to check is that the AudioSession is active first. In my case, I had previously set the session to inactive between song changes before starting a new song:AudioSessionSetActive(false);

一旦我删除了这个 AudioQueueStart 就可以从后台正常工作.

Once I removed this AudioQueueStart works just fine from the background.

推荐答案

根据我的经验,出现 -12985 消息是因为当您尝试在您的应用中开始播放时,另一个应用已经有一个音频会话处于活动状态.选项是 1) 指示用户关闭其他应用程序,或 2) 设置混合模式(请参阅 kAudioSessionProperty_OverrideCategoryMixWithOthers).

In my experience, the -12985 message occurs because another app already has an audio session active when you try to start playback in your app. Options are to 1) instruct the user to close the other app, or 2) set mix mode (see kAudioSessionProperty_OverrideCategoryMixWithOthers).

混合模式的缺点是如果您依赖锁屏艺术或遥控器,它们将无法使用混合模式设置.

The disadvantage of mix mode is if you depend on lock screen art or remote controls, they won't work with mix mode set.

这篇关于AudioQueueStart 失败 -12985的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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