How to play audio in background with firefox os?

*爱你&永不变心* 提交于 2019-12-19 17:38:23

问题


In my manifest file I've add the audio-channel-content in permissions:

"permissions": {
    "audio-channel-content":{"description":"Use the audio channel for the music player"}
}

In my index.html I've got an audio tag like:

<audio mozaudiochannel="content" preload="none" src="http://my-stream-url"></audio>

I can play my audio stream during 2mn:

  • The first one when the phone is unlock.
  • After 1mn my phone auto-lock the screen and it continue playing for another minute.

Does it possible to play this audio stream more than 1mn after the lock?

Thanks in advance.


回答1:


The code and permission block you have are correct and I can confirm it is working in Firefox OS 1.1. You can also do the whole thing in Javascript:

audio = new Audio();
audio.preload = 'none';
audio.mozAudioChannelType = 'content';



回答2:


It's because the wifi is closed after screen shutdown (auto-lock)?

Are you using the dev version of gaia? Wifi is set to always connect in product version.



来源:https://stackoverflow.com/questions/16895835/how-to-play-audio-in-background-with-firefox-os

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!