Skip to main content

Chromecast (Google Cast)

The Cast SDK allows a user to select streaming audio-visual content using a sender (Lura Player), and play it on (or cast it to) another device known as the receiver, while controlling playback using the sender.

caution

Chromecast is not supported on Android TV, Fire TV and devices without Google Play Services.

To enable Google Cast SDK on your player, you need to do the following configuration:

AttributeTypeOptionalDescription
enabledBooleanyesWhether casting is enabled in available devices. (Defaults to false)
appIdStringnoChromecast receiver application ID
Gradle dependencies
dependencies {
implementation 'androidx.appcompat:appcompat:1.3.1'
implementation 'androidx.mediarouter:mediarouter:1.2.5'
implementation 'com.google.android.gms:play-services-cast-framework:21.4.0'
}
OptionsProvider Example
class CastOptionsProvider : OptionsProvider {
override fun getCastOptions(context: Context): CastOptions {
return Builder()
.setReceiverApplicationId(context.getString(R.string.app_id))
.build()
}

override fun getAdditionalSessionProviders(context: Context): List<SessionProvider>? {
return null
}
}
AndroidManifest.xml
<application>
...
<meta-data
android:name=
"com.google.android.gms.cast.framework.OPTIONS_PROVIDER_CLASS_NAME"
android:value="YOUR_PACKAGE.CastOptionsProvider" />
</application>
val luraConfiguration = LuraConfiguration(
cast = LuraCastConfiguration(
chromecast = LuraChromecastConfiguration(
enabled = true,
)
)
)

playerView = findViewById(R.id.lura_player_view)
player = LuraPlayer(context = this, playerView = playerView)
player.setConfig(luraConfiguration)