cordova-plugin-background-mode icon indicating copy to clipboard operation
cordova-plugin-background-mode copied to clipboard

Audio stream stops when background mode is enabled

Open ghost opened this issue 5 years ago • 3 comments

My problem is that my html 5 audio stream stops after approx 10 minutes when the app is running in the background. To tackle this problem ive installed this plugin. But if i read the docs right than i need to enable the background mode. So ive added

document.addEventListener("deviceready", onDeviceReady, false); function onDeviceReady() { window.open = cordova.InAppBrowser.open; cordova.plugins.backgroundMode.setEnabled(true); }

but now when i tap the play button my stream blibs and stops. when i remove the cordova.plugins.backgroundMode.setEnabled(true); sentence, the stream works. how can i activate background mode and still use a stream?

here is my html

<audio id="yourAudio" preload='none'><source src='https://media1.hostin.cc/punt24.mp3' type='audio/wav' /></audio>

and the js

var method = 'pause'; var yourAudio = document.getElementById('yourAudio'); if(this.$root.playStream){ this.$root.playStream = false; method = 'pause'; }else{ this.$root.playStream = true; method = 'play'; } yourAudio[method]();

my plugins: <plugin name="cordova-plugin-remotecmd-playinginfo" spec="0.4.5" /><plugin name="cordova-plugin-background-mode" spec="0.7.3" />

ghost avatar Sep 21 '20 10:09 ghost

Same here, Can I hide the notification without stopping the application after 20 minutes for multimedia applications using exoplayer?

rcasunshare avatar Sep 21 '20 19:09 rcasunshare

I had this issue recently and had to mesh together a few different background mode plugins to make it all work. Here's my repo with the cordova-plugin-background-mode functining on iOS 13 https://github.com/thompsd3/cordova-plugin-background-mode

thompsd3 avatar Sep 27 '20 19:09 thompsd3

You must add this line to AndroidManifest.xml:

<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>

felinuxsas avatar Dec 04 '20 02:12 felinuxsas