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 functions |
|
|---|---|
AdPlaybackState.AdGroup! |
copy()Returns a safe copy with all array fields copied into the new instance as new arrays. |
Boolean |
|
java-static AdPlaybackState.AdGroup! |
fromBundle(bundle: Bundle!)Restores a |
Int |
Returns the index of the first ad in the ad group that should be played, or |
Int |
getIndexOfAdId(adId: String!)Returns the index of the ad with the given ad ID, or |
Int |
getNextAdIndexToPlay(lastPlayedAdIndex: @IntRange(from = "-1") Int)Returns the index of the next ad in the ad group that should be played after playing |
Boolean |
Returns whether the ad group has at least one ad that is neither played, skipped, nor failed. |
Int |
hashCode() |
Boolean |
Returns whether this is a placeholder ad group. |
Boolean |
isLivePostrollPlaceholder(isServerSideInserted: Boolean)Returns whether this is a is a placeholder ad group. |
Boolean |
Returns whether the ad group has at least one ad that should be played. |
Bundle! |
toBundle() |
AdPlaybackState.AdGroup! |
withAdCount(count: Int)Returns a new instance with the ad count set to |
AdPlaybackState.AdGroup! |
withAdDurationsUs(durationsUs: LongArray!)Returns a new instance with the specified ad durations, in microseconds. |
AdPlaybackState.AdGroup! |
Returns a new instance with the specified ID for the given ad index. |
AdPlaybackState.AdGroup! |
withAdMediaItem(mediaItem: MediaItem!, index: @IntRange(from = 0) Int)Returns a new instance with the specified |
AdPlaybackState.AdGroup! |
withAdSkipInfo(Returns a new instance with the specified |
AdPlaybackState.AdGroup! |
withAdState(Returns a new instance with the specified ad set to the specified |
AdPlaybackState.AdGroup! |
This function is deprecated. Use |
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 |
AdPlaybackState.AdGroup! |
withIsServerSideInserted(isServerSideInserted: Boolean)Returns an instance with the specified value for |
AdPlaybackState.AdGroup! |
Removes the last ad from the ad group. |
AdPlaybackState.AdGroup! |
withOriginalAdCount(originalCount: Int)Returns an instance with the specified value for |
AdPlaybackState.AdGroup! |
withTimeUs(timeUs: Long)Returns a new instance with the |
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 |
LongArray<Long>! |
The durations of each ad in the ad group, in microseconds. |
Array<@NullableType String!>! |
The optional IDs of the ads. |
Boolean |
Whether this is an ignorable placeholder that must not be attempted to be played. |
Boolean |
Whether this ad group is server-side inserted and part of the content stream. |
Array<@NullableType MediaItem!>! |
The |
Int |
The original number of ads in the ad group in case the ad group is only partially available, or |
Array<@NullableType AdPlaybackState.SkipInfo!>! |
The skip information for each ad in the ad group. |
IntArray<Int>! |
The state of each ad in the ad group. |
Long |
The time of the ad group in the |
Array<@NullableType Uri!>! |
This property is deprecated. Use |
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 |
Public functions
copy
fun copy(): AdPlaybackState.AdGroup!
Returns a safe copy with all array fields copied into the new instance as new arrays.
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.
getIndexOfAdId
fun getIndexOfAdId(adId: String!): Int
Returns the index of the ad with the given ad ID, or INDEX_UNSET if the ad ID can't be found.
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.
isLivePostrollPlaceholder
fun isLivePostrollPlaceholder(): Boolean
Returns whether this is a placeholder ad group. It can be server-side inserted or not. Use isLivePostrollPlaceholder if you want to differentiate.
| Returns | |
|---|---|
Boolean |
true only if this is a live postroll placeholder. |
isLivePostrollPlaceholder
fun isLivePostrollPlaceholder(isServerSideInserted: Boolean): Boolean
Returns whether this is a is a placeholder ad group.
| Parameters | |
|---|---|
isServerSideInserted: Boolean |
Whether the postroll placeholder must be server-side inserted. |
| Returns | |
|---|---|
Boolean |
true only if this ad group has a matching |
shouldPlayAdGroup
fun shouldPlayAdGroup(): Boolean
Returns whether the ad group has at least one ad that should be played.
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.
withAdId
fun withAdId(adId: String!, index: @IntRange(from = 0) Int): AdPlaybackState.AdGroup!
Returns a new instance with the specified ID for the given ad index.
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.
withAdSkipInfo
fun withAdSkipInfo(
skipInfo: AdPlaybackState.SkipInfo!,
index: @IntRange(from = 0) Int
): AdPlaybackState.AdGroup!
Returns a new instance with the specified SkipInfo for the given ad index.
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.
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 contentResumeOffsetUs: Long
The offset in microseconds which should be added to the content stream when resuming playback after the ad group.
durationsUs
val durationsUs: LongArray<Long>!
The durations of each ad in the ad group, in microseconds.
isPlaceholder
val isPlaceholder: Boolean
Whether this is an ignorable placeholder that must not be attempted to be played.
isServerSideInserted
val isServerSideInserted: Boolean
Whether this ad group is server-side inserted and part of the content stream.
mediaItems
@NullableType
val mediaItems: Array<@NullableType MediaItem!>!
The MediaItem instances for each ad in the ad group, or null if not yet known.
originalCount
val originalCount: Int
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.
skipInfos
@NullableType
val skipInfos: Array<@NullableType AdPlaybackState.SkipInfo!>!
The skip information for each ad in the ad group.
timeUs
val timeUs: Long
The time of the ad group in the Timeline.Period, in microseconds, or TIME_END_OF_SOURCE to indicate a postroll ad.