public static final class Timeline.Period
extends java.lang.Object
Timeline. A period defines a single logical piece
of media, for example a media file. It may also define groups of ads inserted into the media,
along with information about whether those ads have been loaded and played.
The figure below shows some of the information defined by a period, as well as how this
information relates to a corresponding Timeline.Window in the timeline.
| Modifier and Type | Field and Description |
|---|---|
long |
durationUs
The duration of this period in microseconds, or
C.TIME_UNSET if unknown. |
java.lang.Object |
id
An identifier for the period.
|
java.lang.Object |
uid
A unique identifier for the period.
|
int |
windowIndex
The index of the window to which this period belongs.
|
| Constructor and Description |
|---|
Period() |
| Modifier and Type | Method and Description |
|---|---|
int |
getAdCountInAdGroup(int adGroupIndex)
Returns the number of ads in the ad group at index
adGroupIndex, or
C.LENGTH_UNSET if not yet known. |
long |
getAdDurationUs(int adGroupIndex,
int adIndexInAdGroup)
Returns the duration of the ad at index
adIndexInAdGroup in the ad group at
adGroupIndex, in microseconds, or C.TIME_UNSET if not yet known. |
int |
getAdGroupCount()
Returns the number of ad groups in the period.
|
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. |
long |
getAdGroupTimeUs(int adGroupIndex)
Returns the time of the ad group at index
adGroupIndex in the period, in
microseconds. |
long |
getAdResumePositionUs()
Returns the position offset in the first unplayed ad at which to begin playback, in
microseconds.
|
long |
getDurationMs()
Returns the duration of the period in milliseconds, or
C.TIME_UNSET if unknown. |
long |
getDurationUs()
Returns the duration of this period in microseconds, or
C.TIME_UNSET if unknown. |
int |
getFirstAdIndexToPlay(int adGroupIndex)
Returns the index of the first ad in the specified ad group that should be played, or the
number of ads in the ad group if no ads should be played.
|
int |
getNextAdIndexToPlay(int adGroupIndex,
int lastPlayedAdIndex)
Returns the index of the next ad in the specified ad group that should be played after
playing
adIndexInAdGroup, or the number of ads in the ad group if no later ads should
be played. |
long |
getPositionInWindowMs()
Returns the position of the start of this period relative to the start of the window to which
it belongs, in milliseconds.
|
long |
getPositionInWindowUs()
Returns the position of the start of this period relative to the start of the window to which
it belongs, in microseconds.
|
boolean |
hasPlayedAdGroup(int adGroupIndex)
Returns whether the ad group at index
adGroupIndex has been played. |
boolean |
isAdAvailable(int adGroupIndex,
int adIndexInAdGroup)
Returns whether the URL for the specified ad is known.
|
Timeline.Period |
set(java.lang.Object id,
java.lang.Object uid,
int windowIndex,
long durationUs,
long positionInWindowUs)
Sets the data held by this period.
|
Timeline.Period |
set(java.lang.Object id,
java.lang.Object uid,
int windowIndex,
long durationUs,
long positionInWindowUs,
AdPlaybackState adPlaybackState)
Sets the data held by this period.
|
public java.lang.Object id
public java.lang.Object uid
public int windowIndex
public long durationUs
C.TIME_UNSET if unknown.public Timeline.Period set(java.lang.Object id, java.lang.Object uid, int windowIndex, long durationUs, long positionInWindowUs)
id - An identifier for the period. Not necessarily unique.uid - A unique identifier for the period.windowIndex - The index of the window to which this period belongs.durationUs - The duration of this period in microseconds, or C.TIME_UNSET if
unknown.positionInWindowUs - The position of the start of this period relative to the start of
the window to which it belongs, in milliseconds. May be negative if the start of the
period is not within the window.public Timeline.Period set(java.lang.Object id, java.lang.Object uid, int windowIndex, long durationUs, long positionInWindowUs, AdPlaybackState adPlaybackState)
id - An identifier for the period. Not necessarily unique.uid - A unique identifier for the period.windowIndex - The index of the window to which this period belongs.durationUs - The duration of this period in microseconds, or C.TIME_UNSET if
unknown.positionInWindowUs - The position of the start of this period relative to the start of
the window to which it belongs, in milliseconds. May be negative if the start of the
period is not within the window.adPlaybackState - The state of the period's ads, or AdPlaybackState.NONE if
there are no ads.public long getDurationMs()
C.TIME_UNSET if unknown.public long getDurationUs()
C.TIME_UNSET if unknown.public long getPositionInWindowMs()
public long getPositionInWindowUs()
public int getAdGroupCount()
public long getAdGroupTimeUs(int adGroupIndex)
adGroupIndex in the period, in
microseconds.adGroupIndex - The ad group index.public int getFirstAdIndexToPlay(int adGroupIndex)
adGroupIndex - The ad group index.public int getNextAdIndexToPlay(int adGroupIndex,
int lastPlayedAdIndex)
adIndexInAdGroup, or the number of ads in the ad group if no later ads should
be played.adGroupIndex - The ad group index.lastPlayedAdIndex - The last played ad index in the ad group.public boolean hasPlayedAdGroup(int adGroupIndex)
adGroupIndex has been played.adGroupIndex - The ad group index.adGroupIndex has been played.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.public int getAdCountInAdGroup(int adGroupIndex)
adGroupIndex, or
C.LENGTH_UNSET if not yet known.adGroupIndex - The ad group index.C.LENGTH_UNSET if not yet known.public boolean isAdAvailable(int adGroupIndex,
int adIndexInAdGroup)
adGroupIndex - The ad group index.adIndexInAdGroup - The ad index in the ad group.public long getAdDurationUs(int adGroupIndex,
int adIndexInAdGroup)
adIndexInAdGroup in the ad group at
adGroupIndex, in microseconds, or C.TIME_UNSET if not yet known.adGroupIndex - The ad group index.adIndexInAdGroup - The ad index in the ad group.C.TIME_UNSET if not yet known.public long getAdResumePositionUs()