# Google Chromecast

ByteArk Player SDK for Android supports casting to Chromecast-compatible devices.

# AndroidManifest.xml setup

Add the Cast options provider meta-data inside <application>:

<application>
  <meta-data
    android:name="com.google.android.gms.cast.framework.OPTIONS_PROVIDER_CLASS_NAME"
    android:value="com.google.android.exoplayer2.ext.cast.DefaultCastOptionsProvider"/>
</application>
1
2
3
4
5

# Configure Chromecast Setting

val chromeCastSetting = ByteArkPlayerFragment.createChromeCastSetting(true)
1

Or via builder:

val chromeCastSetting = ByteArkChromecastSettingBuilder.Builder()
  .withAppReceiverId("CC1AD845")  // Default Media Receiver ID
  .build()
1
2
3
Builder method Type Description
withAppReceiverId(receiverId: String) String Chromecast Receiver Application ID ("CC1AD845" for the Default Media Receiver)
withCredential(credential: String) String Receiver credential
withOptionalCredential(credential: String) String Optional credential

# Pass CastContext to the player

val castContext = CastContext.getSharedInstance(this)
val playerBuilder = ByteArkPlayerBuilder.Builder()
  .withContext(this)
  .withCastContext(castContext)
  .withControl()
  .build()
1
2
3
4
5
6
7

# Pass the setting to the player

mPlayerFragment = ByteArkPlayerFragment.createInstance(
  playerBuilder,
  mFragmentListener,
  companionAdSlot,
  nielsenSetting,
  playbackSetting,
  lighthouseSetting,
  chromeCastSetting
)
1
2
3
4
5
6
7
8
9