Ionic 4 Radio Streaming App with icecast2 Background Mode and Audio() web function

279 views Asked by At

Actually, I have an implementation with ionic 4 with the Background Mode plugin and the Audio() HTML5 function for the audio. (The audio source is an icecast 2.4.4 server with aacplus).

Before I try with Cordova Media plugin but icecast is not supported.

I have some problems:

When the mobile phone is not connected to the battery (or charging) the audio after 5 minutes stops when the phone is blocked, not if isn't connected(charging) but you are using the app.

My code is like:

 this.global.streamingAndroid = new Audio();
 this.global.streamingAndroid.controls = true;
 this.global.streamingAndroid.src = this.streamingUrl+'&vapp='+Math.random();
 this.global.streamingAndroid.load();
 this.global.streamingAndroid.play();

 ...


 this.backgroundMode.enable();
 this.backgroundMode.setDefaults({ silent: true });
 // this.backgroundMode.disableWebViewOptimizations();
 // this.backgroundMode.disableBatteryOptimizations();
 this.backgroundMode.on('activate').subscribe(() => {
      this.backgroundMode.disableWebViewOptimizations();
      this.backgroundMode.disableBatteryOptimizations();
 });
0

There are 0 answers