AudioQueueStart失败-12985

发布于 2024-10-05 18:11:58 字数 722 浏览 13 评论 0原文

我制作了一个流媒体音乐播放器,它在前台运行良好。 但在iOS4后台,不会自动播放下一首歌曲。 (远程控制有效) 原因是AudioQueueStart返回-12985。

我已经检查了音频会话。就好了。当它开始播放音乐时,我使用 AudioQueueStart 。 如何删除 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);

一旦我删除此 AudioQueueStart,它就可以从后台正常工作。

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.

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); 
}

I read the answer in the web about the AudioQueueStart fail subject.

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);

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

顾忌 2024-10-12 18:11:58

根据我的经验,出现 -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.

不回头走下去 2024-10-12 18:11:58

一周前我也遇到过这样的问题。我花了两天时间寻找解决方案,我找到了。可能这个链接会有所帮助(这是官方答案): http:// /developer.apple.com/library/ios/#qa/qa1668/_index.html

确保从 applicationDidEnterBackground 任务处理程序激活会话。现在我的应用程序可以在后台播放声音。

I also faced with such problem week ago. I've spent two days to find solution and I found it. May be this link will help (it is official answer): http://developer.apple.com/library/ios/#qa/qa1668/_index.html

Make sure that you activate session from applicationDidEnterBackground task handler. Now my application can play sound in background.

人心善变 2024-10-12 18:11:58

请参阅

您可能需要包含以下内容:

[[UIApplication sharedApplication] beginReceivingRemoteControlEvents];

在底部,重申了该行的重要性。由于三个主要音频音频指南(AVFoundation、AudioSession 或 AudioQueue)中都没有提到它,因此很容易被错过。

See this.

You probably need to include the following:

[[UIApplication sharedApplication] beginReceivingRemoteControlEvents];

Towards the bottom there is a reiteration of the how important that line is. As it is not mentioned in any of the three main audio audio guides (AVFoundation, AudioSession, or AudioQueue) it can easily be missed.

烙印 2024-10-12 18:11:58

我有同样的问题。
我注册了AudioSessionInterruptionListener,在打电话时暂停音频,在通话结束后恢复音频。但在调用 AudioQueueStart 恢复时收到 -12985 错误代码。
我的解决方案是我尝试在0.02s后调用AudioQueueStart。
我不知道原因。

I have the same problem.
I registry the AudioSessionInterruptionListener, pause the audio when phone call, resume it after the call end. but get -12985 error code when call AudioQueueStart to resume.
My solution is that I try to call AudioQueueStart after 0.02s.
I don't know the reason.

旧话新听 2024-10-12 18:11:58

在 iOS7 上,AudioQueueStart 返回 '!int' ('tni!'),尽管我确信没有人会惊讶地发现它没有记录在文档或标头中。不过,这是同样的问题,并且相同的修复(将音频会话设置为在后台任务处理程序中处于活动状态)对我有用。

On iOS7, AudioQueueStart was returning '!int' ('tni!'), though i'm sure no one would be surprised to find that it's not documented in the docs or headers. It was the same issue, though, and the same fix (setting the audio session to active in the background task handler) worked for me.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文