HlsDownloader
@UnstableApi
class HlsDownloader : SegmentDownloader
| kotlin.Any | ||
| ↳ | androidx.media3.exoplayer.offline.SegmentDownloader | |
| ↳ | androidx.media3.exoplayer.hls.offline.HlsDownloader |
A downloader for HLS streams.
Example usage:
SimpleCache cache = new SimpleCache(downloadFolder, new NoOpCacheEvictor(), databaseProvider); CacheDataSource.Factory cacheDataSourceFactory = new CacheDataSource.Factory() .setCache(cache) .setUpstreamDataSourceFactory(new DefaultHttpDataSource.Factory()); // Create a downloader for the first variant in a multivariant playlist. HlsDownloader hlsDownloader = new HlsDownloader.Factory(cacheDataSourceFactory) .create(new MediaItem.Builder() .setUri(playlistUri) .setStreamKeys( ImmutableList.of( new StreamKey(HlsMultivariantPlaylist.GROUP_INDEX_VARIANT, 0))) .build()); // Perform the download. hlsDownloader.download(progressListener); // Use the downloaded data for playback. HlsMediaSource mediaSource = new HlsMediaSource.Factory(cacheDataSourceFactory).createMediaSource(mediaItem);
Summary
Nested types |
|---|
|
A factory for |
Public constructors |
|---|
This function is deprecated. Use |
This function is deprecated. Use |
Protected functions |
|
|---|---|
(Mutable)List<SegmentDownloader.Segment!>! |
getSegments(Returns a list of all downloadable |
Inherited Constants |
||
|---|---|---|
|
Inherited functions |
||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Inherited properties |
|---|
Public constructors
HlsDownloader
HlsDownloader(
mediaItem: MediaItem!,
cacheDataSourceFactory: CacheDataSource.Factory!
)
HlsDownloader
HlsDownloader(
mediaItem: MediaItem!,
cacheDataSourceFactory: CacheDataSource.Factory!,
executor: Executor!
)
Protected functions
getSegments
protected fun getSegments(
dataSource: DataSource!,
manifest: HlsPlaylist!,
removing: Boolean
): (Mutable)List<SegmentDownloader.Segment!>!
Returns a list of all downloadable Segments for a given manifest. Any required data should be loaded using getManifest or execute.
| Parameters | |
|---|---|
dataSource: DataSource! |
The |
manifest: HlsPlaylist! |
The manifest containing the segments. |
removing: Boolean |
Whether the segments are being obtained as part of a removal. If true then a partial segment list is returned in the case that a load error prevents all segments from being listed. If false then an |
| Returns | |
|---|---|
(Mutable)List<SegmentDownloader.Segment!>! |
The list of downloadable |
| Throws | |
|---|---|
java.io.IOException |
Thrown if |
java.lang.InterruptedException |