reactormonk
09/19/2023, 5:52 PMval context = LocalContext.current
val playerView = remember {
val layout = LayoutInflater.from(context).inflate(R.layout.video_player_auto, null, false)
val playerView = layout.findViewById(R.id.playerView) as PlayerView
playerView.apply {
player = exoPlayer
}
}
Log.d("VideoPlayer", "View: $playerView")
AndroidView(
{ playerView },
Modifier
.fillMaxHeight()
.background(Color.Black)
)
jw
09/19/2023, 5:54 PMAndroidView
? Are you trying to retain it across changes to the Context
?reactormonk
09/19/2023, 5:55 PM@Composable
fun VideoPlayer(
exoPlayer: ExoPlayer,
) {
KeepScreenOn()
AndroidView(
{
val layout = LayoutInflater.from(it).inflate(R.layout.video_player_auto, null, false)
val playerView = layout.findViewById(R.id.playerView) as PlayerView
playerView.apply {
player = exoPlayer
Log.d("VideoPlayer", "view: $this")
}
},
Modifier
.fillMaxHeight()
.background(Color.Black),
{
it.player = exoPlayer
}
)
}
exoPlayer
instance 🤔Vlad
09/20/2023, 8:11 AMjw
09/20/2023, 3:36 PM