如何在应用程序后台播放音频文件?
在我的应用程序中,只要它运行,我就必须在应用程序后台播放音频文件。我详细介绍了我的过程,如下所示,
我有表格视图,当我单击该表格视图中的特定单元格时,它会加载网页。该网页包含许多音频文件链接,单击特定链接后,只要我的应用程序正在运行,我就需要在应用程序后台播放相应的音频,并且不需要显示任何播放器、列表等。
注意:我使用的是早期版本的 iOS 4
谢谢!
In my application, I have to play audio file in application background as long as its running. And I have detailed my process as below,
I have tableview and when I click the particular cell in that tableview then its loads web page. This webpage contains number of audio file link, After clicked the particular link then I need to play that corresponding audio in my application background as long as my application is running and No need to show any player, list and all.
Note: I am using earlier version of iOS 4
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您了解过 OpenAL 框架吗?它最初的目的是在游戏中播放背景音乐,我不知道你可以在多大程度上定制它用于音频流(我想这就是你想要的?)。否则,您始终可以使用音频工具箱框架,在后台线程中启动音乐并隐藏播放器。
Did you read about the OpenAL framework? It is originally meant to play background music in games and I don't know how much you can custumize it for audio streaming (what i suppose is what you want?). Else you can always use the Audio Toolbox framework, start the music in a background thread and hide the player.
即使在模拟器上运行时设置了所有必需的参数,音频也不会在后台播放,在设备上运行它可以通过将 UIBackgroundModes 设置为 info.plist 和 AVAudioSessionCategoryPlayBack 中的音频来完美运行
The audio is not played in background even if set all the required parameters while running on simulator, run on device it'll work perfectley by setting UIBackgroundModes to audio in info.plist and AVAudioSessionCategoryPlayBack