jofr / capacitor-media-session

Capacitor plugin for media notifications and platform media keys as well as background audio playback.
GNU General Public License v3.0
36 stars 27 forks source link

Audio cannot be controlled using headset controls #17

Closed simonoskamagdalena closed 8 months ago

simonoskamagdalena commented 1 year ago

Hi, I am working on an Ionic application using Angular and Capacitor 5.3.0 and it seems like I cannot play/pause the audio when my phone is connected to bluetooth headset. Can you please check? Edit: I am using Redmi buds 3 lite, Android version 13, Ionic 7 and Capacitor 5. Also it is worth mentioning, that the headset controls work well with Spotify

simonoskamagdalena commented 12 months ago

Hi, any progress on this issue or does anyone have any suggestion on how to solve this problem? The controls from bluetooth devices do not work.

mikmikmik commented 9 months ago

Same here, only works on iOs.

mikmikmik commented 9 months ago

I managed to make it work for Android and iOs by changing in MediaSessionService.java ACTION_PLAY_PAUSE to ACTION_PLAY and ACTION_PAUSE accordingly for both play and pause playbackStateActions and notificationActions Are there some devices using the play/pause instead? Maybe register both like (PlaybackStateCompat.ACTION_PLAY_PAUSE | PlaybackStateCompat.ACTION_PAUSE) and (PlaybackStateCompat.ACTION_PLAY_PAUSE | PlaybackStateCompat.ACTION_PLAY)

simonoskamagdalena commented 9 months ago

Thank you @mikmikmik, you are a life saver. This solution worked for me