public final class DashDownloader extends com.google.android.exoplayer2.offline.SegmentDownloader<DashManifest,RepresentationKey>
Except SegmentDownloader.getTotalSegments(), SegmentDownloader.getDownloadedSegments() and
SegmentDownloader.getDownloadedBytes(), this class isn't thread safe.
Example usage:
SimpleCache cache = new SimpleCache(downloadFolder, new NoOpCacheEvictor());
DefaultHttpDataSourceFactory factory = new DefaultHttpDataSourceFactory("ExoPlayer", null);
DownloaderConstructorHelper constructorHelper =
new DownloaderConstructorHelper(cache, factory);
DashDownloader dashDownloader = new DashDownloader(manifestUrl, constructorHelper);
// Select the first representation of the first adaptation set of the first period
dashDownloader.selectRepresentations(new RepresentationKey[] {new RepresentationKey(0, 0, 0)});
dashDownloader.download(new ProgressListener() {
{@literal @}Override
public void onDownloadProgress(Downloader downloader, float downloadPercentage,
long downloadedBytes) {
// Invoked periodically during the download.
}
});
// Access downloaded data using CacheDataSource
CacheDataSource cacheDataSource =
new CacheDataSource(cache, factory.createDataSource(), CacheDataSource.FLAG_BLOCK_ON_CACHE);
| Constructor and Description |
|---|
DashDownloader(android.net.Uri manifestUri,
com.google.android.exoplayer2.offline.DownloaderConstructorHelper constructorHelper) |
| Modifier and Type | Method and Description |
|---|---|
RepresentationKey[] |
getAllRepresentationKeys() |
protected DashManifest |
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,
DashManifest manifest,
RepresentationKey[] keys,
boolean allowIndexLoadErrors) |
public DashDownloader(android.net.Uri manifestUri,
com.google.android.exoplayer2.offline.DownloaderConstructorHelper constructorHelper)
SegmentDownloader.SegmentDownloader(Uri, DownloaderConstructorHelper)public RepresentationKey[] getAllRepresentationKeys() throws java.io.IOException
getAllRepresentationKeys in class com.google.android.exoplayer2.offline.SegmentDownloader<DashManifest,RepresentationKey>java.io.IOExceptionprotected DashManifest 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<DashManifest,RepresentationKey>java.io.IOExceptionprotected java.util.List<com.google.android.exoplayer2.offline.SegmentDownloader.Segment> getSegments(com.google.android.exoplayer2.upstream.DataSource dataSource,
DashManifest manifest,
RepresentationKey[] keys,
boolean allowIndexLoadErrors)
throws java.lang.InterruptedException,
java.io.IOException
getSegments in class com.google.android.exoplayer2.offline.SegmentDownloader<DashManifest,RepresentationKey>java.lang.InterruptedExceptionjava.io.IOException