# การปรับตั้งค่า Options

การปรับแต่งพฤติกรรมของ ByteArkPlayerFragment ทำได้ผ่าน Helper Function หลายตัวของ ByteArkPlayerFragment ซึ่งจะคืนค่าออบเจ็กต์ Setting ที่ใช้ส่งให้ createInstance(...) ตอนสร้าง Fragment

# ByteArkPlayerBuilder

สร้างผ่าน ByteArkPlayerFragment.createPlayerBuilderWithConfig(...) หรือใช้ ByteArkPlayerBuilder.Builder() โดยตรง ใช้สำหรับเปิด/ปิดความสามารถพื้นฐานของ Player

Builder method Type Default Description
withAutoPlay() flag false เริ่มเล่นวิดีโออัตโนมัติเมื่อ Player พร้อม
withControl() flag false เปิดใช้แถบควบคุม (Control Bar)
withMuted() flag false เริ่มต้นเล่นโดยปิดเสียง
withFullScreenButton() flag false แสดงปุ่ม Full Screen
withPictureInPicture() flag false เปิดใช้โหมด Picture-in-Picture
withSeekButtons() flag false แสดงปุ่ม Seek เดินหน้า/ถอยหลัง
withSeekTime(seekTime: Long) Long 10 ระยะเวลา (วินาที) ที่ใช้ Seek เดินหน้า/ถอยหลัง
withSettingButton() flag false แสดงปุ่มตั้งค่า (คุณภาพวิดีโอ, ความเร็ว, ซับไตเติ้ล ฯลฯ)
withShareOption() flag false แสดงปุ่มแชร์วิดีโอ
withEnableBackButton() flag false แสดงปุ่มย้อนกลับ
withBackButtonAction(action: Runnable) Runnable - กำหนด Action เมื่อกดปุ่มย้อนกลับ
withBackgroundPlaying() flag false เล่นเสียงต่อแม้แอปอยู่ใน Background
withSecureSurface() flag false เปิด Secure Surface เมื่อใช้งาน DRM (ป้องกันการ capture หน้าจอ)
withBrandingResourceId(id: Int) Int - กำหนด Resource ID ของโลโก้ที่จะแสดงบน Player
withLicenseKey(licenseKey: String) String - License key ของ ByteArk Player SDK
withCastContext(castContext: CastContext) CastContext - กำหนด Chromecast context (จำเป็นถ้าใช้ Chromecast)
withPlayerItem(item: ByteArkPlayerItem) object - กำหนดวิดีโอเริ่มต้น
withPlaylist(playlist: ByteArkPlayerPlaylist) object - กำหนด Playlist เริ่มต้น
withAds() flag false เปิดใช้งานระบบโฆษณา (Google IMA)
withAdTagUrl(url: String) String - URL ของ VAST/VMAP สำหรับ ad tag
withDefaultCompanionAdSlot() flag false เปิดใช้ Companion Ad slot เริ่มต้น
withDefaultCompanionAdSize(width: Int, height: Int) Int, Int - ขนาดของ Companion Ad
withAdsInsertionSetting(setting: ByteArkAdsInsertionSetting) object - ตั้งค่า Ads Insertion
withPlaybackSetting(setting: ByteArkPlaybackSetting) object - ตั้งค่าความเร็วในการเล่น
withNielsenSetting(setting: ByteArkNielsenSetting) object - ตั้งค่า Nielsen DCR
withLighthouseConfig(config: ByteArkLighthouseSetting) object - ตั้งค่า ByteArk Lighthouse
withChromecastSetting(config: ByteArkChromeCastSetting) object - ตั้งค่า Chromecast
withSubtitleSize(size: SubtitleSize) enum - ขนาดตัวอักษรของซับไตเติ้ล
withSubtitleBackgroundEnabled(enabled: Boolean) Boolean false แสดง/ซ่อนพื้นหลังตัวอักษรซับไตเติ้ล
withSubtitlePaddingBottomPercentage(percentage: Int) Int - ระยะห่างจากขอบล่างของซับไตเติ้ล (เป็น %)

# ByteArkPlayerItem

