I am using Media Plugin and MusicControl to stream music in my ionic app.
The music plays fine in the background but when the audio is interrupted by notifications from other apps, I couldn’t able to resume the music. This issue is only for IOS. In android, it works as expected.
In android, the media plugin pause/stop callback is triggered when there is an interruption. I don’t see these events are triggered for ios. How to get hold of the pause/stop event if there is an interruption for IOS? I couldn’t able to find anything from the forums as well.
const onStatusUpdate = (status) => {
console.log("media plugin status",status);
switch (status){
case this.media.MEDIA_STARTING:
console.log("Media starting..");
break;
case this.media.MEDIA_RUNNING:
console.log("Media running..");
break;
case this.media.MEDIA_STOPPED:
console.log("Media stopped..");
Player.isPlaying=false;
break;
case this.media.MEDIA_PAUSED:
console.log("Media paused..");
Player.isPlaying=false;
break;
default:
console.log("Unhandled media status!!");
break;
}
};
Player.stream = this.media.create(Player.streamUrl,onStatusUpdate,onSuccess,onError);