如何使用AVAudioPlayer在后台播放音乐,一边?

编程入门 行业动态 更新时间:2024-10-26 04:32:33
本文介绍了如何使用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在后台播放音乐,一边?

本文发布于:2023-07-11 09:05:32,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1093516.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何使用   后台   音乐   AVAudioPlayer

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!