public static final class Timeline.Period extends 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. |
Object |
id
An identifier for the period.
|
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 unplayed ad group after
positionUs . |
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 |
getPlayedAdCount(int adGroupIndex)
Returns the number of ads that have been played in the specified ad group in the period.
|
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(Object id,
Object uid,
int windowIndex,
long durationUs,
long positionInWindowUs)
Sets the data held by this period.
|
Timeline.Period |
set(Object id,
Object uid,
int windowIndex,
long durationUs,
long positionInWindowUs,
long[] adGroupTimesUs,
int[] adCounts,
int[] adsLoadedCounts,
int[] adsPlayedCounts,
long[][] adDurationsUs,
long adResumePositionUs)
Sets the data held by this period.
|
public Object id
public Object uid
public int windowIndex
public long durationUs
C.TIME_UNSET
if unknown.public Timeline.Period set(Object id, 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(Object id, Object uid, int windowIndex, long durationUs, long positionInWindowUs, long[] adGroupTimesUs, int[] adCounts, int[] adsLoadedCounts, int[] adsPlayedCounts, long[][] adDurationsUs, long adResumePositionUs)
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.adGroupTimesUs
- The times of ad groups relative to the start of the period, in
microseconds. A final element with the value C.TIME_END_OF_SOURCE
indicates that
the period has a postroll ad.adCounts
- The number of ads in each ad group. An element may be C.LENGTH_UNSET
if the number of ads is not yet known.adsLoadedCounts
- The number of ads loaded so far in each ad group.adsPlayedCounts
- The number of ads played so far in each ad group.adDurationsUs
- The duration of each ad in each ad group, in microseconds. An element
may be C.TIME_UNSET
if the duration is not yet known.adResumePositionUs
- The position offset in the first unplayed ad at which to begin
playback, in microseconds.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 getPlayedAdCount(int adGroupIndex)
adGroupIndex
- The ad group index.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 before positionUs
has been
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
. 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()