OverlayAdRenderer

class OverlayAdRenderer(context: Context, overlayContainer: ViewGroup, contentPlayer: PlayerAdapter, gamConfig: GamConfig? = null, adBreakCutSafetyMarginSec: Double = DEFAULT_AD_BREAK_CUT_SAFETY_MARGIN_SEC, ioDispatcher: CoroutineDispatcher = Dispatchers.IO, vastAdManagerFactory: (player: ExoPlayer, container: ViewGroup) -> VastAdManager?? = null, adPlayerFactory: (Context) -> ExoPlayer? = null, pauseVastFetcher: suspend (url: String) -> String?? = null, pauseBeaconSink: (url: String) -> Unit? = null, clock: Clock = systemClock, contentContainer: View? = null, contentSurfaceTransformable: Boolean = true, deviceTypeOverride: DeviceType? = null, transitionMs: Long = FADE_MS, audioFocusFactory: (Context, AdAudioFocusCallbacks) -> AdAudioFocus? = null, adScaling: AdScaling = AdScaling.FIT, companionContainer: ViewGroup? = null) : AdRenderer

Overlay AdRenderer for Android: plays break assets on a dedicated ad ExoPlayer in a PlayerView above the integrator's content surface. Event ORDER comes from the portable AdBreakSequencer; this class only performs side effects and reports outcomes back.

The responsibilities live in extension files of the same package (Overlay*.kt); this file holds the state, the public API and the break entry points. All ExoPlayer interaction is marshalled onto Dispatchers.Main.

Constructors

Link copied to clipboard
constructor(context: Context, overlayContainer: ViewGroup, contentPlayer: PlayerAdapter, gamConfig: GamConfig? = null, adBreakCutSafetyMarginSec: Double = DEFAULT_AD_BREAK_CUT_SAFETY_MARGIN_SEC, ioDispatcher: CoroutineDispatcher = Dispatchers.IO, vastAdManagerFactory: (player: ExoPlayer, container: ViewGroup) -> VastAdManager?? = null, adPlayerFactory: (Context) -> ExoPlayer? = null, pauseVastFetcher: suspend (url: String) -> String?? = null, pauseBeaconSink: (url: String) -> Unit? = null, clock: Clock = systemClock, contentContainer: View? = null, contentSurfaceTransformable: Boolean = true, deviceTypeOverride: DeviceType? = null, transitionMs: Long = FADE_MS, audioFocusFactory: (Context, AdAudioFocusCallbacks) -> AdAudioFocus? = null, adScaling: AdScaling = AdScaling.FIT, companionContainer: ViewGroup? = null)

Functions

Link copied to clipboard
open override fun abortBreak(resumeOffsetSec: Double)

AdRenderer.abortBreak: ends the in-progress break now and resumes content at the break start plus resumeOffsetSec.

Link copied to clipboard
open override fun destroy()

AdRenderer.destroy: restores content state, releases the ad player and removes the overlay views.

Link copied to clipboard
open override fun endGamSession()

AdRenderer.endGamSession: resets the IMA stream manager and drops the session asset parameters.

Link copied to clipboard
open override fun endSteeredSsaiSession()

AdRenderer.endSteeredSsaiSession: resets the IMA stream manager of a steered ssai session.

Link copied to clipboard

AdRenderer.forwardSsaiTimedMetadata: hands the content cue to the IMA stream manager.

Link copied to clipboard
open override fun hidePauseAd()

AdRenderer.hidePauseAd: fades the pause ad out and releases its resources.

Link copied to clipboard
open override fun initialize()

AdRenderer.initialize: builds the ad PlayerView, the image and companion views and the GAM stream manager inside overlayContainer.

Link copied to clipboard
open override fun isAdPlaying(): Boolean

AdRenderer.isAdPlaying: true from break begin to break end.

Link copied to clipboard
open override fun isGamEnabled(): Boolean

Not gated on a GamConfig being supplied, only on the explicit opt-out.

Link copied to clipboard
open override fun isShowingAd(): Boolean

An lshape_content break in PiP is active but shows no ad; isAdPlaying stays true.

Link copied to clipboard
open suspend override fun playBreak(breakInfo: Break, callbacks: BreakPlaybackCallbacks, effectiveDurationSec: Double?)

AdRenderer.playBreak: plays the selected variant of breakInfo asset by asset and suspends until the break ends or is cut.

Link copied to clipboard
open suspend override fun preload(breakInfo: Break)

AdRenderer.preload: warms the media of the variant that will play, subject to the preload mode.

Link copied to clipboard
open suspend override fun prepareAdRequest()

AdRenderer.prepareAdRequest: awaits the installed preparer, if any.

Link copied to clipboard
open override fun revealPauseAdResume()

