'Ionic play HLS stream in background with Media Controls on Android

I’m building an app in Ionic 6 which needs to play an HLS stream. When the user hides the app (to the background) the stream needs to continue playing. Preferably with the possibility of using the media controls.

For iOS, this isn’t a problem. I can just use the HTML5 audio player and it just works perfect. For Android this won’t work. When I hide the app, the music stops playing (even with backgroundMode enabled).

Does anyone know how to solve this on Android?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source