Shivam Dhuria
03/14/2023, 7:32 PMAndroidView
. However they seem to not respect the zIndex
in a Box
Layout. The newest composable associated with lowest zIndex always renders at the top even though it should be at the bottom. Here’s the code. 🧵var movieList = remember { mutableStateListOf(mock4.get(0), mock4.get(1), mock4.get(2), mock4.get(3), mock4.get(4), mock4.get(5),) }
fun onClick() {
movieList.removeLast()
}
Column {
// I only pass the last two elements from the above list to be rendered
ContentList(movieList.takeLast(2))
// Clicking the button removes the last element from the list
Button( onClick = ::onClick) {
Text(text = "remove last")
}
}
@Composable
private fun ContentList(movieList: List<GameEntry>) {
Box {
LogCompositions(tag = "", msg = "ContentList Box ")
movieList.forEachIndexed { index, movie ->
// I do not want to rerender composables based on the id field, which is unique
key(movie.id) {
ContentView(
Modifier.fillMaxWidth(), movie, index == 1
)
}
}
}
}
@Composable
private fun ContentView(modifier: Modifier, movie: GameEntry, isActive: Boolean) {
Card(
modifier
.height(400.dp)
.padding(horizontal = 30.dp)
) {
MediaPlayer(videoUri = movie.media?.url.toString(), id = movie.id, isActive)
// The below text Composable works as expected but the ^^ Media player does not
Text(
text = movie.id.toString(),
textAlign = TextAlign.Center,
modifier = Modifier.fillMaxWidth()
)
}
DisposableEffect(Unit) {
onDispose {
Log.e("", "Disposed Card id -> ${movie.id}")
}
}
}
@Composable
fun MediaPlayer(videoUri: String, id: Long, isActive:Boolean) {
val exoPlayer = remember {... }
DisposableEffect(
AndroidView(
factory = {
PlayerView(context).apply {
hideController()
useController = false
resizeMode = AspectRatioFrameLayout.RESIZE_MODE_ZOOM
player = exoPlayer
layoutParams = FrameLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT
)
}
},
)
) {
onDispose {
exoPlayer.release()
}
}
}
[4, 5].
At first video on top [5]
is visible. On pressing the button , this video is removed from movieList and last 2 videos [3,4]
are passed to ContentList . Now instead of seeing video [4]
on top, somehow video [3]
is visible at the top of Box. I have verified that the rendering sequence is correct, yet somehow i see preview for video [3]
on topChris Fillmore
03/14/2023, 10:03 PMShivam Dhuria
03/15/2023, 12:32 PMsetZOrderMediaOverlay
and setZOrderOnTop
with no success 😞 .
Here’s the repo,.Chris Fillmore
03/15/2023, 12:38 PMShivam Dhuria
03/15/2023, 12:40 PMChris Fillmore
03/15/2023, 12:45 PMShivam Dhuria
03/15/2023, 12:50 PM