@UnstableApi
public final class HlsMediaPlaylist extends HlsPlaylist


Represents an HLS media playlist.

Summary

Nested types

A media part.

@Documented
@Retention(value = RetentionPolicy.SOURCE)
@Target(value = TYPE_USE)
@IntDef(value = )
public annotation HlsMediaPlaylist.PlaylistType

Type of the playlist, as defined by #EXT-X-PLAYLIST-TYPE.

A rendition report for an alternative rendition defined in another media playlist.

Media segment reference.

The base for a Segment or a Part required for playback.

Server control attributes.

Constants

static final int
static final int
static final int

Public fields

final int

The discontinuity sequence number of the first media segment in the playlist, as defined by #EXT-X-DISCONTINUITY-SEQUENCE.

final long

The total duration of the playlist in microseconds.

final boolean

Whether the playlist contains the #EXT-X-DISCONTINUITY-SEQUENCE tag.

final boolean

Whether the playlist contains the #EXT-X-ENDLIST tag.

final boolean

Whether the startOffsetUs was explicitly defined by #EXT-X-START as a positive value or zero.

final boolean

Whether the playlist contains a #EXT-X-PROGRAM-DATE-TIME tag.

final long

The media sequence number of the first media segment in the playlist, as defined by #EXT-X-MEDIA-SEQUENCE.

final long

The target duration for segment parts, as defined by #EXT-X-PART-INF, or TIME_UNSET if undefined.

final int

The type of the playlist.

final boolean

Whether the start position should be precise, as defined by #EXT-X-START.

final @Nullable DrmInitData

Contains the CDM protection schemes used by segments in this playlist.

final Map<UriHlsMediaPlaylist.RenditionReport>

The rendition reports of alternative rendition playlists.

final List<HlsMediaPlaylist.Segment>

The list of segments in the playlist.

final HlsMediaPlaylist.ServerControl

The attributes of the #EXT-X-SERVER-CONTROL header.

final long

The start offset in microseconds from the beginning of the playlist, as defined by #EXT-X-START, or TIME_UNSET if undefined.

final long

If hasProgramDateTime is true, contains the datetime as microseconds since epoch.

final long

The target duration in microseconds, as defined by #EXT-X-TARGETDURATION.

final List<HlsMediaPlaylist.Part>

The list of parts at the end of the playlist for which the segment is not in the playlist yet.

final int

The compatibility version, as defined by #EXT-X-VERSION.

Public constructors

HlsMediaPlaylist(
    @HlsMediaPlaylist.PlaylistType int playlistType,
    String baseUri,
    List<String> tags,
    long startOffsetUs,
    boolean preciseStart,
    long startTimeUs,
    boolean hasDiscontinuitySequence,
    int discontinuitySequence,
    long mediaSequence,
    int version,
    long targetDurationUs,
    long partTargetDurationUs,
    boolean hasIndependentSegments,
    boolean hasEndTag,
    boolean hasProgramDateTime,
    @Nullable DrmInitData protectionSchemes,
    List<HlsMediaPlaylist.Segment> segments,
    List<HlsMediaPlaylist.Part> trailingParts,
    HlsMediaPlaylist.ServerControl serverControl,
    Map<UriHlsMediaPlaylist.RenditionReport> renditionReports
)

Constructs an instance.

Public methods

HlsMediaPlaylist
copy(List<StreamKey> streamKeys)

Returns a copy of the manifest including only the streams specified by the given keys.

HlsMediaPlaylist
copyWith(long startTimeUs, int discontinuitySequence)

Returns a playlist identical to this one except for the start time, the discontinuity sequence and hasDiscontinuitySequence values.

HlsMediaPlaylist

Returns a playlist identical to this one except that an end tag is added.

long

Returns the result of adding the duration of the playlist to its start time.

boolean

Returns whether this playlist is newer than other.

Inherited fields

From androidx.media3.exoplayer.hls.playlist.HlsPlaylist
final String

The base uri.

final boolean

Whether the media is formed of independent segments, as defined by the #EXT-X-INDEPENDENT-SEGMENTS tag.

final List<String>

The list of tags in the playlist.

Constants

PLAYLIST_TYPE_EVENT

public static final int PLAYLIST_TYPE_EVENT = 2

PLAYLIST_TYPE_UNKNOWN

public static final int PLAYLIST_TYPE_UNKNOWN = 0

PLAYLIST_TYPE_VOD

public static final int PLAYLIST_TYPE_VOD = 1

Public fields

discontinuitySequence

public final int discontinuitySequence

The discontinuity sequence number of the first media segment in the playlist, as defined by #EXT-X-DISCONTINUITY-SEQUENCE.

durationUs

public final long durationUs

The total duration of the playlist in microseconds.

hasDiscontinuitySequence

public final boolean hasDiscontinuitySequence

Whether the playlist contains the #EXT-X-DISCONTINUITY-SEQUENCE tag.

hasEndTag

public final boolean hasEndTag

Whether the playlist contains the #EXT-X-ENDLIST tag.

hasPositiveStartOffset

public final boolean hasPositiveStartOffset

Whether the startOffsetUs was explicitly defined by #EXT-X-START as a positive value or zero.

hasProgramDateTime

public final boolean hasProgramDateTime

Whether the playlist contains a #EXT-X-PROGRAM-DATE-TIME tag.

mediaSequence

