media icon indicating copy to clipboard operation
media copied to clipboard

How to customize media button handlers ?

Open muhammadalkady opened this issue 2 years ago • 5 comments

I can't customize media button handlers. I should be able to override onMediaButtonEvent, also onStartCommand called with intent with null action when pressing on media button from [bluetooth headset]. It is called after the media is played or paused so there is no chance to customize buttons behavior.

muhammadalkady avatar Dec 01 '21 09:12 muhammadalkady

It's very unclear what this issue is referring to, in part due to a lack of context. Please could you fully explain your use case (e.g., what customisation are you trying to make).

ojw28 avatar Dec 02 '21 14:12 ojw28

I am trying to make the media always rebuffer when the user hits the play button as the stream is alive. In MediaLibraryService when onStartCommand is called I can extract the keyCode like this val keyCode = intent?.extras?.getParcelable<KeyEvent>(EXTRA_KEY_EVENT) so I can handle the KEYCODE_MEDIA_PLAY and it is working when receiving click from media notification, but when receiving the click from Bluetooth headset the player resumes the media after that onStartCommand is called with null extras val keyCode = intent?.extras?.getParcelable<KeyEvent>(EXTRA_KEY_EVENT) // keyCode = null. Here in MediaSessionCompat I can customize the media handlers. So how to do this is in androidx.media3.session.MediaSession Thanks.

muhammadalkady avatar Dec 03 '21 06:12 muhammadalkady

Hey @muhammadalkady. We need more information to resolve this issue but there hasn't been an update in 14 weekdays. I'm marking the issue as stale and if there are no new updates in the next 7 days I will close it automatically.

If you have more information that will help us get to the bottom of this, just add a comment!

google-oss-bot avatar Dec 23 '21 02:12 google-oss-bot

Any updates on this issue?

muhammadalkady avatar Dec 28 '21 13:12 muhammadalkady

AndroidX Media3 is still in alpha. Your feedback is valuable to us. There are some changes coming in regarding how media key events are handled. I will update this issue when this is the case to make you aware and that we know whether your case is covered.

marcbaechinger avatar Jan 11 '22 13:01 marcbaechinger