public final class ExtractorMediaSource extends java.lang.Object implements MediaSource
Uri and extracted using an Extractor.
If the possible input stream container formats are known, pass a factory that instantiates
extractors for them to the constructor. Otherwise, pass a DefaultExtractorsFactory to
use the default extractors. When reading a new stream, the first Extractor in the array
of extractors created by the factory that returns true from Extractor.sniff(com.google.android.exoplayer2.extractor.ExtractorInput) will
be used to extract samples from the input stream.
Note that the built-in extractors for AAC, MPEG PS/TS and FLV streams do not support seeking.
| Modifier and Type | Class and Description |
|---|---|
static interface |
ExtractorMediaSource.EventListener
Deprecated.
|
static class |
ExtractorMediaSource.Factory
Factory for
ExtractorMediaSources. |
MediaSource.Listener, MediaSource.MediaPeriodId| Modifier and Type | Field and Description |
|---|---|
static int |
DEFAULT_LOADING_CHECK_INTERVAL_BYTES
The default number of bytes that should be loaded between each each invocation of
SequenceableLoader.Callback.onContinueLoadingRequested(SequenceableLoader). |
static int |
DEFAULT_MIN_LOADABLE_RETRY_COUNT_LIVE
The default minimum number of times to retry loading prior to failing for live streams.
|
static int |
DEFAULT_MIN_LOADABLE_RETRY_COUNT_ON_DEMAND
The default minimum number of times to retry loading prior to failing for on-demand streams.
|
static int |
MIN_RETRY_COUNT_DEFAULT_FOR_MEDIA
Value for
minLoadableRetryCount that causes the loader to retry
DEFAULT_MIN_LOADABLE_RETRY_COUNT_LIVE times for live streams and
DEFAULT_MIN_LOADABLE_RETRY_COUNT_ON_DEMAND for on-demand streams. |
MEDIA_SOURCE_REUSED_ERROR_MESSAGE| Constructor and Description |
|---|
ExtractorMediaSource(android.net.Uri uri,
DataSource.Factory dataSourceFactory,
ExtractorsFactory extractorsFactory,
android.os.Handler eventHandler,
ExtractorMediaSource.EventListener eventListener)
Deprecated.
Use
ExtractorMediaSource.Factory instead. |
ExtractorMediaSource(android.net.Uri uri,
DataSource.Factory dataSourceFactory,
ExtractorsFactory extractorsFactory,
android.os.Handler eventHandler,
ExtractorMediaSource.EventListener eventListener,
java.lang.String customCacheKey)
Deprecated.
Use
ExtractorMediaSource.Factory instead. |
ExtractorMediaSource(android.net.Uri uri,
DataSource.Factory dataSourceFactory,
ExtractorsFactory extractorsFactory,
int minLoadableRetryCount,
android.os.Handler eventHandler,
ExtractorMediaSource.EventListener eventListener,
java.lang.String customCacheKey,
int continueLoadingCheckIntervalBytes)
Deprecated.
Use
ExtractorMediaSource.Factory instead. |
| Modifier and Type | Method and Description |
|---|---|
MediaPeriod |
createPeriod(MediaSource.MediaPeriodId id,
Allocator allocator)
Returns a new
MediaPeriod identified by periodId. |
void |
maybeThrowSourceInfoRefreshError()
Throws any pending error encountered while loading or refreshing source information.
|
void |
onSourceInfoRefreshed(long durationUs,
boolean isSeekable)
Called when the duration or ability to seek within the period changes.
|
void |
prepareSource(ExoPlayer player,
boolean isTopLevelSource,
MediaSource.Listener listener)
Starts preparation of the source.
|
void |
releasePeriod(MediaPeriod mediaPeriod)
Releases the period.
|
void |
releaseSource()
Releases the source.
|
public static final int DEFAULT_MIN_LOADABLE_RETRY_COUNT_ON_DEMAND
public static final int DEFAULT_MIN_LOADABLE_RETRY_COUNT_LIVE
public static final int MIN_RETRY_COUNT_DEFAULT_FOR_MEDIA
minLoadableRetryCount that causes the loader to retry
DEFAULT_MIN_LOADABLE_RETRY_COUNT_LIVE times for live streams and
DEFAULT_MIN_LOADABLE_RETRY_COUNT_ON_DEMAND for on-demand streams.public static final int DEFAULT_LOADING_CHECK_INTERVAL_BYTES
SequenceableLoader.Callback.onContinueLoadingRequested(SequenceableLoader).@Deprecated
public ExtractorMediaSource(android.net.Uri uri,
DataSource.Factory dataSourceFactory,
ExtractorsFactory extractorsFactory,
android.os.Handler eventHandler,
ExtractorMediaSource.EventListener eventListener)
ExtractorMediaSource.Factory instead.uri - The Uri of the media stream.dataSourceFactory - A factory for DataSources to read the media.extractorsFactory - A factory for Extractors to process the media stream. If the
possible formats are known, pass a factory that instantiates extractors for those formats.
Otherwise, pass a DefaultExtractorsFactory to use default extractors.eventHandler - A handler for events. May be null if delivery of events is not required.eventListener - A listener of events. May be null if delivery of events is not required.@Deprecated
public ExtractorMediaSource(android.net.Uri uri,
DataSource.Factory dataSourceFactory,
ExtractorsFactory extractorsFactory,
android.os.Handler eventHandler,
ExtractorMediaSource.EventListener eventListener,
java.lang.String customCacheKey)
ExtractorMediaSource.Factory instead.uri - The Uri of the media stream.dataSourceFactory - A factory for DataSources to read the media.extractorsFactory - A factory for Extractors to process the media stream. If the
possible formats are known, pass a factory that instantiates extractors for those formats.
Otherwise, pass a DefaultExtractorsFactory to use default extractors.eventHandler - A handler for events. May be null if delivery of events is not required.eventListener - A listener of events. May be null if delivery of events is not required.customCacheKey - A custom key that uniquely identifies the original stream. Used for cache
indexing. May be null.@Deprecated
public ExtractorMediaSource(android.net.Uri uri,
DataSource.Factory dataSourceFactory,
ExtractorsFactory extractorsFactory,
int minLoadableRetryCount,
android.os.Handler eventHandler,
ExtractorMediaSource.EventListener eventListener,
java.lang.String customCacheKey,
int continueLoadingCheckIntervalBytes)
ExtractorMediaSource.Factory instead.uri - The Uri of the media stream.dataSourceFactory - A factory for DataSources to read the media.extractorsFactory - A factory for Extractors to process the media stream. If the
possible formats are known, pass a factory that instantiates extractors for those formats.
Otherwise, pass a DefaultExtractorsFactory to use default extractors.minLoadableRetryCount - The minimum number of times to retry if a loading error occurs.eventHandler - A handler for events. May be null if delivery of events is not required.eventListener - A listener of events. May be null if delivery of events is not required.customCacheKey - A custom key that uniquely identifies the original stream. Used for cache
indexing. May be null.continueLoadingCheckIntervalBytes - The number of bytes that should be loaded between each
invocation of SequenceableLoader.Callback.onContinueLoadingRequested(SequenceableLoader).public void prepareSource(ExoPlayer player, boolean isTopLevelSource, MediaSource.Listener listener)
MediaSourceShould not be called directly from application code.
prepareSource in interface MediaSourceplayer - The player for which this source is being prepared.isTopLevelSource - Whether this source has been passed directly to
ExoPlayer.prepare(MediaSource) or
ExoPlayer.prepare(MediaSource, boolean, boolean). If false, this source is
being prepared by another source (e.g. ConcatenatingMediaSource) for composition.listener - The listener for source events.public void maybeThrowSourceInfoRefreshError()
throws java.io.IOException
MediaSourceShould not be called directly from application code.
maybeThrowSourceInfoRefreshError in interface MediaSourcejava.io.IOExceptionpublic MediaPeriod createPeriod(MediaSource.MediaPeriodId id, Allocator allocator)
MediaSourceMediaPeriod identified by periodId. This method may be called
multiple times with the same period identifier without an intervening call to
MediaSource.releasePeriod(MediaPeriod).
Should not be called directly from application code.
createPeriod in interface MediaSourceid - The identifier of the period.allocator - An Allocator from which to obtain media buffer allocations.MediaPeriod.public void releasePeriod(MediaPeriod mediaPeriod)
MediaSourceShould not be called directly from application code.
releasePeriod in interface MediaSourcemediaPeriod - The period to release.public void releaseSource()
MediaSourceShould not be called directly from application code.
releaseSource in interface MediaSourcepublic void onSourceInfoRefreshed(long durationUs,
boolean isSeekable)
durationUs - The duration of the period, or C.TIME_UNSET.isSeekable - Whether the period is seekable.