Chromecast Integration
Add Chromecast (Google Cast) support when using BBChannelWithPlayerView.
Chromecast is provided by the BB Native Player SDK, which wraps the native Google Cast SDK.
Prerequisites
The Google Cast SDK is included automatically with the BB Native Player SDK. The SDK registers a default CastOptionsProvider with application ID 1F61A3A5.
If you need a custom Cast application ID, create your own provider and register it in AndroidManifest.xml:
<meta-data
android:name="com.google.android.gms.cast.framework.OPTIONS_PROVIDER_CLASS_NAME"
android:value="com.yourapp.CastOptionsProvider" />
If you don't need a custom Cast app ID, no additional setup is needed.
Cast Button
Use BBCastButton to render the native Google Cast button (MediaRouteButton). It auto-shows when a Cast device is discovered.
import com.bluebillywig.bbchannel.compose.BBChannelWithPlayerView
import com.bluebillywig.bbplayer.compose.BBCastButton
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun ChannelScreen() {
val viewModel = remember { BBChannelViewModel() }
Scaffold(
topBar = {
TopAppBar(
title = { Text("Videos") },
actions = {
BBCastButton(
modifier = Modifier.size(36.dp),
tintColor = Color.White
)
}
)
}
) { padding ->
BBChannelWithPlayerView(
channelUrl = "https://demo.bbvms.com/ch/channel_name.json",
viewModel = viewModel,
callbacks = BBChannelCallbacks(),
modifier = Modifier.padding(padding)
)
}
}
How It Works
BBChannelWithPlayerView handles cast routing automatically via castMode: "auto":
- Connect first, then play — video routes directly to the Cast device
- Play first, then connect — playback transfers to Cast at the current position
- Switch clips while casting — new content replaces the current Cast stream
- Disconnect — playback resumes locally on next play
No additional configuration or dialogs are needed.
Tips
- Place
BBCastButtonin the top app bar so it's always accessible - The cast button is invisible when no devices are available — use fixed dimensions
- Cast device discovery requires the device to be on the same Wi-Fi network as the Chromecast