public final class HlsDownloader extends com.google.android.exoplayer2.offline.SegmentDownloader<HlsPlaylist,RenditionKey>
Example usage:
SimpleCache cache = new SimpleCache(downloadFolder, new NoOpCacheEvictor());
DefaultHttpDataSourceFactory factory = new DefaultHttpDataSourceFactory("ExoPlayer", null);
DownloaderConstructorHelper constructorHelper =
new DownloaderConstructorHelper(cache, factory);
// Create a downloader for the first variant in a master playlist.
HlsDownloader hlsDownloader =
new HlsDownloader(
playlistUri,
Collections.singletonList(new RenditionKey(RenditionKey.TYPE_VARIANT, 0)),
constructorHelper);
// Perform the download.
hlsDownloader.download();
// Access downloaded data using CacheDataSource
CacheDataSource cacheDataSource =
new CacheDataSource(cache, factory.createDataSource(), CacheDataSource.FLAG_BLOCK_ON_CACHE);
| Constructor and Description |
|---|
HlsDownloader(android.net.Uri playlistUri,
java.util.List<RenditionKey> renditionKeys,
com.google.android.exoplayer2.offline.DownloaderConstructorHelper constructorHelper) |
| Modifier and Type | Method and Description |
|---|---|
protected HlsPlaylist |
getManifest(com.google.android.exoplayer2.upstream.DataSource dataSource,
android.net.Uri uri) |
protected java.util.List<com.google.android.exoplayer2.offline.SegmentDownloader.Segment> |
getSegments(com.google.android.exoplayer2.upstream.DataSource dataSource,
HlsPlaylist playlist,
boolean allowIncompleteList) |
public HlsDownloader(android.net.Uri playlistUri,
java.util.List<RenditionKey> renditionKeys,
com.google.android.exoplayer2.offline.DownloaderConstructorHelper constructorHelper)
playlistUri - The Uri of the playlist to be downloaded.renditionKeys - Keys defining which renditions in the playlist should be selected for
download. If empty, all renditions are downloaded.constructorHelper - A DownloaderConstructorHelper instance.protected HlsPlaylist getManifest(com.google.android.exoplayer2.upstream.DataSource dataSource, android.net.Uri uri) throws java.io.IOException
getManifest in class com.google.android.exoplayer2.offline.SegmentDownloader<HlsPlaylist,RenditionKey>java.io.IOExceptionprotected java.util.List<com.google.android.exoplayer2.offline.SegmentDownloader.Segment> getSegments(com.google.android.exoplayer2.upstream.DataSource dataSource,
HlsPlaylist playlist,
boolean allowIncompleteList)
throws java.io.IOException
getSegments in class com.google.android.exoplayer2.offline.SegmentDownloader<HlsPlaylist,RenditionKey>java.io.IOException