So I got this line of code:
fun LiveTrainingScreen(viewModel: LiveTrainingViewModel = viewModel()) {
Column(modifier = Modifier.padding(PaddingStatic.Small).zIndex(2f)) {
//Large Video Display
//here
var videoLink = remember { mutableStateOf(LiveTrainingViewModel.cockPitRight) }
val exoPlayerCamera1 = viewModel.GetCameraPlayer(videoLink.value)
DisposableEffect(
AndroidView(
modifier = Modifier
.weight(1f)
.fillMaxSize()
.clip(RoundedCornerShape(RoundedSizeStatic.Medium))
.clickable { videoLink = mutableStateOf(LiveTrainingViewModel.mapCamera) },
factory = {
PlayerView(viewModel.context).apply {
player = exoPlayerCamera1
useController = false
resizeMode = AspectRatioFrameLayout.RESIZE_MODE_FILL
FrameLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT
)
}
}
)
) {
onDispose {
exoPlayerCamera1.release()
}
}
}
}
But when I click on the video element, the code is not being re-executed when I change the mediaItem Uri, because the video frame keeps displaying the same video.
And I don't understand what I am doing wrong.
Through mutablestate manual string change, re-execute code to change video display from the internet
So for some reason exoplayer doesn't update when a State update is done.
So I tried to set the MediaItem for the second time which worked fine
.clickable { exoPlayerCamera1.setMediaItem(MediaItem.fromUri(LiveTrainingViewModel.mapCamera))
},