Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML5 audio/javascript stops working on android(google chrome) when screen is turned off

I have created a Web App which plays music playlist and it works well on desktop browsers and also in mozilla and opera of android. But When I play the songs on Chrome browser of Android and I turn off the screen, it stops after playing the current song. And as soon as I turn the screen on, it starts loading the next song in line.

From my observations, what I have understood is Google Chrome browser on android pauses the javascript code from executing if the screen is turned off till the screen is not waken up again. Is there any way I can prevent my specific library from pausing? Any approach or events?

Some related this question is what I am looking for: JavaScript halts in inactive android Chrome tab

There are so many WebApps which does not stop playing music. Does it need some permissions from Google App Store?

like image 790
Deepanshu Goyal Avatar asked Aug 15 '26 20:08

Deepanshu Goyal


1 Answers

I don't think that you can change the behaviour of the Chrome app, if they want to save battery in the background and stop the javascript, you won't reactivate it.

There are maybe some other ways to get it working.

  1. Tell your users that they should use Firefox or Opera on their mobile device.

  2. All apps are allowed to play or stream music in the background, so you could make or use an app for your task.

  3. Maybe you can use the default music player app on android. Open a playlist of streams using the app. (I don't know if this is possible, because I have no android device.)

I know that is not exactly what you want, but a maybe a way to get it working.

like image 66
KIMB-technologies Avatar answered Aug 18 '26 10:08

KIMB-technologies