-
Notifications
You must be signed in to change notification settings - Fork 57
Open
Description
Description:
I wanna manually set showControls based on my logic in real rime.
Example:
@Composable
private fun RemoteVideo(
modifier: Modifier,
showControls: Boolean,
url: String,
) {
val playerHost = rememberPlayerHost(url)
val playerConfig = rememberPlayerConfig(showControls)
playerConfig.showControls = showControls // user can manually show/hide controls
playerHost.onError = { err ->
// intent
}
VideoPlayerComposable(
modifier = modifier
.clip(RoundedCornerShape(DesignSystem.radius.x16)),
playerHost = playerHost,
playerConfig = playerConfig,
)
}Cause:
We can't update *.showControls = !*.showControls because it keeps in remember in VideoPlayerComposable -> VideoPlayerWithControl.
@Composable
internal fun VideoPlayerWithControl(
modifier: Modifier,
playerHost: MediaPlayerHost,
playerConfig: VideoPlayerConfig
) {
var isScreenLocked by remember { mutableStateOf(false) }
<--- here we keep value from config in remember and it survive recompositions --->
var showControls by remember { mutableStateOf(playerConfig.showControls) } // State for showing/hiding controls
var showVolumeControl by remember { mutableStateOf(false) }
var volumeDragAmount by remember { mutableStateOf(0f) }
var initialVolume by remember { mutableStateOf(0f) }
...How to fix?
- Consider not to wrap showControls and others into the
remember { mutableStateOf(playerConfig.showControls) } - Use
remember(playerConfig.showControls) { mutableStateOf(playerConfig.showControls) }but this doesn't have a lot of sense, coz it won't decrease recompositions from my understanding. So, better just removerememberand allow code recompose every time when VideoPlayerConfig.showControls changed.
I wanted to contribute, submit PR. But didn't find where is library. I see the demo app only in the repo.
Anyway, thanks for this library, appreciate a lot!
Metadata
Metadata
Assignees
Labels
No labels