Class HlsDownloader

  • All Implemented Interfaces:

    public final class HlsDownloader
    extends SegmentDownloader<HlsPlaylist>
    Deprecated. is deprecated. Please migrate to androidx.media3 (which contains the same ExoPlayer code). See the migration guide for more details, including a script to help with the migration.
    A downloader for HLS streams.

    Example usage:

     SimpleCache cache = new SimpleCache(downloadFolder, new NoOpCacheEvictor(), databaseProvider);
     CacheDataSource.Factory cacheDataSourceFactory =
         new CacheDataSource.Factory()
             .setUpstreamDataSourceFactory(new DefaultHttpDataSource.Factory());
     // Create a downloader for the first variant in a multivariant playlist.
     HlsDownloader hlsDownloader =
         new HlsDownloader(
             new MediaItem.Builder()
                         new StreamKey(HlsMultivariantPlaylist.GROUP_INDEX_VARIANT, 0)))
     // Perform the download.;
     // Use the downloaded data for playback.
     HlsMediaSource mediaSource =
         new HlsMediaSource.Factory(cacheDataSourceFactory).createMediaSource(mediaItem);