First install:
- https://github.com/wizpanda/cordova-plugin-nativeaudio
- https://github.com/katzer/cordova-plugin-background-mode
Then we need to use backgroundMode event listening for activate to resume the audio whenever the app goes to background, you will notice a tiny micropause, but that’s it!
this.nativeAudio.play("audio1"),() => console.log('audio1 is done playing'));
this.backgroundMode.enable();
this.backgroundMode.on("activate").subscribe(()=>{
this.nativeAudio.play("audio1");
});