Search code examples
androidcordovaphonegap

How can avoid audio streaming to stop after 5 minuter?


I made an PhoneGap app that contains an audio player with start / stop. Player stream audio from shoutcast streaming.

It works perfectly on iOS and it also works on Android, even if the app goes is in background and the phone is lock

but after around 5 minutes audio stops

I tested on OnePlus 6t and has been tested on a Sony Xperia with same results

JS code

myaudio = new Audio(streamurl);
myaudio.id = 'playerMyAdio';
myaudio.play();

Solution

  • All apps without background tasks will get snoozed on Android after a while. You need to set up a background task so your app doesn't go into snooze.

    Maybe you can try this plugin https://github.com/katzer/cordova-plugin-background-mode