mirror of
https://github.com/androidx/media.git
synced 2025-04-30 06:46:50 +08:00
[ui-compose] Check Player
commands in PlayerSurface
actions
Setting and destroying the Surface should only happen if the `Player` has the required command PiperOrigin-RevId: 705488781
This commit is contained in:
parent
4997ea82fa
commit
77a215f39c
@ -44,8 +44,12 @@ import androidx.media3.common.util.UnstableApi
|
||||
@UnstableApi
|
||||
@Composable
|
||||
fun PlayerSurface(player: Player, surfaceType: @SurfaceType Int, modifier: Modifier = Modifier) {
|
||||
val onSurfaceCreated: (Surface) -> Unit = { surface -> player.setVideoSurface(surface) }
|
||||
val onSurfaceDestroyed: () -> Unit = { player.setVideoSurface(null) }
|
||||
val onSurfaceCreated: (Surface) -> Unit = { surface ->
|
||||
if (player.isCommandAvailable(Player.COMMAND_SET_VIDEO_SURFACE)) player.setVideoSurface(surface)
|
||||
}
|
||||
val onSurfaceDestroyed: () -> Unit = {
|
||||
if (player.isCommandAvailable(Player.COMMAND_SET_VIDEO_SURFACE)) player.clearVideoSurface()
|
||||
}
|
||||
val onSurfaceInitialized: AndroidExternalSurfaceScope.() -> Unit = {
|
||||
onSurface { surface, _, _ ->
|
||||
onSurfaceCreated(surface)
|
||||
|
Loading…
x
Reference in New Issue
Block a user