AdPlaybackState.AdGroup


class AdPlaybackState.AdGroup


Represents a group of ads, with information about their states.

Instances are immutable. Call the with* methods to get new instances that have the required changes.

Summary

Public constructors

AdGroup(timeUs: Long)

Creates a new ad group with an unspecified number of ads.

Public functions

Boolean
equals(o: Any?)
java-static AdPlaybackState.AdGroup!
fromBundle(bundle: Bundle!)

Restores a AdGroup from a Bundle.

Int

Returns the index of the first ad in the ad group that should be played, or count if no ads should be played.

Int
getNextAdIndexToPlay(lastPlayedAdIndex: @IntRange(from = "-1") Int)

Returns the index of the next ad in the ad group that should be played after playing lastPlayedAdIndex, or count if no later ads should be played.

Boolean

Returns whether the ad group has at least one ad that is neither played, skipped, nor failed.

Int
Boolean

Returns whether the ad group has at least one ad that should be played.

Bundle!
AdPlaybackState.AdGroup!
withAdCount(count: Int)

Returns a new instance with the ad count set to count.

AdPlaybackState.AdGroup!

Returns a new instance with the specified ad durations, in microseconds.

AdPlaybackState.AdGroup!
withAdMediaItem(mediaItem: MediaItem!, index: @IntRange(from = 0) Int)

Returns a new instance with the specified MediaItem set for the specified ad, and the ad marked as AD_STATE_AVAILABLE.

AdPlaybackState.AdGroup!
withAdState(
    @AdPlaybackState.AdState state: Int,
    index: @IntRange(from = 0) Int
)

Returns a new instance with the specified ad set to the specified state.

AdPlaybackState.AdGroup!
withAdUri(uri: Uri!, index: @IntRange(from = 0) Int)

This function is deprecated.

Use withAdMediaItem instead.

AdPlaybackState.AdGroup!

Returns an instance with all ads in final states (played, skipped, error) reset to either available or unavailable, which allows to play them again.

AdPlaybackState.AdGroup!

Returns an instance with all unavailable and available ads marked as skipped.

AdPlaybackState.AdGroup!
withContentResumeOffsetUs(contentResumeOffsetUs: Long)

Returns an instance with the specified contentResumeOffsetUs.

AdPlaybackState.AdGroup!
withIsServerSideInserted(isServerSideInserted: Boolean)

Returns an instance with the specified value for isServerSideInserted.

AdPlaybackState.AdGroup!

Removes the last ad from the ad group.

AdPlaybackState.AdGroup!
withOriginalAdCount(originalCount: Int)

Returns an instance with the specified value for originalCount.

AdPlaybackState.AdGroup!
withTimeUs(timeUs: Long)

Returns a new instance with the timeUs set to the specified value.

Public properties

Long

The offset in microseconds which should be added to the content stream when resuming playback after the ad group.

Int

The number of ads in the ad group, or LENGTH_UNSET if unknown.

LongArray<Long>!

The durations of each ad in the ad group, in microseconds.

Boolean

Whether this ad group is server-side inserted and part of the content stream.

Array<@NullableType MediaItem!>!

The MediaItem instances for each ad in the ad group, or null if not yet known.

Int

The original number of ads in the ad group in case the ad group is only partially available, or LENGTH_UNSET if unknown.

IntArray<Int>!

The state of each ad in the ad group.

Long

The time of the ad group in the Timeline.Period, in microseconds, or TIME_END_OF_SOURCE to indicate a postroll ad.

Array<@NullableType Uri!>!

This property is deprecated.

Use mediaItems instead.

Public constructors

AdGroup

AdGroup(timeUs: Long)

Creates a new ad group with an unspecified number of ads.

Parameters
timeUs: Long

The time of the ad group in the Timeline.Period, in microseconds, or TIME_END_OF_SOURCE to indicate a postroll ad.

Public functions

equals

fun equals(o: Any?): Boolean

fromBundle

java-static fun fromBundle(bundle: Bundle!): AdPlaybackState.AdGroup!

Restores a AdGroup from a Bundle.

getFirstAdIndexToPlay

fun getFirstAdIndexToPlay(): Int

Returns the index of the first ad in the ad group that should be played, or count if no ads should be played.

getNextAdIndexToPlay

