admin管理员组文章数量:1332361
I'm working on a web app that plays through a playlist of mp3 files and I'm running into an issue on mobile browsers. I'll start playing a song and immediately turn the screen off. The website will continue to run and play 2-3 songs. After that it stops playing. I have only tested this with chrome on android.
What can I can do to keep the music playing?
I'm working on a web app that plays through a playlist of mp3 files and I'm running into an issue on mobile browsers. I'll start playing a song and immediately turn the screen off. The website will continue to run and play 2-3 songs. After that it stops playing. I have only tested this with chrome on android.
What can I can do to keep the music playing?
Share Improve this question asked Dec 20, 2013 at 1:30 user2492019user2492019 271 silver badge2 bronze badges 3-
The website will continue to run and play 2-3 songs.
It will? – Derek 朕會功夫 Commented Dec 20, 2013 at 1:38 - 1 This is most likely not something you can solve. The way Android works internally is by just shutting down or 'freezing' applications that do not need resources to save on battery. What you experience is most likely the system freezing Chrome because 'nobody is using it' as far as the system knows - you abandoned it a few minutes ago. This is not something you can control without native system access, which you don't have inside the browser. – Niels Keurentjes Commented Dec 20, 2013 at 1:49
- afaik on iOS the backgrounded programm will go to sleep after some minutes. the only way to keep it alive is to poll(wakeup via notification / notification center / local push) it every now and then. afaik this is not doeable within a webappp. or is it? – jko Commented Dec 20, 2013 at 1:57
2 Answers
Reset to default 10If the screen is turned off you can't stop the OS from shutting down or freezing apps - as @Niels points out in the question ments.
However, you can keep the screen awake by using this NoSleep JavaScript library: https://github./richtr/NoSleep.js
There's an official API to keep screens awake these days! More info at https://web.dev/wake-lock/
本文标签: javascripthow do I keep a mobile browser awakeStack Overflow
版权声明:本文标题:javascript - how do I keep a mobile browser awake - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742318038a2452206.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论