GamStreamManager

class GamStreamManager(context: Context, adUiContainer: ViewGroup, adPlayerVolumeProvider: () -> Int = { 100 })

Manages a Google IMA DAI SDK pod-serving session on Android — the Kotlin mirror of the web GamStreamManager. Initializes an IMA StreamManager via a PodStreamRequest, exposes the resulting streamId for pod-manifest URL construction (delegated to the portable buildGamPodUrl), and forwards ad progress/quartile events.

Pod manifests are stitched/played by the SDK's ad player (we build the pod URL ourselves); IMA tracks ad progress from the stream's timed metadata, which the player forwards via processMetadata. Requires a device/emulator at runtime (the IMA SDK has no headless mode); this class is structured for that.

Constructors

Link copied to clipboard
constructor(context: Context, adUiContainer: ViewGroup, adPlayerVolumeProvider: () -> Int = { 100 })

Functions

Link copied to clipboard
fun buildPodUrl(podId: String, durationSeconds: Double, params: GamVendorParameters): String

Build a pod-manifest URL for podId using the current streamId. Throws if not initialized.

Link copied to clipboard
fun destroy()

Destroy and release all resources.

Link copied to clipboard

The IMA stream id of the initialized session, or null before isInitialized.

Link copied to clipboard
suspend fun initialize(config: GamStreamConfig)

Initialize a fresh IMA pod-serving session and suspend until the stream id is available (or the request errors). Always resets any prior session.

Link copied to clipboard

Open a full-service IMA DAI live-stream session and suspend until IMA hands back the stitched stream URL to play on the content player.

Link copied to clipboard

Whether a stream session has been initialized with a valid streamId.

Link copied to clipboard
fun processMetadata(userText: String)

Forward timed metadata (HLS ID3 TXXX text) from the ad player to IMA.

Link copied to clipboard

Forward an in-stream timed-metadata marker (from the content player in SSAI mode) to IMA for ad tracking. Picks the ID3 TXXX user text (falling back to the first frame / message payload). No-op when no text is present.

Link copied to clipboard

Replace ad-tag parameters on the active stream session. No-op if not initialized.

Link copied to clipboard
fun reset()

Reset session state before starting a new session.

Link copied to clipboard

Install the sink for IMA ad-progress events; replaces any earlier one.