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/
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742318038a4421230.html
评论列表(0条)