# Advertisement

ByteArk Player SDK for Flutter supports advertisement playback through the Google IMA SDK following the Video Ad Serving Template (VAST) (opens new window) and VMAP standards, configured via adsSettings on ByteArkPlayerConfig.

# Enable

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? VAST/VMAP ad tag URL
enableDefaultCompanionSlot bool? Enable the default Companion Ad slot
defaultCompanionSize Pair<int, int>? Companion Ad size (width, height)

# Receive ad events

final listener = ByteArkPlayerListener(
  onAdsRequest: () => debugPrint("Ad requested"),
  onAdsBreakStart: () => debugPrint("Ad break started"),
  onAdsStart: (data) => debugPrint("Ad started: ${data.toMap()}"),
  onAdsImpressed: (data) => debugPrint("Ad impression"),
  onAdsFirstQuartile: (data) => debugPrint("Ad first quartile"),
  onAdsMidPoint: (data) => debugPrint("Ad midpoint"),
  onAdsThirdQuartile: (data) => debugPrint("Ad third quartile"),
  onAdsCompleted: (data) => debugPrint("Ad completed"),
  onAdsClicked: (data) => debugPrint("Ad clicked"),
  onAdsSkipped: (data) => debugPrint("Ad skipped"),
  onAdsBreakEnd: () => debugPrint("Ad break ended"),
  onAllAdsCompleted: () => debugPrint("All ads completed"),
  onAdsError: (error) => debugPrint("Ads error: ${error.msg}"),
);
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15

# ByteArkPlayerAdsData

Ad lifecycle callbacks (onAdsStart, the quartile callbacks, onAdsCompleted, onAdsClicked, onAdsSkipped, onAdsImpressed) receive a ByteArkPlayerAdsData object:

Field Type Description
adId String? Unique identifier of the ad creative
adSystem String? Ad system that served the ad (e.g. GoogleAds)
advertiserName String? Display name of the advertiser
creativeAdId String? Identifier of the creative variant within the campaign
creativeId String? Identifier of the creative asset
title String? Human-readable ad title

onAdsError instead receives a ByteArkPlayerAdsErrorData with code and msg fields (see Errors Reference).