public final class AdPlaybackState
extends java.lang.Object
Instances are immutable. Call the with* methods to get new instances that have the
required changes.
| Modifier and Type | Class and Description |
|---|---|
static class |
AdPlaybackState.AdGroup
Represents a group of ads, with information about their states.
|
static interface |
AdPlaybackState.AdState
Represents the state of an ad in an ad group.
|
| Modifier and Type | Field and Description |
|---|---|
static int |
AD_STATE_AVAILABLE
State for an ad that has a URL but has not yet been played.
|
static int |
AD_STATE_ERROR
State for an ad that could not be loaded.
|
static int |
AD_STATE_PLAYED
State for an ad that was played in full.
|
static int |
AD_STATE_SKIPPED
State for an ad that was skipped.
|
static int |
AD_STATE_UNAVAILABLE
State for an ad that does not yet have a URL.
|
int |
adGroupCount
The number of ad groups.
|
AdPlaybackState.AdGroup[] |
adGroups
The ad groups.
|
long[] |
adGroupTimesUs
The times of ad groups, in microseconds.
|
long |
adResumePositionUs
The position offset in the first unplayed ad at which to begin playback, in microseconds.
|
long |
contentDurationUs
The content duration in microseconds, if known.
|
static AdPlaybackState |
NONE
Ad playback state with no ads.
|
| Constructor and Description |
|---|
AdPlaybackState(long... adGroupTimesUs)
Creates a new ad playback state with the specified ad group times.
|
| Modifier and Type | Method and Description |
|---|---|
int |
getAdGroupIndexAfterPositionUs(long positionUs)
Returns the index of the next ad group after
positionUs that has ads remaining to be
played. |
int |
getAdGroupIndexForPositionUs(long positionUs)
Returns the index of the ad group at or before
positionUs, if that ad group is
unplayed. |
AdPlaybackState |
withAdCount(int adGroupIndex,
int adCount)
Returns an instance with the number of ads in
adGroupIndex resolved to adCount. |
AdPlaybackState |
withAdDurationsUs(long[][] adDurationUs)
Returns an instance with the specified ad durations, in microseconds.
|
AdPlaybackState |
withAdLoadError(int adGroupIndex,
int adIndexInAdGroup)
Returns an instance with the specified ad marked as having a load error.
|
AdPlaybackState |
withAdResumePositionUs(long adResumePositionUs)
Returns an instance with the specified ad resume position, in microseconds.
|
AdPlaybackState |
withAdUri(int adGroupIndex,
int adIndexInAdGroup,
android.net.Uri uri)
Returns an instance with the specified ad URI.
|
AdPlaybackState |
withContentDurationUs(long contentDurationUs)
Returns an instance with the specified content duration, in microseconds.
|
AdPlaybackState |
withPlayedAd(int adGroupIndex,
int adIndexInAdGroup)
Returns an instance with the specified ad marked as played.
|
AdPlaybackState |
withSkippedAd(int adGroupIndex,
int adIndexInAdGroup)
Returns an instance with the specified ad marked as skipped.
|
AdPlaybackState |
withSkippedAdGroup(int adGroupIndex)
Returns an instance with all ads in the specified ad group skipped (except for those already
marked as played or in the error state).
|
public static final int AD_STATE_UNAVAILABLE
public static final int AD_STATE_AVAILABLE
public static final int AD_STATE_SKIPPED
public static final int AD_STATE_PLAYED
public static final int AD_STATE_ERROR
public static final AdPlaybackState NONE
public final int adGroupCount
public final long[] adGroupTimesUs
C.TIME_END_OF_SOURCE indicates a postroll ad.public final AdPlaybackState.AdGroup[] adGroups
public final long adResumePositionUs
public final long contentDurationUs
C.TIME_UNSET otherwise.public AdPlaybackState(long... adGroupTimesUs)
adGroupTimesUs - The times of ad groups in microseconds. A final element with the value
C.TIME_END_OF_SOURCE indicates that there is a postroll ad.public int getAdGroupIndexForPositionUs(long positionUs)
positionUs, if that ad group is
unplayed. Returns C.INDEX_UNSET if the ad group at or before positionUs has no
ads remaining to be played, or if there is no such ad group.positionUs - The position at or before which to find an ad group, in microseconds.C.INDEX_UNSET.public int getAdGroupIndexAfterPositionUs(long positionUs)
positionUs that has ads remaining to be
played. Returns C.INDEX_UNSET if there is no such ad group.positionUs - The position after which to find an ad group, in microseconds.C.INDEX_UNSET.@CheckResult public AdPlaybackState withAdCount(int adGroupIndex, int adCount)
adGroupIndex resolved to adCount.
The ad count must be greater than zero.@CheckResult public AdPlaybackState withAdUri(int adGroupIndex, int adIndexInAdGroup, android.net.Uri uri)
@CheckResult public AdPlaybackState withPlayedAd(int adGroupIndex, int adIndexInAdGroup)
@CheckResult public AdPlaybackState withSkippedAd(int adGroupIndex, int adIndexInAdGroup)
@CheckResult public AdPlaybackState withAdLoadError(int adGroupIndex, int adIndexInAdGroup)
@CheckResult public AdPlaybackState withSkippedAdGroup(int adGroupIndex)
@CheckResult public AdPlaybackState withAdDurationsUs(long[][] adDurationUs)
@CheckResult public AdPlaybackState withAdResumePositionUs(long adResumePositionUs)
@CheckResult public AdPlaybackState withContentDurationUs(long contentDurationUs)