VideoController

public final class VideoController


An object that provides playback control for video ads.

Summary

Nested types

Callback for receiving updates on video ad lifecycle events.

Public methods

@Nullable 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.

void
mute(boolean mute)

Sets the video mute state.

void

Pauses the video ad if applicable.

void

Play the video ad if applicable.

void

Sets a listener that will receive callbacks for video events.

void

Stops video playback.

Public methods

getVideoLifecycleCallbacks

public @Nullable VideoController.VideoLifecycleCallbacks getVideoLifecycleCallbacks()

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

hasVideoContent

public boolean hasVideoContent()

Returns true if the current ad has video content.

isClickToExpandEnabled

public boolean isClickToExpandEnabled()

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

isCustomControlsEnabled

public boolean isCustomControlsEnabled()

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

public boolean isMuted()

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

mute

public void mute(boolean mute)

Sets the video mute state.

This video control method only works when isCustomControlsEnabled returns true.

Parameters
boolean mute

true if video should be muted, false for unmuted

pause

public void pause()

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

public void play()

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

public void setVideoLifecycleCallbacks(
    @Nullable VideoController.VideoLifecycleCallbacks callbacks
)

Sets a listener that will receive callbacks for video events.

Parameters
@Nullable VideoController.VideoLifecycleCallbacks callbacks

the object that is to receive lifecycle callbacks

stop

public void stop()

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.