trunk-player icon indicating copy to clipboard operation
trunk-player copied to clipboard

Mobile Phone Browsers doesn't keep playing when screen asleep/timesout

Open s3m1s0n1c opened this issue 4 years ago • 9 comments

Hey Guys,

Looks like trunk-player doesn't keep playing on mobiles when the screen times out or goes to sleep... It plays the call then stops and doesn't keep playing the next call..

Is there an easy way to fix this as my users would like to have it in the BG so they can hear whats going on.

Thanks Sonic

s3m1s0n1c avatar Dec 28 '20 00:12 s3m1s0n1c

After doing some tests..

Safari is the only one at the moment..

Doing more tests on other browsers

s3m1s0n1c avatar Dec 28 '20 00:12 s3m1s0n1c

Android as a whole will do that sort of behavior. Once the screen timeout happens, Android will begin to shush/put-to-sleep apps that use the most CPU time thus most battery usage.

The only real way around that issue is by using an app (ScannerRadio, VLC, MXPlayer), Tasker or some other sort of keep-alive application, or having users go to the developer settings on android to force the phone screen to always remain on while charging.

bctrainers avatar Dec 28 '20 01:12 bctrainers

So it seems its not just mobiles.. If I open Chrome on my Mac and not actively on the table it stops playing after a while.. Its doing the same on mobile as well..

s3m1s0n1c avatar Dec 28 '20 10:12 s3m1s0n1c

Correct. Background tabs are throttled on Chrome (and most Chromium-based browsers) - timer dependent.

There used to be an option under chrome://flags to override the background tab CPU limiter. It would appear it was changed in recent years to: chrome://flags/#intensive-wake-up-throttling

bctrainers avatar Dec 28 '20 11:12 bctrainers

Yeah the browser have locked down a lot of javascript activities when the page is not in focus. I'm sure there are some workarounds but probably each browser has their own. The mplayer that was added 4 years ago (which is an eternity in browser development) a newer javascipt player might help, but that code a spaghetti mess. I don't see a quick fix for this one, but does need some love.

dreinhold avatar Dec 28 '20 18:12 dreinhold

Mmm that's a bit shitty.. Oh well... it is what it is..

Thanks for your comments 👍

s3m1s0n1c avatar Jan 03 '21 06:01 s3m1s0n1c

I'll leave this one open..

Maybe someone might want the challenge to re-visit mplayer

s3m1s0n1c avatar Aug 16 '21 08:08 s3m1s0n1c

This is still an issue. I noticed that audio from TR/Trunk-Player stops whenever the browser is minimized on iOS/iPad OS 15 (regardless of whether I'm using Safari, Chrome, or Firefox).

However, I did discover that the scanner app NoraSector has figured out a way to keep the audio running in mobile web browsers even when the browser is not in focus. Not sure if it's because it's using WebRTC or something else.

bhall7 avatar Jan 27 '22 18:01 bhall7

@bhall7 this seems to be an issue with the Channels implementation of Websockets and websockets in general. I am working on a complete re-write to Trunk-Player and it will be using sockets.io... unfortunately for now there is not a great solution

MaxwellDPS avatar Jan 30 '22 18:01 MaxwellDPS