HTML5 audio / javascript stops working on Android (google chrome) when the screen is off

I created a web application that plays a music playlist, and it works well on desktop browsers, as well as in Mozilla and Opera android. But when I play songs in Chrome browser in Android and I turn off the screen, it stops after playing the current song. And as soon as I turn on the screen, it starts loading the next song in line.

From my observations, I realized that the Google Chrome browser on Android disables javascript code execution if the screen is turned off until the screen wakes up again. Is there a way to prevent my specific library from stopping? Any approach or events?

Some of these questions are related to what I'm looking for: JavaScript dwells on the inactive tab of Chrome Chrome

There are so many WebApps that it doesnโ€™t stop playing music. Do I need some permissions from the Google App Store?

+5
source share
2 answers

to check what is happening with youtube, at least a few years ago I had a terrible time related to this, and what my client proved, he can not be completed within the given time frame and budget. which was actually device-specific, on some devices it worked fine, but on others it didnโ€™t. check if this is happening on other devices. the only solutions that I could think about the dishes, so as not to turn off the screen (on problem devices or everything at the beginning), or create an application and handle the onPause event

0
source

I donโ€™t think you can change the behavior of the Chrome application, if they want to keep the battery in the background and stop javascript, you wonโ€™t activate it.

Perhaps there are other ways to make it work.

  • Tell your users that they must use Firefox or Opera on their mobile device.

  • All applications can play or stream music in the background so you can create or use the application for your task.

  • Perhaps you can use the default music player app on Android. Open the streaming playlist using the app. (I do not know if this is possible because I do not have an Android device.)

I know that this is not exactly what you want, but perhaps a way to make it work.

0
source

Source: https://habr.com/ru/post/1240514/


All Articles