google / google/ExoPlayer

Make StyledPlayerView aware of SurfaceControl

Open
#10,226 0 comments 4 reactions 1 assignee Claimed by @marcbaechinger View on GitHub
enhancement
Dominant language
Java
Stars
21.9k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

### Use case description
Starting from API 29, we have the nice [`SurfaceControl`](https://github.com/google/ExoPlayer/tree/r2.16.1/demos/surface) to help redirecting video output from ExoPlayer between different views in a better way. It works great with surface views, but many of us are used to working with the `StyledPlayerView`, and it currently has no `SurfaceControl` awareness whatsoever.

I would love to be able to take advantage of both `SurfaceControl`'s seamless transitions between different surfaces, and `StyledPlayerView` built-in capabilities like resize mode at the same time, and I think that's a valid use case the library could have proper support.

### Proposed solution
I'm not sure what's the best solution to make `StyledPlayerView` aware of `SurfaceControl`, but what I currently have in mind would be a new method on `StyledPlayerView` to connect the player. But differently from `setPlayer()` and `switchTargetView()`, it wouldn't expect a player and it would receive a `SurfaceControl` instead (which would be the one attached to the player). Something like this:

```kotlin
val surfaceControl = SurfaceControl.Builder().setName("test").build()
val videoSurface = Surface(surfaceControl)

val player = // initialize player
player.setVideoSurface(videoSurface)

styledPlayerView.reparentFrom(videoSurface)
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.