@UnstableApi
class DashDownloader : SegmentDownloader


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.Factory(cacheDataSourceFactory)
            .create(new MediaItem.Builder()
              .setUri(manifestUrl)
              .setStreamKeys(ImmutableList.of(new StreamKey(0, 0, 0)))
              .build());
// Perform the download.
dashDownloader.download(progressListener);
// Use the downloaded data for playback.
DashMediaSource mediaSource =
    new DashMediaSource.Factory(cacheDataSourceFactory).createMediaSource(mediaItem);

Summary

Public constructors

DashDownloader(
    mediaItem: MediaItem!,
    cacheDataSourceFactory: CacheDataSource.Factory!
)

This function is deprecated.

Use create instead.

DashDownloader(
    mediaItem: MediaItem!,
    cacheDataSourceFactory: CacheDataSource.Factory!,
    executor: Executor!
)

This function is deprecated.

Use create instead.

Protected functions

(Mutable)List<SegmentDownloader.Segment!>!
getSegments(
    dataSource: DataSource!,
    manifest: DashManifest!,
    removing: Boolean
)

Returns a list of all downloadable Segments for a given manifest.

Inherited functions

From androidx.media3.exoplayer.offline.SegmentDownloader
Unit

Permanently cancels the downloading by this downloader.

Unit

Downloads the content.

T!
<T> execute(runnable: RunnableFutureTask<T!, Any!>!, removing: Boolean)

Executes the provided RunnableFutureTask.

java-static DataSpec!
M!
getManifest(dataSource: DataSource!, dataSpec: DataSpec!, removing: Boolean)

Loads and parses a manifest.

Unit

Removes the content.

Public constructors

DashDownloader

DashDownloader(
    mediaItem: MediaItem!,
    cacheDataSourceFactory: CacheDataSource.Factory!
)

DashDownloader

DashDownloader(
    mediaItem: MediaItem!,
    cacheDataSourceFactory: CacheDataSource.Factory!,
    executor: Executor!
)

Protected functions

getSegments

protected fun getSegments(
    dataSource: DataSource!,
    manifest: DashManifest!,
    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 DataSource through which to load any required data.

manifest: DashManifest!

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 IOException will be thrown in this case.

Returns
(Mutable)List<SegmentDownloader.Segment!>!

The list of downloadable Segments.

Throws
java.io.IOException

Thrown if allowPartialIndex is false and an execution error occurs, or if the media is not in a form that allows for its segments to be listed.

java.lang.InterruptedException