Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Android Media Session #3080

Closed

Conversation

phillip-kic
Copy link

Media Session

This adds 2 props, enableMediaSession and mediaSessionMetadata. With these the video can create an Android Media Session and provide it with metadata.
Simply adding a media session like this allows the video to be controlled and respond to a number of external controls. Some examples include:

  • Hardware buttons (eg. Play/Pause on a Google TV Remote)
  • Google Assistant (eg. saying "Play"/"Pause"/"Stop")
  • Other devices

Testing

Because this opens the door to many controls there are number of ways it can be tested. I've been testing 2 different ways:

Trigger pause/play event through adb

You can mimic the event of pressing a pause/play button through adb.
adb shell input keyevent 126
Key 126 is PLAY, 127 is PAUSE, 85 is PLAY/PAUSE. See more event codes in the Android docs here

Google Assistant

You can run on a device that has Google Assistant, then test instructions such as "Play"/"Pause"/"What's Playing?"
Pretty sure you can also use Google Assistant in emulators

@freeboub
Copy link
Collaborator

freeboub commented Apr 5, 2023

This Pr looks good thank you. but unfortunately, I didn't plan to make evolution on 5.2 branch.
Is it possible to move this PR to master branch ?

@freeboub freeboub added the 5.2 label Apr 5, 2023
@phillip-kic
Copy link
Author

@freeboub I avoided using the master branch as we haven't moved over to v6 while it's in alpha. If that gets a stable release within the next few months then I'm happy to adapt this over there with some other features too

@@ -314,6 +316,26 @@ public void setControls(final ReactExoplayerView videoView, final boolean contro
videoView.setControls(controls);
}

@ReactProp(name = PROP_ENABLE_MEDIA_SESSION, defaultBoolean = false)
public void setEnabledMediaSession(final ReactExoplayerView videoView, final boolean enableMediaSession) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure, but wanted to double check just in case. Is there a spelling error here?

Suggested change
public void setEnabledMediaSession(final ReactExoplayerView videoView, final boolean enableMediaSession) {
public void setEnableMediaSession(final ReactExoplayerView videoView, final boolean enableMediaSession) {

Copy link

@s-rschie s-rschie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like there may be a spelling error?

@KrzysztofMoch
Copy link
Member

This is now implemented via #3723 - if I missed something please let me know

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants