Skip to main content

BBPlayerState

class BBPlayerState

Reactive state holder that bridges [BBNativePlayerViewDelegate] callbacks to Compose state.

Observe any property directly in a composable to trigger recomposition when it changes. Use the imperative control methods ([play], [pause], [seek], etc.) to control the player.

Create with [rememberBBPlayerState].

Properties

currentTime

val currentTime: Double

Estimated current playback position in seconds.

Historically used by Channel for resume-position bookkeeping; Continue Watching is now SDK-internal — set [BBPlayerOptions.continueWatching] = true to let the SDK persist and auto-resume on load, and call [com.bluebillywig.bbnativeplayersdk.PlayHistoryManager.lastKnownPosition] for "% watched" badges that don't have a live player.

isCasting

val isCasting: Boolean

Whether the player is currently casting to a Chromecast device.

Functions

play

fun play()

Start or resume playback.

pause

fun pause()

Pause playback.

seek

fun seek(seconds: Double)

Seek to the given absolute position in seconds.

seekRelative

fun seekRelative(offsetInSeconds: Double)

Seek relative to the current position (e.g. +10.0 or -10.0 seconds).

setVolume

fun setVolume(volume: Double)

Set the playback volume (0.0 to 1.0).

setMuted

fun setMuted(muted: Boolean)

Set the muted state.

enterFullScreen

fun enterFullScreen()

Enter fullscreen mode. Requires the hosting Activity to extend AppCompatActivity.

exitFullScreen

fun exitFullScreen()

Exit fullscreen mode.

loadWithContentIdAndType

fun loadWithContentIdAndType(
contentId: String,
contentType: String,
autoPlay: Boolean = true,
context: Map<String, Any?>? = null,
)

Load content by ID and type. Routes to the correct SDK method based on [contentType]. Matches RN's loadWithContentIdAndType.

loadClip

fun loadClip(clipId: String, autoPlay: Boolean = true, seekTo: Number? = null)

Load a clip by ID. Convenience for [loadWithContentIdAndType] with type "mediaclip". For playlist context (auto-advance), use [loadWithContentIdAndType] instead.

unload

fun unload()

Unload content without destroying the player (for reuse).

destroy

fun destroy()

Destroy the player and release resources.

isMuted

fun isMuted() : Boolean

Get the muted state.

endCastSession

fun endCastSession()

End the current Cast session and stop playback on the Cast device. Uses reflection: Cast SDK is an implementation dep of the core module, not transitive.

showCastPicker

fun showCastPicker()

Show the Chromecast device picker by programmatically clicking the cast button in the player UI.

clickNativeControl

fun clickNativeControl(controlName: String) : Boolean

Programmatically click any control button in the player by its resource id name (e.g. "exo_settings_icon", "exo_subtitles_icon", "exo_play_pause", "exo_fullscreen_icon"). Used by TV shells to surface the player's native overlay menus from remote-key handlers.

The full controls bar is shown first via [BBNativePlayerView.showController] so the click lands on a laid-out view (otherwise a hidden controls bar would receive the click but the user would see nothing).

Returns: true if the control was found and clicked, false if the player isn't attached, the resource id doesn't resolve, or the view isn't in the hierarchy.

rememberBBPlayerState

fun rememberBBPlayerState() : BBPlayerState

Remember a [BBPlayerState] instance scoped to the current composition.