HlsMediaSource
@UnstableApi
class HlsMediaSource : BaseMediaSource, HlsPlaylistTracker.PrimaryPlaylistListener
| kotlin.Any | ||
| ↳ | androidx.media3.exoplayer.source.BaseMediaSource | |
| ↳ | androidx.media3.exoplayer.hls.HlsMediaSource |
An HLS MediaSource.
Summary
Nested types |
|---|
|
Factory for |
@DocumentedThe types of metadata that can be extracted from HLS streams. |
Constants |
|
|---|---|
const Int |
Type for EMSG metadata in HLS streams. |
const Int |
Type for ID3 metadata in HLS streams. |
Public functions |
|
|---|---|
Boolean |
canUpdateMediaItem(mediaItem: MediaItem!)Returns whether the |
MediaPeriod! |
createPeriod(Returns a new |
Unit |
Throws any pending error encountered while loading or refreshing source information. |
Unit |
onPrimaryPlaylistRefreshed(mediaPlaylist: HlsMediaPlaylist!)Called when the primary playlist changes. |
Unit |
releasePeriod(mediaPeriod: MediaPeriod!)Releases the period. |
synchronized Unit |
updateMediaItem(mediaItem: MediaItem!)Updates the |
Protected functions |
|
|---|---|
Unit |
prepareSourceInternal(mediaTransferListener: TransferListener?)Starts source preparation and enables the source, see |
Unit |
Releases the source, see |
Inherited functions |
||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
||||||||||||||||||||||||||||||||||||||||
Constants
Public functions
canUpdateMediaItem
fun canUpdateMediaItem(mediaItem: MediaItem!): Boolean
Returns whether the MediaItem for this source can be updated with the provided item.
Should not be called directly from application code.
This method must be called on the application thread.
| Returns | |
|---|---|
Boolean |
Whether the source can be updated using this item. |
createPeriod
fun createPeriod(
id: MediaSource.MediaPeriodId!,
allocator: Allocator!,
startPositionUs: Long
): MediaPeriod!
Returns a new MediaPeriod identified by periodId.
Should not be called directly from application code.
This method must be called on the playback thread and only if the source is enabled.
| Parameters | |
|---|---|
id: MediaSource.MediaPeriodId! |
The identifier of the period. |
allocator: Allocator! |
An |
startPositionUs: Long |
The expected start position, in microseconds. |
| Returns | |
|---|---|
MediaPeriod! |
A new |
maybeThrowSourceInfoRefreshError
fun maybeThrowSourceInfoRefreshError(): Unit
Throws any pending error encountered while loading or refreshing source information.
Should not be called directly from application code.
This method must be called on the playback thread and only after prepareSource.
| Throws | |
|---|---|
java.io.IOException |
onPrimaryPlaylistRefreshed
fun onPrimaryPlaylistRefreshed(mediaPlaylist: HlsMediaPlaylist!): Unit
Called when the primary playlist changes.
| Parameters | |
|---|---|
mediaPlaylist: HlsMediaPlaylist! |
The primary playlist new snapshot. |
releasePeriod
fun releasePeriod(mediaPeriod: MediaPeriod!): Unit
Releases the period.
Should not be called directly from application code.
This method must be called on the playback thread.
| Parameters | |
|---|---|
mediaPeriod: MediaPeriod! |
The period to release. |
updateMediaItem
synchronized fun updateMediaItem(mediaItem: MediaItem!): Unit
Updates the MediaItem for this source.
Should not be called directly from application code.
This method must be called on the playback thread and only if canUpdateMediaItem returns true for the new MediaItem.
Protected functions
prepareSourceInternal
protected fun prepareSourceInternal(mediaTransferListener: TransferListener?): Unit
Starts source preparation and enables the source, see prepareSource. This method is called at most once until the next call to releaseSourceInternal.
This method is called on the playback thread.
| Parameters | |
|---|---|
mediaTransferListener: TransferListener? |
The transfer listener which should be informed of any media data transfers. May be null if no listener is available. Note that this listener should usually be only informed of transfers related to the media loads and not of auxiliary loads for manifests and other data. |
releaseSourceInternal
protected fun releaseSourceInternal(): Unit
Releases the source, see releaseSource. This method is called exactly once after each call to prepareSourceInternal.
This method is called on the playback thread.