Make StyledPlayerView aware of SurfaceControl
- 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
Assessment
This issue has not been assessed yet.