public static final class AdPlaybackState.AdGroup extends Object
Instances are immutable. Call the with*
methods to get new instances that have the
required changes.
Modifier and Type | Field and Description |
---|---|
int |
count
The number of ads in the ad group, or
C.LENGTH_UNSET if unknown. |
long[] |
durationsUs
The durations of each ad in the ad group, in microseconds.
|
int[] |
states
The state of each ad in the ad group.
|
Uri[] |
uris
The URI of each ad in the ad group.
|
Constructor and Description |
---|
AdGroup()
Creates a new ad group with an unspecified number of ads.
|
Modifier and Type | Method and 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 still needs to be played.
|
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(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 |
withAllAdsSkipped()
Returns an instance with all unavailable and available ads marked as skipped.
|
public final int count
C.LENGTH_UNSET
if unknown.public final Uri[] uris
@AdPlaybackState.AdState public final int[] states
public final long[] durationsUs
public AdGroup()
public int getFirstAdIndexToPlay()
count
if
no ads should be played.public int getNextAdIndexToPlay(int lastPlayedAdIndex)
lastPlayedAdIndex
, or count
if no later ads should be played.public boolean hasUnplayedAds()
@CheckResult public AdPlaybackState.AdGroup withAdCount(int count)
count
. This method may only be called
if this instance's ad count has not yet been specified.@CheckResult public AdPlaybackState.AdGroup withAdUri(Uri uri, int index)
uri
set for the specified ad, and the ad
marked as AdPlaybackState.AD_STATE_AVAILABLE
. The specified ad must currently be in AdPlaybackState.AD_STATE_UNAVAILABLE
, which is the default state.
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 withAdState(@AdPlaybackState.AdState int state, int index)
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 withAdDurationsUs(long[] durationsUs)
@CheckResult public AdPlaybackState.AdGroup withAllAdsSkipped()