public final long mediaSequence

The media sequence number of the first media segment in the playlist, as defined by #EXT-X-MEDIA-SEQUENCE.

partTargetDurationUs

public final long partTargetDurationUs

The target duration for segment parts, as defined by #EXT-X-PART-INF, or TIME_UNSET if undefined.

playlistType

@HlsMediaPlaylist.PlaylistType
public final int playlistType

The type of the playlist. See PlaylistType.

preciseStart

public final boolean preciseStart

Whether the start position should be precise, as defined by #EXT-X-START.

protectionSchemes

public final @Nullable DrmInitData protectionSchemes

Contains the CDM protection schemes used by segments in this playlist. Does not contain any key acquisition data. Null if none of the segments in the playlist is CDM-encrypted.

renditionReports

public final Map<UriHlsMediaPlaylist.RenditionReportrenditionReports

The rendition reports of alternative rendition playlists.

segments

public final List<HlsMediaPlaylist.Segmentsegments

The list of segments in the playlist.

serverControl

public final HlsMediaPlaylist.ServerControl serverControl

The attributes of the #EXT-X-SERVER-CONTROL header.

startOffsetUs

public final long startOffsetUs

The start offset in microseconds from the beginning of the playlist, as defined by #EXT-X-START, or TIME_UNSET if undefined. The value is guaranteed to be between 0 and durationUs, inclusive.

startTimeUs

public final long startTimeUs

If hasProgramDateTime is true, contains the datetime as microseconds since epoch. Otherwise, contains the aggregated duration of removed segments up to this snapshot of the playlist.

targetDurationUs

public final long targetDurationUs

The target duration in microseconds, as defined by #EXT-X-TARGETDURATION.

trailingParts

public final List<HlsMediaPlaylist.ParttrailingParts

The list of parts at the end of the playlist for which the segment is not in the playlist yet.

version

public final int version

The compatibility version, as defined by #EXT-X-VERSION.

Public constructors

HlsMediaPlaylist

public HlsMediaPlaylist(
    @HlsMediaPlaylist.PlaylistType int playlistType,
    String baseUri,
    List<String> tags,
    long startOffsetUs,
    boolean preciseStart,
    long startTimeUs,
    boolean hasDiscontinuitySequence,
    int discontinuitySequence,
    long mediaSequence,
    int version,
    long targetDurationUs,
    long partTargetDurationUs,
    boolean hasIndependentSegments,
    boolean hasEndTag,
    boolean hasProgramDateTime,
    @Nullable DrmInitData protectionSchemes,
    List<HlsMediaPlaylist.Segment> segments,
    List<HlsMediaPlaylist.Part> trailingParts,
    HlsMediaPlaylist.ServerControl serverControl,
    Map<UriHlsMediaPlaylist.RenditionReport> renditionReports
)

Constructs an instance.

Parameters
@HlsMediaPlaylist.PlaylistType int playlistType

See playlistType.

String baseUri

See baseUri.

List<String> tags

See tags.

long startOffsetUs

See startOffsetUs.

boolean preciseStart

See preciseStart.

long startTimeUs

See startTimeUs.

boolean hasDiscontinuitySequence

See hasDiscontinuitySequence.

int discontinuitySequence

See discontinuitySequence.

long mediaSequence

See mediaSequence.

int version

See version.

long targetDurationUs

See targetDurationUs.

long partTargetDurationUs

See partTargetDurationUs.

boolean hasIndependentSegments

See hasIndependentSegments.

boolean hasEndTag

See hasEndTag.

boolean hasProgramDateTime

See hasProgramDateTime.

@Nullable DrmInitData protectionSchemes

See protectionSchemes.

List<HlsMediaPlaylist.Segment> segments

See segments.

List<HlsMediaPlaylist.Part> trailingParts

See trailingParts.

HlsMediaPlaylist.ServerControl serverControl

See serverControl

Map<UriHlsMediaPlaylist.RenditionReport> renditionReports

See renditionReports.

Public methods

copy

public HlsMediaPlaylist copy(List<StreamKey> streamKeys)

Returns a copy of the manifest including only the streams specified by the given keys. If the manifest is unchanged then the instance may return itself.

Parameters
List<StreamKey> streamKeys

A non-empty list of stream keys.

Returns
HlsMediaPlaylist

The filtered manifest.

copyWith

public HlsMediaPlaylist copyWith(long startTimeUs, int discontinuitySequence)

Returns a playlist identical to this one except for the start time, the discontinuity sequence and hasDiscontinuitySequence values. The first two are set to the specified values, hasDiscontinuitySequence is set to true.

Parameters
long startTimeUs

The start time for the returned playlist.

int discontinuitySequence

The discontinuity sequence for the returned playlist.

Returns
HlsMediaPlaylist

An identical playlist including the provided discontinuity and timing information.

copyWithEndTag

public HlsMediaPlaylist copyWithEndTag()

Returns a playlist identical to this one except that an end tag is added. If an end tag is already present then the playlist will return itself.

getEndTimeUs

public long getEndTimeUs()

Returns the result of adding the duration of the playlist to its start time.

isNewerThan

public boolean isNewerThan(@Nullable HlsMediaPlaylist other)

Returns whether this playlist is newer than other.

Parameters
@Nullable HlsMediaPlaylist other

The playlist to compare.

Returns
boolean

Whether this playlist is newer than other.