VideoStreamPlayer

interface VideoStreamPlayer : 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 functions

Unit

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

Unit
loadUrl(url: String!, subtitles: (Mutable)List<HashMap<String!, String!>!>!)

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

Unit

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

Unit

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

Unit

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

Unit

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

Unit

Pauses the current stream.

Unit

Removes a callback.

Unit

Resumes playing the stream.

Unit
seek(time: Long)

Seeks the stream to the given time.

Inherited functions

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

Gets an update on the progress of the video.

From com.google.ads.interactivemedia.v3.api.player.VolumeProvider
Int

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

Public functions

addCallback

fun addCallback(callback: VideoStreamPlayer.VideoStreamPlayerCallback!): Unit

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

loadUrl

fun loadUrl(url: String!, subtitles: (Mutable)List<HashMap<String!, String!>!>!): Unit

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

fun onAdBreakEnded(): Unit

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

onAdBreakStarted

fun onAdBreakStarted(): Unit

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

fun onAdPeriodEnded(): Unit

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

fun onAdPeriodStarted(): Unit

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

fun pause(): Unit

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

removeCallback

fun removeCallback(callback: VideoStreamPlayer.VideoStreamPlayerCallback!): Unit

Removes a callback.

resume

fun resume(): Unit

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

seek

fun seek(time: Long): Unit

Seeks the stream to the given time.

Parameters
time: Long

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