# Client-Side Ad Insertion (CSAI)

In addition to a single ad-tag URL, ByteArk Player SDK for Android supports Client-Side Ad Insertion (CSAI) — inserting ads at specific time offsets via ByteArkAdsInsertionSetting. This is suitable for use cases that need precise ad insertion, especially in live streaming.

# Usage

val adsInsertionSetting = ByteArkAdsInsertionSettingBuilder.Builder()
  .withAdsUrl("https://example.com/vast/tag.xml")
  .withDefaultKeyName("midroll")
  .withDefaultOffset(30_000L)  // Ad starts at 30 seconds
  .build()
val playerBuilder = ByteArkPlayerBuilder.Builder()
  .withContext(this)
  .withControl()
  .withAds()
  .withAdsInsertionSetting(adsInsertionSetting)
  .build()
1
2
3
4
5
6
7
8
9
10
11
12
Builder method Type Description
withAdsUrl(adsUrl: String) String Ad tag URL
withDefaultKeyName(key: String) String Key identifying the ad position
withDefaultOffset(offset: Long) Long Default offset in milliseconds

# Difference from Advertisement (VAST/VMAP)

Approach Description
Advertisement Single VAST/VMAP ad tag — Google IMA SDK schedules the ads
Client-Side Ad Insertion (CSAI) Custom offset-based insertion, suitable for live streaming or precise placement