当设备锁定时,AVAudioPlayer将不会播放 [英] AVAudioPlayer will not play when device is locked

查看:112
本文介绍了当设备锁定时,AVAudioPlayer将不会播放的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的应用程序中使用 AVAudioPlayer

I am using AVAudioPlayer in my application. When I select a song it plays, but my problem is, it is not playing when the device gets locked.

推荐答案

当您选择要播放的歌曲时,请阅读在Apple的文档中执行代码。如果您在应用程序的 Info.plist 中将 UIBackgroundModes 键设置为音频,音频将继续播放而背景。

You need to read Executing Code in the Background in Apple's documentation. If you set the UIBackgroundModes key in you app's Info.plist to audio, audio will keep playing while backgrounded.

请参阅上述文档中的声明您支持的后台任务播放背景音频

See the sections Declaring the Background Tasks You Support and Playing Background Audio in the aforementioned documentation.

这篇关于当设备锁定时,AVAudioPlayer将不会播放的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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