rememberVideoPlayerState

fun rememberVideoPlayerState(audioMode: AudioMode = AudioMode(), cacheConfig: CacheConfig = CacheConfig()): VideoPlayerState

Creates and remembers a VideoPlayerState, automatically releasing all player resources when the composable leaves the composition.

This is the recommended way to obtain a VideoPlayerState. You do not need to call VideoPlayerState.dispose yourself — cleanup is handled via DisposableEffect.

@Composable
fun MyPlayer() {
val playerState = rememberVideoPlayerState()
// use playerState — resources are freed automatically on removal
}

Return

The remembered instance of VideoPlayerState.

Parameters

audioMode

The audio mode configuration for the player.

cacheConfig

Optional caching configuration. When CacheConfig.enabled is true, video data fetched via VideoPlayerState.openUri is cached on disk so that subsequent plays of the same URI avoid a full re-download. Currently only effective on Android and iOS.