VideoStreamPlayer

public interface VideoStreamPlayer extends ContentProgressProvider, VolumeProvider


Defines a set of methods that a video player must implement to be used by the IMA SDK for dynamic ad insertion.

Summary

Nested types

Callbacks that the player must fire.

Public methods

abstract void

Adds a callback so that listeners can react to events from the VideoStreamPlayer.

abstract void
loadUrl(String url, List<HashMap<StringString>> subtitles)

Loads a stream with dynamic ad insertion given the stream url and subtitles array.

abstract void

The SDK will call this method the first time each ad break ends.

abstract void

The SDK will call this method the first time each ad break begins playback.

abstract void

The SDK will call this method every time the stream switches from advertising or slate to content.

abstract void

The SDK will call this method every time the stream switches from content to advertising or slate.

abstract void

Pauses the current stream.

abstract void

Removes a callback.

abstract void

Resumes playing the stream.

abstract void
seek(long time)

Seeks the stream to the given time.

Inherited methods

From com.google.ads.interactivemedia.v3.api.player.ContentProgressProvider
abstract VideoProgressUpdate

Gets an update on the progress of the video.

From com.google.ads.interactivemedia.v3.api.player.VolumeProvider
abstract int

Returns the volume of the player as a percentage from 0 to 100.

Public methods

addCallback

abstract void addCallback(VideoStreamPlayer.VideoStreamPlayerCallback callback)

Adds a callback so that listeners can react to events from the VideoStreamPlayer.

loadUrl

abstract void loadUrl(String url, List<HashMap<StringString>> subtitles)

Loads a stream with dynamic ad insertion given the stream url and subtitles array. The subtitles array is only used in VOD streams.

Each entry in the subtitles array is a HashMap that corresponds to a language. Each map will have a "language" key with a two letter language string value, a "language name" to specify the set of subtitles if multiple sets exist for the same language, and one or more subtitle key/value pairs. Here's an example map for English:

  • "language" -> "en"
  • "language_name" -> "English"
  • "webvtt" -> "https://example.com/vtt/en.vtt"
  • "ttml" -> "https://example.com/ttml/en.ttml"
For pod streams, is only called for VOD streams. For pod livestreams, the SDK will not call .

onAdBreakEnded

abstract void onAdBreakEnded()

The SDK will call this method the first time each ad break ends. Applications must reenable seeking when this occurs.

onAdBreakStarted

abstract void onAdBreakStarted()

The SDK will call this method the first time each ad break begins playback. If an ad break is watched subsequent times this callback will not be triggered. Applications must disable seeking when this occurs.

onAdPeriodEnded

abstract void onAdPeriodEnded()

The SDK will call this method every time the stream switches from advertising or slate to content. This will be called even when an ad is played a second time or when seeking into an ad.

onAdPeriodStarted

abstract void onAdPeriodStarted()

The SDK will call this method every time the stream switches from content to advertising or slate. This will be called even when an ad is played a second time or when seeking into an ad.

pause

abstract void pause()

Pauses the current stream. This may be called by the publisher or by an interactive ad.

removeCallback

abstract void removeCallback(VideoStreamPlayer.VideoStreamPlayerCallback callback)

Removes a callback.

resume

abstract void resume()

Resumes playing the stream. This may be called by the publisher or an interactive ad.

seek

abstract void seek(long time)

Seeks the stream to the given time.

Parameters
long time

The time to which the stream should be seeked in milliseconds.