AdPlayer

interface AdPlayer

AdPlayer is an interface that describes the functionality of our media player and should be extended to create an SDK-compatible ad player.

Types

Link copied to clipboard
interface Listener

Callbacks that the player must fire.

Link copied to clipboard
data class MetadataItem(val key: String, val value: String)

MetadataItem encapsulates one key-value item used in the onMetadata callback

Link copied to clipboard

Represents the possible states of the player. This enum reports the player's playback state to the SDK whenever the status() function is called by the SDK.

Properties

Link copied to clipboard
abstract var cacheAssetsHint: Boolean

Indicates whether assets should be cached. This flag mirrors the value passed through AdManagerSettings. Your AdPlayer implementation does not need to handle this property unless your player requires custom logic for asset caching.

Link copied to clipboard

Indicates whether enqueue mode is enabled. This flag mirrors the value passed through AdManagerSettings. Your AdPlayer implementation may ignore this hint unless it requires custom logic for handling enqueue behavior.

Link copied to clipboard

Is buffering while paused. Returns:
true if the player buffers the content while paused and starts from that same point when it resumes;
false if the player does not buffer while paused, and when it resumes the playback starts from the live frame of the stream

Link copied to clipboard
abstract val name: String

Name of the player, e.g. MyExternalImplementationOfAdPlayer

Link copied to clipboard

Player capabilities as described in the VAST 4.0 document

Link copied to clipboard

Player state as described in the VAST 4.+ document

Link copied to clipboard
abstract val version: String

Player version, e.g. 1.0.0

Link copied to clipboard
abstract var volume: Float

Current player volume. The value should be between 0.0f ( silence ) and 1.0f ( maximum volume )

Functions

Link copied to clipboard
abstract fun addListener(listener: AdPlayer.Listener)

Adds an AdPlayer.Listener callback.
listener: AdPlayer.Listener callback to be add

Link copied to clipboard
open fun clearVideoSurface(surface: Surface)

Removes a surface previously set to render the video content.
surface - the surface that was used to render the video content

Link copied to clipboard
open fun dequeue(index: Int)

Dequeue - removes a creative from the playlist.
index - the position from which we want to remove the creative

Link copied to clipboard
open fun enqueue(creativeUrlString: String, index: Int)

Enqueues a creative URL into the player for an ad pod. This method is invoked once for each media file in the pod. creativeUrlString - The URL of the creative to enqueue. index - The position in the playlist at which to enqueue the creative.

Link copied to clipboard
abstract fun getCurrentTime(): Duration

Returns the current playhead of the current track. Note: Implementations must preserve the value with at least millisecond precision.

Link copied to clipboard
abstract fun getDuration(): Duration?

Returns the total duration of the current track. Note: Implementations must preserve the value with at least millisecond precision.

Link copied to clipboard
abstract fun load(creativeUrlString: String)

Loads a creative into the player for the current media file. creativeUrlString - The URL of the creative to load.

Link copied to clipboard
abstract fun pause()

Pauses the current ad.

Link copied to clipboard
abstract fun play()

Plays the current ad.

Link copied to clipboard
open fun release()

This method will be called when any instance of: AdManager, AdswizzAdStreamManager, AdswizzAdPodcastManager wants to free up the resources used is their lifecycle.

Link copied to clipboard
abstract fun removeListener(listener: AdPlayer.Listener)

Removes an AdPlayer.Listener callback.
listener: AdPlayer.Listener callback to be removed

Link copied to clipboard
abstract fun reset()

Resets the player. Should be able to rerun ads from the beginning.

Link copied to clipboard
abstract fun seekTo(position: Duration)

Skips to a certain position.
position: where to jump player playhead

Link copied to clipboard
abstract fun seekToTrackEnd()

Skips the current ad.

Link copied to clipboard
open fun setVideoState(videoState: AdVideoState?)

Sets the video view state for viewability purposes.
videoState - the state of the video view. Possible values: MINIMIZED, COLLAPSED, NORMAL, EXPANDED, FULLSCREEN

Link copied to clipboard
open fun setVideoSurface(surface: Surface)

Sets a surface to render the video content.
surface - the surface to be used to render the video content

Link copied to clipboard
abstract fun status(): AdPlayer.Status

return the current status for a player. The enum with all possible values is defined here: Status