Skip to main content

com.bluebillywig.bbnativeplayersdk.compose — Functions

BBNativePlayer

fun BBNativePlayer(
jsonUrl: String,
modifier: Modifier = Modifier,
options: BBPlayerOptions = BBPlayerOptions(),
state: BBPlayerState = rememberBBPlayerState(),
onReady: (() -> Unit)? = null,
onError: ((String?) -> Unit)? = null,
onEnded: (() -> Unit)? = null,
)

A Jetpack Compose wrapper for [BBNativePlayerView][com.bluebillywig.bbnativeplayersdk.BBNativePlayerView].

Embeds the Blue Billywig native video player in a Compose layout using [AndroidView]. Observe the player's reactive state via [state] and control it with [BBPlayerState] methods.

Example

@Composable
fun VideoScreen(clipUrl: String) {
val playerState = rememberBBPlayerState()

BBNativePlayer(
jsonUrl = clipUrl,
modifier = Modifier.fillMaxWidth().aspectRatio(16f / 9f),
state = playerState,
options = BBPlayerOptions(autoPlay = false, noChromeCast = true),
)

Button(onClick = {
if (playerState.isPlaying) playerState.pause() else playerState.play()
}) {
Text(if (playerState.isPlaying) "Pause" else "Play")
}
}

Parameters:

NameDescription
jsonUrlThe JSON embed URL for the player configuration.
modifierModifier for sizing and layout.
optionsType-safe player options. Defaults to empty (uses playout defaults).
stateReactive state holder. Create with [rememberBBPlayerState].
onReadyCalled when the player has finished setup.
onErrorCalled when the player encounters an error.
onEndedCalled when playback ends.

BBNativeShorts

fun BBNativeShorts(
jsonUrl: String,
modifier: Modifier = Modifier,
options: BBShortsOptions = BBShortsOptions(),
state: BBShortsState = rememberBBShortsState(),
onReady: (() -> Unit)? = null,
onError: ((String?) -> Unit)? = null,
)

A Jetpack Compose wrapper for [BBNativeShortsView][com.bluebillywig.bbnativeplayersdk.BBNativeShortsView].

Embeds the Blue Billywig Shorts experience in a Compose layout using [AndroidView].

Example

@Composable
fun ShortsScreen(shortsUrl: String) {
val shortsState = rememberBBShortsState()

BBNativeShorts(
jsonUrl = shortsUrl,
modifier = Modifier.fillMaxSize(),
state = shortsState,
options = BBShortsOptions(displayFormat = "full"),
)
}

Parameters:

NameDescription
jsonUrlThe JSON embed URL for the shorts configuration.
modifierModifier for sizing and layout.
optionsType-safe shorts options. Defaults to empty (uses defaults).
stateReactive state holder. Create with [rememberBBShortsState].
onReadyCalled when the shorts view has finished setup.
onErrorCalled when the shorts view encounters an error.