简体   繁体   English

Phonegap +多任务音频

[英]Phonegap + Multitasking audio

I'd like to code my phonegap app so at a minimum the audio that is streaming/playing can stay active across pages. 我想编写我的phonegap应用程序代码,因此流媒体/播放的音频至少可以在页面上保持活动状态。 Even better would be a way to have it interact with the OS and stop when a call comes in or they play their own music or something else. 更好的方法是让它与操作系统进行交互,并在呼叫进入或播放自己的音乐或其他内容时停止。

Has anyone accomplished either of these things yet? 有没有人完成这些事情呢?

Thanks! 谢谢!

The PhoneGap Media API plays just fine in the background on both iOS and Android. PhoneGap Media API在iOS和Android的后台播放都很好。

In iOS you have to make sure to set the required background modes to include playback of audio: 在iOS中,您必须确保设置所需的背景模式以包括音频播放:

"Support for some types of background execution must be declared in advance by the app that uses them. An app declares support for a service using its Info.plist file. Add the UIBackgroundModes key to your Info.plist file and set its value to an array containing one or more of the following strings: “支持某些类型的后台执行必须事先由使用它们的应用程序声明。应用程序使用其Info.plist文件声明支持服务。将UIBackgroundModes键添加到Info.plist文件并将其值设置为包含以下一个或多个字符串的数组:

audio—The app plays audible content to the user while in the background. audio-该应用程序在后台播放可听内容给用户。 (This content includes streaming audio or video content using AirPlay.)" (此内容包括使用AirPlay播放音频或视频内容。)“

I don't think anything extra is required for Android. 我不认为Android需要额外的东西。

NOTE : If you have multiple "pages" in your app and music must continue to play amongst them, be sure that the page changes are not actually "file" changes (ie: you are still really displaying index.html, just changing content via js/ajax/etc). 注意 :如果您的应用中有多个“页面”并且音乐必须继续在它们之间播放,请确保页面更改实际上不是“文件”更改(即:您仍然真正显示index.html,只是通过更改内容JS / AJAX /等​​)。 The common mobile JS frameworks handle this just fine (jQuery Mobile, jQTouch, etc etc). 常见的移动JS框架处理这个很好(jQuery Mobile,jQTouch等)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM