rememberPlayer

fun rememberPlayer(config: THEOplayerConfig? = null): Player

Creates and remembers a Player.

Parameters

config

the player configuration


fun rememberPlayer(theoplayerView: THEOplayerView): Player

Create a Player wrapping an existing THEOplayerView.

The THEOplayerView should be remembered so it's not re-created on every recomposition.

Example usage:

val context = LocalContext.current
val theoplayerView = remember(context) {
val config = THEOplayerConfig.Builder().build()
THEOplayerView(context, config)
}
val player = rememberPlayer(theoplayerView)

This couples the lifecycle of the given THEOplayerView to the current activity. That is, it automatically calls THEOplayerView.onPause and THEOplayerView.onResume whenever the current activity is paused or resumed.

The THEOplayerView is not automatically destroyed when the composition is disposed. If you need this, use a DisposableEffect:

val player = rememberPlayer(theoplayerView)
DisposableEffect(theoplayerView) {
onDispose {
theoplayerView.onDestroy()
}
}

Parameters

theoplayerView

the existing THEOplayer view