androidx / androidx/media

Media3 MediaController does not accept COMMAND_SET_VIDEO_SURFACE after ending a Cast session

Open
#764 0 comments 1 reaction 1 assignee View on GitHub

@tianyif is already working on this.

Since Oct 26, 2023.

bug needs triage
Dominant language
Java
Stars
3k
Forks
955
Avg merge
12d 14h
Merged PRs (30d)
2

Description

Version

Media3 1.1.1

More version details

I have implemented a MediaService implementation with a ExoPlayer/CastPlayer hand-off using a ReplaceableForwardingPlayer following the pattern of the UAmp demo application here.

This is working well for handing off the media playback from ExoPlayer to Cast. It also works well when ending the Cast session and returning the playback to ExoPlayer for audio only. When using if for video, however, the ExoPlayer VideoView does not show any video content, although the player controls work, and the audio plays.

I did some debugging and found that after a Cast session, the MediaController that is returned from from the service connection returns false when calling MediaController.isCommandAvailable(COMMAND_SET_VIDEO_SURFACE) which prevents the VideoView from setting its Surface for playback. I also found that the isCommandAvailable(COMMAND_SET_VIDEO_SURFACE) never gets passed down to my ReplaceableForwardingPlayer implementation. So it seems to me that this is a bug, since some state is getting changed when switching to my CastPlayer that does not get reset when switching back to my ExoPlayer.

I am currently working around the problem by just killing the entire media session at the end of the Cast session, and starting a new session. But it seems like I should not need to do this.

Also, I am curious... what is the intended behavior of MediaSession.setPlayer(player: Player)? It seems to me that this method should make a custom ReplaceableForwardingPlayer not necessary. But in attempting to do this, I've had no luck getting it working. Instead the entire media session just seems to end when I switch players in this way. If this is indeed the intention, can you point me to any sample code which does this?

Thank you!

Devices that reproduce the issue

Pixel 7 running Android 14
(Issue is not device-specific)

Devices that do not reproduce the issue

No response

Reproducible in the demo app?

Not tested

Reproduction steps

I didn't find any examples of ExoPlayer/CastPlayer hand-off in the demo app. But you can reproduce the issue by modifying the media3 branch of the uamp demo application by adding an ExoPlayer VideoView and replacing some media with a video url.

Expected result

When switching from CastPlayer to ExoPlayer, the MediaController should accept COMMAND_SET_VIDEO_SURFACE commands.

Actual result

MediaController.isCommandAvailable(COMMAND_SET_VIDEO_SURFACE) returns false

Media

I have been using HLS video streams whose URLs I cannot share. However, there are many free HLS streams listed here: https://github.com/bengarney/list-of-streams

Bug Report
  • You will email the zip file produced by adb bugreport to android-media-github@google.com after filing this issue.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.