CastConnector

interface CastConnector

SPI for Chromecast support (sender side). Apps construct a connector from the cast module (OGCastConnector) and pass it to OGPlayer.Builder.setCastConnector. When a cast session starts, the player hands playback off to the receiver at the current position and takes it back when the session ends — listeners and UI keep working.

The SDK is a Cast sender only: what plays on the receiver (DRM, ads, custom UI) is defined by the receiver application. By default Google's default media receiver is used; apps with their own hosted Web Receiver configure its ID via the cast module.

Functions

Link copied to clipboard
abstract fun createCastPlayer(listener: CastSessionListener): Any?

Creates the cast playback engine (androidx.media3.cast.CastPlayer), reporting session availability through listener. Returns null when cast is unavailable on this device (e.g. missing Play Services).

Link copied to clipboard
abstract fun release()

Releases cast resources. Called from OGPlayer.release().

Link copied to clipboard
open fun showCastDialog(context: Context)

Opens the Cast device picker (device scanning happens inside the dialog); when a session is already active, shows the session controller for disconnecting instead. The player's built-in controls call this from the cast button.