VideoController

class VideoController


An object that provides playback control for video ads.

Summary

Nested types

Callback for receiving updates on video ad lifecycle events.

Public functions

VideoController.VideoLifecycleCallbacks?

Returns the previously provided VideoLifecycleCallbacks or null if no instance was provided.

Boolean

Returns true if the current ad has video content.

Boolean

Returns true if the video ad is using click to expand behavior.

Boolean

Returns true if the video ad is using custom player controls.

Boolean

Returns true if the video is currently muted, false otherwise.

Unit
mute(mute: Boolean)

Sets the video mute state.

Unit

Pauses the video ad if applicable.

Unit

Play the video ad if applicable.

Unit

Sets a listener that will receive callbacks for video events.

Unit

Stops video playback.

Public functions

getVideoLifecycleCallbacks

fun getVideoLifecycleCallbacks(): VideoController.VideoLifecycleCallbacks?

Returns the previously provided VideoLifecycleCallbacks or null if no instance was provided.

hasVideoContent

fun hasVideoContent(): Boolean

Returns true if the current ad has video content.

isClickToExpandEnabled

fun isClickToExpandEnabled(): Boolean

Returns true if the video ad is using click to expand behavior.

isCustomControlsEnabled

fun isCustomControlsEnabled(): Boolean

Returns true if the video ad is using custom player controls. If custom player controls are used, then it is the app's responsibility to render provide play/pause and mute/unmute controls and call play, pause, and mute at the appropriate times.

Use setCustomControlsRequested to enable custom controls.

Custom controls are currently only available for Ad Manager reservations.

isMuted

fun isMuted(): Boolean

Returns true if the video is currently muted, false otherwise.

mute

fun mute(mute: Boolean): Unit

Sets the video mute state.

This video control method only works when isCustomControlsEnabled returns true.

Parameters
mute: Boolean

true if video should be muted, false for unmuted

pause

fun pause(): Unit

Pauses the video ad if applicable. This method is a no-op if the video is already paused or the video has ended.

This video control method only works when isCustomControlsEnabled returns true.

play

fun play(): Unit

Play the video ad if applicable. This method is a no-op if the video is already playing.

This video control method only works when isCustomControlsEnabled returns true.

setVideoLifecycleCallbacks

fun setVideoLifecycleCallbacks(
    callbacks: VideoController.VideoLifecycleCallbacks?
): Unit

Sets a listener that will receive callbacks for video events.

Parameters
callbacks: VideoController.VideoLifecycleCallbacks?

the object that is to receive lifecycle callbacks

stop

fun stop(): Unit

Stops video playback. Subsequent calls to play will resume at the beginning of the video. This method is a no-op if the video has already been stopped.

The ad unit must be in the allow list to be able to use this api. If you are interested in using this feature, reach out to your account manager.