mirror of
https://github.com/androidx/media.git
synced 2025-04-30 06:46:50 +08:00
[ui-compose] Fix PlayerSurface's use of Player
The new `currentPlayer` was only used to check the available command. It should also be used for setting and clearing the Surface. The PlayerSurface was still behaving correctly, perhaps due to the lambda being reevaluated with the new player (since `currentPlayer` is of type MutableState). Which meant it was also using the latest `player` that `PlayerSurface` was recomposed with (in the argument), rather than holding onto the original object. PiperOrigin-RevId: 713264041
This commit is contained in:
parent
48e3eaa623
commit
79d41aac7e
@ -51,11 +51,11 @@ fun PlayerSurface(player: Player, surfaceType: @SurfaceType Int, modifier: Modif
|
||||
val currentPlayer by rememberUpdatedState(player)
|
||||
val onSurfaceCreated: (Surface) -> Unit = { surface ->
|
||||
if (currentPlayer.isCommandAvailable(Player.COMMAND_SET_VIDEO_SURFACE))
|
||||
player.setVideoSurface(surface)
|
||||
currentPlayer.setVideoSurface(surface)
|
||||
}
|
||||
val onSurfaceDestroyed: () -> Unit = {
|
||||
if (currentPlayer.isCommandAvailable(Player.COMMAND_SET_VIDEO_SURFACE))
|
||||
player.clearVideoSurface()
|
||||
currentPlayer.clearVideoSurface()
|
||||
}
|
||||
val onSurfaceInitialized: AndroidExternalSurfaceScope.() -> Unit = {
|
||||
onSurface { surface, _, _ ->
|
||||
|
Loading…
x
Reference in New Issue
Block a user