package com.hermes.app.core.media

import androidx.compose.runtime.Composable
import androidx.compose.runtime.DisposableEffect
import androidx.compose.ui.Modifier
import androidx.compose.ui.viewinterop.AndroidView
import androidx.media3.ui.PlayerView

@Composable
fun HermesVideoPlayerView(
    coordinator: HermesPlayerCoordinator,
    modifier: Modifier = Modifier,
) {
    DisposableEffect(coordinator.player) {
        onDispose {
            // Player lifecycle is controlled by the coordinator.
        }
    }

    AndroidView(
        modifier = modifier,
        factory = { context ->
            PlayerView(context).apply {
                useController = false
                player = coordinator.player
            }
        },
        update = { view -> view.player = coordinator.player },
    )
}
