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:
| Name | Description |
|---|---|
jsonUrl | The JSON embed URL for the player configuration. |
modifier | Modifier for sizing and layout. |
options | Type-safe player options. Defaults to empty (uses playout defaults). |
state | Reactive state holder. Create with [rememberBBPlayerState]. |
onReady | Called when the player has finished setup. |
onError | Called when the player encounters an error. |
onEnded | Called 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:
| Name | Description |
|---|---|
jsonUrl | The JSON embed URL for the shorts configuration. |
modifier | Modifier for sizing and layout. |
options | Type-safe shorts options. Defaults to empty (uses defaults). |
state | Reactive state holder. Create with [rememberBBShortsState]. |
onReady | Called when the shorts view has finished setup. |
onError | Called when the shorts view encounters an error. |