如何使用AVAudioPlayer在后台播放音乐,一边? [英] How do you use AVAudioPlayer to play music while in the background?

查看:305
本文介绍了如何使用AVAudioPlayer在后台播放音乐,一边?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前使用AVAudioPlayer而在前台,但是当我preSS home键我的应用程序去的背景和音乐停止播放音乐。我设置的类别为我AVAudioSession到AVAudioSessionCategoryPlayback并设置为活动为YES。此外,我还添加了音频键UIBackgroundModes在我的Info.plist。

I currently use AVAudioPlayer to play music while in the foreground, but when I press the home button my application goes to the background and the music stops. I set the category for my AVAudioSession to AVAudioSessionCategoryPlayback and set active to YES. Additionally, I added the audio key to UIBackgroundModes in my Info.plist.

还有什么我需要做的,使背景音乐播放?

Is there anything else I need to do to enable background music playback?

推荐答案

有很明显的在模拟器中的错误 - 它没有在那里工作,而它在设备上工作精细

There's apparently a bug in the simulator - it doesn't work there, while it works fine on the device.

(编辑:由不工作我的意思是,当应用程序进入的背景,但玩家的状态保持玩,似乎让玩的声音停止,但你不能听到它)

( and by "doesn't work" I mean the sound stops when the app enters background, yet the player's status remains "playing" and it seems to keep "playing", although you can't hear it).

这篇关于如何使用AVAudioPlayer在后台播放音乐,一边?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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