สร้างผ่าน ByteArkPlayerItemBuilder.Builder() ใช้สำหรับกำหนดข้อมูลของวิดีโอที่จะเล่น

Builder method Type Required Description
withMediaId(id: String?) String Yes ID ของวิดีโอ (จำเป็นเมื่อเปิดใช้ Lighthouse)
withTitle(title: String?) String No ชื่อวิดีโอ (จำเป็นเมื่อเปิดใช้ Lighthouse)
withSubtitle(subtitle: String?) String No คำอธิบาย/ตอน
withUrl(url: String?) String Yes URL ของวิดีโอ
withPosterImage(src: String?) String No URL ของภาพปก
withDuration(duration: Long?) Long No ความยาววิดีโอ (มิลลิวินาที)
withShareUrl(url: String?) String No URL ที่จะใช้แชร์
withAdTagUrl(url: String?) String No URL ของ ad tag เฉพาะวิดีโอ
withDrmLicenseUrl(url: String?) String No URL ของ DRM license server
withDrmLicenseRequestHeaders(headers: Map<String,String>?) Map No Custom header ที่ส่งไปยัง license server
withByteArkNielsenMetaData(metaData: ByteArkNielsenMetaData) object No Metadata สำหรับ Nielsen
withByteArkLighthouseMetaData(metaData: ByteArkLightHouseMetaData) object No Metadata สำหรับ Lighthouse

# ByteArkPlaybackSetting

สร้างผ่าน ByteArkPlayerFragment.createPlaybackSetting(speedList, defaultSpeed) ใช้สำหรับกำหนดความเร็วในการเล่น

Builder method Type Description
withPlaybackSpeedList(list: List<Float>) List<Float> รายการความเร็วที่ผู้ชมเลือกได้ เช่น [0.5, 1.0, 1.5, 2.0]
withDefaultSpeed(speed: Float) Float ความเร็วเริ่มต้น (โดยปกติคือ 1.0)
withPlaybackSpeed(speed: Float) Float ความเร็วปัจจุบัน

# ByteArkChromeCastSetting

สร้างผ่าน ByteArkPlayerFragment.createChromeCastSetting(...) หรือ ByteArkChromecastSettingBuilder

Builder method Type Description
withAppReceiverId(receiverId: String) String Chromecast Receiver Application ID
withCredential(credential: String) String Credential สำหรับ Receiver
withOptionalCredential(credential: String) String Optional credential

# ByteArkLighthouseSetting

สร้างผ่าน ByteArkPlayerFragment.createLighthouseSetting(...) หรือ ByteArkLighthouseSettingBuilder

Builder method Type Description
withProjectId(projectId: String) String Lighthouse Project ID
withLighthouseUrl(url: String?) String URL ของ Lighthouse server (สำหรับ self-hosted)

# ByteArkNielsenSetting

สร้างผ่าน ByteArkPlayerFragment.createNielsenSetting(...) หรือ ByteArkNielsenSettingBuilder

Builder method Type Description
withAppId(appId: String) String Nielsen App ID
withAppName(appName: String) String ชื่อแอปสำหรับ Nielsen
withSfCode(sfCode: String) String SF Code ของ Nielsen (เช่น "th")
withNolDevDebug(debug: String) String Debug flag ("DEBUG" หรือ "INFO")

# ByteArkAdsInsertionSetting

ใช้สำหรับ insert โฆษณาในตำแหน่งเวลาที่กำหนด

Builder method Type Description
withAdsUrl(adsUrl: String) String URL ของ ad tag
withDefaultKeyName(key: String) String Key ที่ใช้ระบุตำแหน่งโฆษณา
withDefaultOffset(offset: Long) Long Offset เริ่มต้น (มิลลิวินาที)

# ByteArkCompanionAdSlot

สร้างผ่าน ByteArkPlayerFragment.createCompanionAdSlot(container, width, height) ใช้สำหรับกำหนด container ของ Companion Ads ที่จะแสดงข้าง Player

Builder method Type Description
withContainer(container: ViewGroup) ViewGroup View ที่จะใช้แสดง Companion Ad
withWidth(width: Int) Int ความกว้าง (pixel)
withHeight(height: Int) Int ความสูง (pixel)