AdRenderer.revealPauseAdResume: shows the resume control of the mounted pause ad.

Link copied to clipboard
open override fun setAdClickHandler(handler: RendererAdClickHandler?)

AdRenderer.setAdClickHandler: installs the handler invoked when the viewer taps the ad surface.

Link copied to clipboard
open override fun setAdPreloadMode(mode: PreloadMode)

AdRenderer.setAdPreloadMode: decides whether preload may warm media in the ad player.

Link copied to clipboard
open override fun setAdRequestPreparer(preparer: suspend () -> Unit?)

AdRenderer.setAdRequestPreparer: installs the hook awaited before every ad request.

Link copied to clipboard
open override fun setAudio(muted: Boolean, volume: Double)

AdRenderer.setAudio: applies the unified mute and volume to the ad player and any pause-ad video.

Link copied to clipboard
open override fun setBreakCutSafetyMargin(seconds: Double)

AdRenderer.setBreakCutSafetyMargin: overrides the constructor adBreakCutSafetyMarginSec.

Link copied to clipboard
open override fun setBreakResumePolicy(insertionType: AdInsertionType?, timebase: Timebase, continueContentDuringBreak: Boolean)

AdRenderer.setBreakResumePolicy: sets the insertion type, timebase and continue-content option that decide where content resumes.

Link copied to clipboard
open override fun setChainResolver(resolver: ChainResolver?)

AdRenderer.setChainResolver: installs the resolver used to soft-end into a chained break.

Link copied to clipboard
open override fun setDiagnoseHandler(handler: RendererDiagnoseHandler?)

AdRenderer.setDiagnoseHandler: installs the sink for renderer diagnostics.

Link copied to clipboard
open override fun setDoubleBoxAudio(mode: DoubleBoxAudio)

AdRenderer.setDoubleBoxAudio: selects which side stays audible in a double break.

Link copied to clipboard
open override fun setGamEventCallbacks(callbacks: GamEventCallbacks)

AdRenderer.setGamEventCallbacks: installs the quartile sink for GAM and VAST ads.

Link copied to clipboard
open override fun setManifestAssetParameters(params: Map<String, String>?)

AdRenderer.setManifestAssetParameters: installs the manifest session layer and pushes a change to a live IMA session.

Link copied to clipboard
open override fun setPauseAdCreativeEndedCallback(callback: (String) -> Unit?)

AdRenderer.setPauseAdCreativeEndedCallback: installs the callback for a pause-ad video that ended or failed.

Link copied to clipboard
open override fun setPictureInPicture(active: Boolean)

AdRenderer.setPictureInPicture: re-lays out a break in flight as single when picture-in-picture starts.

Link copied to clipboard
open override fun setPictureInPictureChangeHandler(handler: (Boolean) -> Unit?)

AdRenderer.setPictureInPictureChangeHandler: starts watching the host Activity for picture-in-picture changes; null stops watching.

Link copied to clipboard

AdRenderer.setSessionAssetParameterMacros: installs the customer macros for the session.

Link copied to clipboard
open override fun setSessionAssetParameters(params: Map<String, String>?)

AdRenderer.setSessionAssetParameters: installs the session layer of the asset parameters.

Link copied to clipboard
open override fun setTransitionDurationMs(durationMs: Long)

AdRenderer.setTransitionDurationMs: overrides the constructor transitionMs; 0 cuts without a fade.

Link copied to clipboard
open override fun setTransitionPhaseReporter(reporter: (String) -> Unit?)

AdRenderer.setTransitionPhaseReporter: installs the break-transition checkpoint reporter used in debug mode.

Link copied to clipboard
open override fun showPauseAd(resolution: PauseAdResolution)

AdRenderer.showPauseAd: resolves the pause-ad creative and fades it in over the paused content.

Link copied to clipboard
open override fun skipBreak()

Reuses the break-cut path so the sequencer emits a balanced adend + adbreakend.

Link copied to clipboard
open suspend override fun startGamSession(identity: GamSessionIdentity, assetParameters: Map<String, String>?)

AdRenderer.startGamSession: opens the IMA pod-serving stream for identity and installs the session asset parameters.

Link copied to clipboard
open suspend override fun startSteeredSsaiSession(vendor: StitchedStreamVendor, assetParameters: Map<String, String>?): String

Unlike startGamSession the ads arrive inside the stitched stream; no pod is played.

Link copied to clipboard

AdRenderer.updateAssetParameterMacros: merges the customer macros and pushes them to a live IMA session.

Link copied to clipboard
open override fun updateAssetParameters(params: Map<String, String>)

AdRenderer.updateAssetParameters: replaces the live-update layer and pushes the merged parameters to IMA.

Link copied to clipboard

PiP narrows the playable-format set to single + the suppressed lshape_content.