rememberKitePlayer

fun rememberKitePlayer(config: PlayerConfig = PlayerConfig()): KitePlayer

A player that belongs to this place in the composition: built with KitePlayer(config) the first time, and closed when this call leaves the composition.

val player = rememberKitePlayer()
KitePlayerVideo(player, Modifier.fillMaxSize())
LaunchedEffect(url) {
player.open(MediaItem(url))
player.play()
}

config is read once. A later, different config does not rebuild the player, because a rebuild would stop what is playing. On Android, a configuration change such as a rotation recreates the activity, so its composition leaves and this player closes. Hold the player in a ViewModel when it must outlive that.

Throws

as KitePlayer(config) does, when the platform has no default stack.