# การเล่นโฆษณา (Advertisement)

ByteArk Player SDK for Flutter รองรับการแสดงโฆษณาผ่าน Google IMA SDK ตามมาตรฐาน Video Ad Serving Template (VAST) (opens new window) และ VMAP โดยกำหนดผ่าน adsSettings ของ ByteArkPlayerConfig

# การเปิดใช้งาน

final config = ByteArkPlayerConfig(
  licenseKey: licenseKey,
  playerItem: playerItem,
  adsSettings: ByteArkAdsSettings(
    adTagUrl: "<VAST_TAG_URL>",
  ),
);
1
2
3
4
5
6
7
Property Type Description
adTagUrl String? URL ของ VAST/VMAP ad tag
enableDefaultCompanionSlot bool? เปิดใช้ Companion Ad slot เริ่มต้น
defaultCompanionSize Pair<int, int>? ขนาดของ Companion Ad (width, height)

# รับ Event ของโฆษณา

final listener = ByteArkPlayerListener(
  onAdsRequest: () => debugPrint("Ad requested"),
  onAdsBreakStart: () => debugPrint("Ad break started"),
  onAdsStart: (data) => debugPrint("Ad started: ${data.toMap()}"),
  onAdsEnd: () => debugPrint("Ad ended"),
  onAdsComplete: () => debugPrint("All ads completed"),
  onAdsClicked: () => debugPrint("Ad clicked"),
  onAdsSkipped: () => debugPrint("Ad skipped"),
  onAdsError: (error) => debugPrint("Ads error: ${error.message}"),
);
1
2
3
4
5
6
7
8
9
10