Class DashDownloader
- java.lang.Object
-
- com.google.android.exoplayer2.offline.SegmentDownloader<DashManifest>
-
- com.google.android.exoplayer2.source.dash.offline.DashDownloader
-
- All Implemented Interfaces:
Downloader
@Deprecated public final class DashDownloader extends SegmentDownloader<DashManifest>
Deprecated.com.google.android.exoplayer2 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 DASH 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 representation of the first adaptation set of the first // period. DashDownloader dashDownloader = new DashDownloader( new MediaItem.Builder() .setUri(manifestUrl) .setStreamKeys(Collections.singletonList(new StreamKey(0, 0, 0))) .build(), cacheDataSourceFactory); // Perform the download. dashDownloader.download(progressListener); // Use the downloaded data for playback. DashMediaSource mediaSource = new DashMediaSource.Factory(cacheDataSourceFactory).createMediaSource(mediaItem);
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.google.android.exoplayer2.offline.SegmentDownloader
SegmentDownloader.Segment
-
Nested classes/interfaces inherited from interface com.google.android.exoplayer2.offline.Downloader
Downloader.ProgressListener
-
-
Field Summary
-
Fields inherited from class com.google.android.exoplayer2.offline.SegmentDownloader
DEFAULT_MAX_MERGED_SEGMENT_START_TIME_DIFF_MS
-
-
Constructor Summary
Constructors Constructor Description DashDownloader(MediaItem mediaItem, CacheDataSource.Factory cacheDataSourceFactory)
Deprecated.Creates a new instance.DashDownloader(MediaItem mediaItem, CacheDataSource.Factory cacheDataSourceFactory, Executor executor)
Deprecated.Creates a new instance.DashDownloader(MediaItem mediaItem, ParsingLoadable.Parser<DashManifest> manifestParser, CacheDataSource.Factory cacheDataSourceFactory, Executor executor)
Deprecated.DashDownloader(MediaItem mediaItem, ParsingLoadable.Parser<DashManifest> manifestParser, CacheDataSource.Factory cacheDataSourceFactory, Executor executor, long maxMergedSegmentStartTimeDiffMs)
Deprecated.Creates a new instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected List<SegmentDownloader.Segment>
getSegments(DataSource dataSource, DashManifest manifest, boolean removing)
Deprecated.Returns a list of all downloadableSegmentDownloader.Segment
s for a given manifest.-
Methods inherited from class com.google.android.exoplayer2.offline.SegmentDownloader
cancel, download, execute, getCompressibleDataSpec, getManifest, remove
-
-
-
-
Constructor Detail
-
DashDownloader
public DashDownloader(MediaItem mediaItem, CacheDataSource.Factory cacheDataSourceFactory)
Deprecated.Creates a new instance.- Parameters:
mediaItem
- TheMediaItem
to be downloaded.cacheDataSourceFactory
- ACacheDataSource.Factory
for the cache into which the download will be written.
-
DashDownloader
public DashDownloader(MediaItem mediaItem, CacheDataSource.Factory cacheDataSourceFactory, Executor executor)
Deprecated.Creates a new instance.- Parameters:
mediaItem
- TheMediaItem
to be downloaded.cacheDataSourceFactory
- ACacheDataSource.Factory
for the cache into which the download will be written.executor
- AnExecutor
used to make requests for the media being downloaded. Providing anExecutor
that uses multiple threads will speed up the download by allowing parts of it to be executed in parallel.
-
DashDownloader
@Deprecated public DashDownloader(MediaItem mediaItem, ParsingLoadable.Parser<DashManifest> manifestParser, CacheDataSource.Factory cacheDataSourceFactory, Executor executor)
Deprecated.
-
DashDownloader
public DashDownloader(MediaItem mediaItem, ParsingLoadable.Parser<DashManifest> manifestParser, CacheDataSource.Factory cacheDataSourceFactory, Executor executor, long maxMergedSegmentStartTimeDiffMs)
Deprecated.Creates a new instance.- Parameters:
mediaItem
- TheMediaItem
to be downloaded.manifestParser
- A parser for DASH manifests.cacheDataSourceFactory
- ACacheDataSource.Factory
for the cache into which the download will be written.executor
- AnExecutor
used to make requests for the media being downloaded. Providing anExecutor
that uses multiple threads will speed up the download by allowing parts of it to be executed in parallel.maxMergedSegmentStartTimeDiffMs
- The maximum difference of the start time of two segments, up to which the segments (of the same URI) should be merged into a single download segment, in milliseconds.
-
-
Method Detail
-
getSegments
protected List<SegmentDownloader.Segment> getSegments(DataSource dataSource, DashManifest manifest, boolean removing) throws IOException, InterruptedException
Deprecated.Description copied from class:SegmentDownloader
Returns a list of all downloadableSegmentDownloader.Segment
s for a given manifest. Any required data should be loaded usingSegmentDownloader.getManifest(com.google.android.exoplayer2.upstream.DataSource, com.google.android.exoplayer2.upstream.DataSpec, boolean)
orSegmentDownloader.execute(com.google.android.exoplayer2.util.RunnableFutureTask<T, ?>, boolean)
.- Specified by:
getSegments
in classSegmentDownloader<DashManifest>
- Parameters:
dataSource
- TheDataSource
through which to load any required data.manifest
- The manifest containing the segments.removing
- 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 anIOException
will be thrown in this case.- Returns:
- The list of downloadable
SegmentDownloader.Segment
s. - Throws:
IOException
- Thrown ifallowPartialIndex
is false and an execution error occurs, or if the media is not in a form that allows for its segments to be listed.InterruptedException
-
-