# Google Chromecast

ByteArk Player SDK for Android รองรับการ Cast วิดีโอไปยังอุปกรณ์ที่รองรับ Google Chromecast

# การตั้งค่า AndroidManifest.xml

เพิ่ม meta-data สำหรับ Cast options provider ใน <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

# สร้าง Chromecast Setting

val chromeCastSetting = ByteArkPlayerFragment.createChromeCastSetting(true)
1

หรือใช้ 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" สำหรับ Default Media Receiver)
withCredential(credential: String) String Credential สำหรับ Receiver (ถ้า Receiver ต้องการ)
withOptionalCredential(credential: String) String Optional credential

# ส่ง CastContext เข้า Player Builder

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

# นำ Setting มาใช้

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