fun getNextAdIndexToPlay(lastPlayedAdIndex: @IntRange(from = "-1") Int): Int

Returns the index of the next ad in the ad group that should be played after playing lastPlayedAdIndex, or count if no later ads should be played. If no ads have been played, pass -1 to get the index of the first ad to play.

Note: Server side inserted ads are always considered playable.

hasUnplayedAds

fun hasUnplayedAds(): Boolean

Returns whether the ad group has at least one ad that is neither played, skipped, nor failed.

hashCode

fun hashCode(): Int

shouldPlayAdGroup

fun shouldPlayAdGroup(): Boolean

Returns whether the ad group has at least one ad that should be played.

toBundle

fun toBundle(): Bundle!

withAdCount

fun withAdCount(count: Int): AdPlaybackState.AdGroup!

Returns a new instance with the ad count set to count.

withAdDurationsUs

fun withAdDurationsUs(durationsUs: LongArray!): AdPlaybackState.AdGroup!

Returns a new instance with the specified ad durations, in microseconds.

withAdMediaItem

fun withAdMediaItem(mediaItem: MediaItem!, index: @IntRange(from = 0) Int): AdPlaybackState.AdGroup!

Returns a new instance with the specified MediaItem set for the specified ad, and the ad marked as AD_STATE_AVAILABLE.

withAdState

fun withAdState(
    @AdPlaybackState.AdState state: Int,
    index: @IntRange(from = 0) Int
): AdPlaybackState.AdGroup!

Returns a new instance with the specified ad set to the specified state. The ad specified must currently either be in AD_STATE_UNAVAILABLE or AD_STATE_AVAILABLE.

This instance's ad count may be unknown, in which case index must be less than the ad count specified later. Otherwise, index must be less than the current ad count.

withAdUri

fun withAdUri(uri: Uri!, index: @IntRange(from = 0) Int): AdPlaybackState.AdGroup!

withAllAdsReset

fun withAllAdsReset(): AdPlaybackState.AdGroup!

Returns an instance with all ads in final states (played, skipped, error) reset to either available or unavailable, which allows to play them again.

withAllAdsSkipped

fun withAllAdsSkipped(): AdPlaybackState.AdGroup!

Returns an instance with all unavailable and available ads marked as skipped. If the ad count hasn't been set, it will be set to zero.

withContentResumeOffsetUs

fun withContentResumeOffsetUs(contentResumeOffsetUs: Long): AdPlaybackState.AdGroup!

Returns an instance with the specified contentResumeOffsetUs.

withIsServerSideInserted

fun withIsServerSideInserted(isServerSideInserted: Boolean): AdPlaybackState.AdGroup!

Returns an instance with the specified value for isServerSideInserted.

withLastAdRemoved

fun withLastAdRemoved(): AdPlaybackState.AdGroup!

Removes the last ad from the ad group.

withOriginalAdCount

fun withOriginalAdCount(originalCount: Int): AdPlaybackState.AdGroup!

Returns an instance with the specified value for originalCount.

withTimeUs

fun withTimeUs(timeUs: Long): AdPlaybackState.AdGroup!

Returns a new instance with the timeUs set to the specified value.

Public properties

contentResumeOffsetUs

val contentResumeOffsetUsLong

The offset in microseconds which should be added to the content stream when resuming playback after the ad group.

count

val countInt

The number of ads in the ad group, or LENGTH_UNSET if unknown.

durationsUs

val durationsUsLongArray<Long>!

The durations of each ad in the ad group, in microseconds.

isServerSideInserted

val isServerSideInsertedBoolean

Whether this ad group is server-side inserted and part of the content stream.

mediaItems

@NullableType
val mediaItemsArray<@NullableType MediaItem!>!

The MediaItem instances for each ad in the ad group, or null if not yet known.

originalCount

val originalCountInt

The original number of ads in the ad group in case the ad group is only partially available, or LENGTH_UNSET if unknown. An ad can be partially available when a server side inserted ad live stream is joined while an ad is already playing and some ad information is missing.

states

@AdPlaybackState.AdState
val statesIntArray<Int>!

The state of each ad in the ad group.

timeUs

val timeUsLong

The time of the ad group in the Timeline.Period, in microseconds, or TIME_END_OF_SOURCE to indicate a postroll ad.

uris

@NullableType
val urisArray<@NullableType Uri!>!