Class SegmentDownloader<M extends FilterableManifest<M>>
- java.lang.Object
-
- com.google.android.exoplayer2.offline.SegmentDownloader<M>
-
- Type Parameters:
M
- The type of the manifest object.
- All Implemented Interfaces:
Downloader
- Direct Known Subclasses:
DashDownloader
,HlsDownloader
,SsDownloader
@Deprecated public abstract class SegmentDownloader<M extends FilterableManifest<M>> extends Object implements Downloader
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.Base class for multi segment stream downloaders.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
SegmentDownloader.Segment
Deprecated.Smallest unit of content to be downloaded.-
Nested classes/interfaces inherited from interface com.google.android.exoplayer2.offline.Downloader
Downloader.ProgressListener
-
-
Field Summary
Fields Modifier and Type Field Description static long
DEFAULT_MAX_MERGED_SEGMENT_START_TIME_DIFF_MS
Deprecated.
-
Constructor Summary
Constructors Constructor Description SegmentDownloader(MediaItem mediaItem, ParsingLoadable.Parser<M> manifestParser, CacheDataSource.Factory cacheDataSourceFactory, Executor executor)
Deprecated.SegmentDownloader(MediaItem mediaItem, ParsingLoadable.Parser<M> manifestParser, CacheDataSource.Factory cacheDataSourceFactory, Executor executor, long maxMergedSegmentStartTimeDiffMs)
Deprecated.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
cancel()
Deprecated.Permanently cancels the downloading by this downloader.void
download(Downloader.ProgressListener progressListener)
Deprecated.Downloads the content.protected <T> T
execute(RunnableFutureTask<T,?> runnable, boolean removing)
Deprecated.Executes the providedRunnableFutureTask
.protected static DataSpec
getCompressibleDataSpec(Uri uri)
Deprecated.protected M
getManifest(DataSource dataSource, DataSpec dataSpec, boolean removing)
Deprecated.Loads and parses a manifest.protected abstract List<SegmentDownloader.Segment>
getSegments(DataSource dataSource, M manifest, boolean removing)
Deprecated.Returns a list of all downloadableSegmentDownloader.Segment
s for a given manifest.void
remove()
Deprecated.Removes the content.
-
-
-
Field Detail
-
DEFAULT_MAX_MERGED_SEGMENT_START_TIME_DIFF_MS
public static final long DEFAULT_MAX_MERGED_SEGMENT_START_TIME_DIFF_MS
Deprecated.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
SegmentDownloader
@Deprecated public SegmentDownloader(MediaItem mediaItem, ParsingLoadable.Parser<M> manifestParser, CacheDataSource.Factory cacheDataSourceFactory, Executor executor)
Deprecated.
-
SegmentDownloader
public SegmentDownloader(MediaItem mediaItem, ParsingLoadable.Parser<M> manifestParser, CacheDataSource.Factory cacheDataSourceFactory, Executor executor, long maxMergedSegmentStartTimeDiffMs)
Deprecated.- Parameters:
mediaItem
- TheMediaItem
to be downloaded.manifestParser
- A parser for manifests belonging to the media 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.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
-
download
public final void download(@Nullable Downloader.ProgressListener progressListener) throws IOException, InterruptedException
Deprecated.Description copied from interface:Downloader
Downloads the content.If downloading fails, this method can be called again to resume the download. It cannot be called again after the download has been
canceled
.If downloading is canceled whilst this method is executing, then it is expected that it will return reasonably quickly. However, there are no guarantees about how the method will return, meaning that it can return without throwing, or by throwing any of its documented exceptions. The caller must use its own knowledge about whether downloading has been canceled to determine whether this is why the method has returned, rather than relying on the method returning in a particular way.
- Specified by:
download
in interfaceDownloader
- Parameters:
progressListener
- A listener to receive progress updates, ornull
.- Throws:
IOException
- If the download failed to complete successfully.InterruptedException
- If the download was interrupted.
-
cancel
public void cancel()
Deprecated.Description copied from interface:Downloader
Permanently cancels the downloading by this downloader. The caller should also interrupt the downloading thread immediately after calling this method.Once canceled,
Downloader.download(com.google.android.exoplayer2.offline.Downloader.ProgressListener)
cannot be called again.- Specified by:
cancel
in interfaceDownloader
-
remove
public final void remove()
Deprecated.Description copied from interface:Downloader
Removes the content.- Specified by:
remove
in interfaceDownloader
-
getManifest
protected final M getManifest(DataSource dataSource, DataSpec dataSpec, boolean removing) throws InterruptedException, IOException
Deprecated.Loads and parses a manifest.- Parameters:
dataSource
- The source to use when loading the manifest.dataSpec
- The manifestDataSpec
.removing
- Whether the manifest is being loaded as part of the download being removed.- Returns:
- The loaded manifest.
- Throws:
InterruptedException
- If the thread on which the method is called is interrupted.IOException
- If an error occurs during execution.
-
execute
protected final <T> T execute(RunnableFutureTask<T,?> runnable, boolean removing) throws InterruptedException, IOException
Deprecated.Executes the providedRunnableFutureTask
.- Parameters:
runnable
- TheRunnableFutureTask
to execute.removing
- Whether the execution is part of the download being removed.- Returns:
- The result.
- Throws:
InterruptedException
- If the thread on which the method is called is interrupted.IOException
- If an error occurs during execution.
-
getSegments
protected abstract List<SegmentDownloader.Segment> getSegments(DataSource dataSource, M manifest, boolean removing) throws IOException, InterruptedException
Deprecated.Returns a list of all downloadableSegmentDownloader.Segment
s for a given manifest. Any required data should be loaded usinggetManifest(com.google.android.exoplayer2.upstream.DataSource, com.google.android.exoplayer2.upstream.DataSpec, boolean)
orexecute(com.google.android.exoplayer2.util.RunnableFutureTask<T, ?>, boolean)
.- 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
-
-