Ionic 7 and Capacitor 5 controlling audio through bluetooth headset and glitchy audio

I am making radio application using API to stream the audio and I have two problems:

  1. play/pause through bluetooth headset controls is not working. I am using media-session plugin, however something is missing.

  2. on some devices the audio is glitchy when the phone is locked, however when the screen is active the audio is ok. On some phones the audio is glitchy if my radio application is in the background and the user is using WhatsApp or other application while the radio is playing. On some devices this issue does not exist.

I am using Ionic 7 with Angular 16 and Capacitor 5. In AndroidManifest.xml I have the following permissions:

Does anyone have an idea/suggestion on how to solve these issues?

It looks like there is an open issue about Bluetooth controls here - Audio cannot be controlled using headset controls · Issue #17 · jofr/capacitor-media-session · GitHub

Here’s an issue with some possible solutions with background play - Background Mode Not Working · Issue #11 · jofr/capacitor-media-session · GitHub

I personally ended up creating my own local audio plugin because no existing plugin worked as needed. Mine has some quirks too but at least I am familiar with it and can fix it (just haven’t had the time). I wish there was a solid audio plugin for Capacitor!