
When selecting progressive and HLS tracks, we currently check if we can either seek in the existing samples or are starting from the beginning of the stream. In both cases, we don't need to reload the stream and can continue reading. Seeking to the beginning isn't side-effect free though because it also sets the startTimeUs to zero. Whether a seek to the beginning is successful also depends on whether we already loaded a sample or not. This mean that the startTimeUs value is set (or not set) based on the speed of the Loader thread even for the same input starting from the beginning. This race condition means the actual samples we write to the stream may differ if the stream has initial samples with negative timestamps. We can avoid this race condition by checking if the queue is empty first, so that we only call seekTo if really needed. PiperOrigin-RevId: 546010951
ExoPlayer HLS module
Provides support for HTTP Live Streaming (HLS) content in ExoPlayer.
Getting the module
The easiest way to get the module is to add it as a gradle dependency:
implementation 'androidx.media3:media3-exoplayer-hls:1.X.X'
where 1.X.X
is the version, which must match the version of the other media
modules being used.
Alternatively, you can clone this GitHub project and depend on the module locally. Instructions for doing this can be found in the top level README.
Using the module
Adding a dependency to this module is all that's required to enable playback of
HLS media items added to ExoPlayer
in its default configuration. Internally,
DefaultMediaSourceFactory
will automatically detect the presence of the module
and convert an HLS MediaItem
into an HlsMediaSource
for playback.
Similarly, a DownloadManager
in its default configuration will use
DefaultDownloaderFactory
, which will automatically detect the presence of
the module and build HlsDownloader
instances to download HLS content.
For advanced playback use cases, applications can build HlsMediaSource
instances and pass them directly to the player. For advanced download use cases,
HlsDownloader
can be used directly.