docs/doc/reference/com/google/android/exoplayer2/source/ads/AdPlaybackState.AdGroup.html
Package com.google.android.exoplayer2.source.ads
All Implemented Interfaces:BundleableEnclosing class:AdPlaybackState
public static final classAdPlaybackState.AdGroupextends[Object](https://developer.android.com/reference/java/lang/Object.html "class or interface in java.lang")implements[Bundleable](../../Bundleable.html "interface in com.google.android.exoplayer2")
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.
-
Bundleable.Creator<T extends Bundleable>
Fields | Modifier and Type | Field | Description |
| --- | --- | --- |
| long | contentResumeOffsetUs |
The offset in microseconds which should be added to the content stream when resuming playback after the ad group.
|
| int | count |
The number of ads in the ad group, or C.LENGTH_UNSET if unknown.
|
| static Bundleable.Creator<AdPlaybackState.AdGroup> | CREATOR |
Object that can restore AdPlaybackState.AdGroup from a Bundle.
|
| long[] | durationsUs |
The durations of each ad in the ad group, in microseconds.
|
| boolean | isServerSideInserted |
Whether this ad group is server-side inserted and part of the content stream.
|
| int | originalCount |
The original number of ads in the ad group in case the ad group is only partially available, or C.LENGTH_UNSET if unknown.
|
| @com.google.android.exoplayer2.source.ads.AdPlaybackState.AdState int[] | states |
The state of each ad in the ad group.
|
| long | timeUs |
The time of the ad group in the Timeline.Period, in microseconds, or C.TIME_END_OF_SOURCE to indicate a postroll ad.
|
| @NullableType Uri[] | uris |
The URI of each ad in the ad group.
|
Constructors | Constructor | Description |
| --- | --- |
| AdGroup(long timeUs) |
Creates a new ad group with an unspecified number of ads.
|
All Methods Instance Methods Concrete Methods | Modifier and Type | Method | Description |
| --- | --- | --- |
| boolean | equals(Object o) | |
| int | getFirstAdIndexToPlay() |
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(int lastPlayedAdIndex) |
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.
|
| int | hashCode() | |
| boolean | hasUnplayedAds() |
Returns whether the ad group has at least one ad that is neither played, skipped, nor failed.
|
| boolean | shouldPlayAdGroup() |
Returns whether the ad group has at least one ad that should be played.
|
| Bundle | toBundle() |
Returns a Bundle representing the information stored in this object.
|
| AdPlaybackState.AdGroup | withAdCount(int count) |
Returns a new instance with the ad count set to count.
|
| AdPlaybackState.AdGroup | withAdDurationsUs(long[] durationsUs) |
Returns a new instance with the specified ad durations, in microseconds.
|
| AdPlaybackState.AdGroup | withAdState(@com.google.android.exoplayer2.source.ads.AdPlaybackState.AdState int state, int index) |
Returns a new instance with the specified ad set to the specified state.
|
| AdPlaybackState.AdGroup | withAdUri(Uri uri, int index) |
Returns a new instance with the specified uri set for the specified ad, and the ad marked as AdPlaybackState.AD_STATE_AVAILABLE.
|
| AdPlaybackState.AdGroup | withAllAdsReset() |
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 | withAllAdsSkipped() |
Returns an instance with all unavailable and available ads marked as skipped.
|
| AdPlaybackState.AdGroup | withContentResumeOffsetUs(long contentResumeOffsetUs) |
Returns an instance with the specified contentResumeOffsetUs.
|
| AdPlaybackState.AdGroup | withIsServerSideInserted(boolean isServerSideInserted) |
Returns an instance with the specified value for isServerSideInserted.
|
| AdPlaybackState.AdGroup | withLastAdRemoved() |
Removes the last ad from the ad group.
|
| AdPlaybackState.AdGroup | withOriginalAdCount(int originalCount) |
Returns an instance with the specified value for originalCount.
|
| AdPlaybackState.AdGroup | withTimeUs(long timeUs) |
Returns a new instance with the timeUs set to the specified value.
|
-
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
public final long timeUs
The time of the ad group in the Timeline.Period, in microseconds, or C.TIME_END_OF_SOURCE to indicate a postroll ad.
-
public final int count
The number of ads in the ad group, or C.LENGTH_UNSET if unknown.
-
public final int originalCount
The original number of ads in the ad group in case the ad group is only partially available, or C.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.
-
public final @NullableType[Uri](https://developer.android.com/reference/android/net/Uri.html "class or interface in android.net")[] uris
The URI of each ad in the ad group.
-
[@AdState](AdPlaybackState.AdState.html "annotation in com.google.android.exoplayer2.source.ads")public final @com.google.android.exoplayer2.source.ads.AdPlaybackState.AdState int[] states
The state of each ad in the ad group.
-
public final long[] durationsUs
The durations of each ad in the ad group, in microseconds.
-
public final long contentResumeOffsetUs
The offset in microseconds which should be added to the content stream when resuming playback after the ad group.
-
public final boolean isServerSideInserted
Whether this ad group is server-side inserted and part of the content stream.
-
public static final[Bundleable.Creator](../../Bundleable.Creator.html "interface in com.google.android.exoplayer2")<[AdPlaybackState.AdGroup](AdPlaybackState.AdGroup.html "class in com.google.android.exoplayer2.source.ads")> CREATOR
Object that can restore AdPlaybackState.AdGroup from a Bundle.
-
public AdGroup(long timeUs)
Creates a new ad group with an unspecified number of ads.
Parameters:timeUs - The time of the ad group in the Timeline.Period, in microseconds, or C.TIME_END_OF_SOURCE to indicate a postroll ad.
-
public int getFirstAdIndexToPlay()
Returns the index of the first ad in the ad group that should be played, or count if no ads should be played.
-
public int getNextAdIndexToPlay(@IntRange(from=-1L)
int lastPlayedAdIndex)
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.
-
public boolean shouldPlayAdGroup()
Returns whether the ad group has at least one ad that should be played.
-
public boolean hasUnplayedAds()
Returns whether the ad group has at least one ad that is neither played, skipped, nor failed.
-
public boolean equals(@Nullable[Object](https://developer.android.com/reference/java/lang/Object.html "class or interface in java.lang")o)
Overrides:equals in class Object
-
public int hashCode()
Overrides:hashCode in class Object
-
@CheckResult
public[AdPlaybackState.AdGroup](AdPlaybackState.AdGroup.html "class in com.google.android.exoplayer2.source.ads")withTimeUs(long timeUs)
Returns a new instance with the timeUs set to the specified value.
-
@CheckResult
public[AdPlaybackState.AdGroup](AdPlaybackState.AdGroup.html "class in com.google.android.exoplayer2.source.ads")withAdCount(int count)
Returns a new instance with the ad count set to count.
-
@CheckResult
public[AdPlaybackState.AdGroup](AdPlaybackState.AdGroup.html "class in com.google.android.exoplayer2.source.ads")withAdUri([Uri](https://developer.android.com/reference/android/net/Uri.html "class or interface in android.net")uri,
@IntRange(from=0L)
int index)
Returns a new instance with the specified uri set for the specified ad, and the ad marked as AdPlaybackState.AD_STATE_AVAILABLE.
-
@CheckResult
public[AdPlaybackState.AdGroup](AdPlaybackState.AdGroup.html "class in com.google.android.exoplayer2.source.ads")withAdState([@AdState](AdPlaybackState.AdState.html "annotation in com.google.android.exoplayer2.source.ads")@com.google.android.exoplayer2.source.ads.AdPlaybackState.AdState int state,
@IntRange(from=0L)
int index)
Returns a new instance with the specified ad set to the specified state. The ad specified must currently either be in AdPlaybackState.AD_STATE_UNAVAILABLE or AdPlaybackState.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.
-
@CheckResult
public[AdPlaybackState.AdGroup](AdPlaybackState.AdGroup.html "class in com.google.android.exoplayer2.source.ads")withAdDurationsUs(long[] durationsUs)
Returns a new instance with the specified ad durations, in microseconds.
-
@CheckResult
public[AdPlaybackState.AdGroup](AdPlaybackState.AdGroup.html "class in com.google.android.exoplayer2.source.ads")withContentResumeOffsetUs(long contentResumeOffsetUs)
Returns an instance with the specified contentResumeOffsetUs.
-
@CheckResult
public[AdPlaybackState.AdGroup](AdPlaybackState.AdGroup.html "class in com.google.android.exoplayer2.source.ads")withIsServerSideInserted(boolean isServerSideInserted)
Returns an instance with the specified value for isServerSideInserted.
-
public[AdPlaybackState.AdGroup](AdPlaybackState.AdGroup.html "class in com.google.android.exoplayer2.source.ads")withOriginalAdCount(int originalCount)
Returns an instance with the specified value for originalCount.
-
public[AdPlaybackState.AdGroup](AdPlaybackState.AdGroup.html "class in com.google.android.exoplayer2.source.ads")withLastAdRemoved()
Removes the last ad from the ad group.
-
@CheckResult
public[AdPlaybackState.AdGroup](AdPlaybackState.AdGroup.html "class in com.google.android.exoplayer2.source.ads")withAllAdsSkipped()
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.
-
@CheckResult
public[AdPlaybackState.AdGroup](AdPlaybackState.AdGroup.html "class in com.google.android.exoplayer2.source.ads")withAllAdsReset()
Returns an instance with all ads in final states (played, skipped, error) reset to either available or unavailable, which allows to play them again.
-
public[Bundle](https://developer.android.com/reference/android/os/Bundle.html "class or interface in android.os")toBundle()
Description copied from interface: Bundleable
Returns a Bundle representing the information stored in this object.
Specified by:toBundle in interface Bundleable