androidx / media

Jetpack Media3 support libraries for media use cases, including ExoPlayer, an extensible media player for Android
https://developer.android.com/media/media3
Apache License 2.0
1.66k stars 392 forks source link

How to customize media button handlers ? #12

Open muhammadalkady opened 2 years ago

muhammadalkady commented 2 years ago

I can't customize media button handlers. I should be able to override onMediaButtonEvent, also onStartCommandcalled with intent with nullaction 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.

ojw28 commented 2 years ago

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).

muhammadalkady commented 2 years ago

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 onStartCommandis called with nullextras val keyCode = intent?.extras?.getParcelable<KeyEvent>(EXTRA_KEY_EVENT) // keyCode = null. Here in MediaSessionCompatI can customize the media handlers. So how to do this is inandroidx.media3.session.MediaSession Thanks.

google-oss-bot commented 2 years ago

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!

muhammadalkady commented 2 years ago

Any updates on this issue?

marcbaechinger commented 2 years ago

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.