public final class ExtractorMediaSource extends BaseMediaSource
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.MediaPeriodId, MediaSource.SourceInfoRefreshListener| 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). |
| 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,
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 |
prepareSourceInternal(ExoPlayer player,
boolean isTopLevelSource,
TransferListener mediaTransferListener)
Starts source preparation.
|
void |
releasePeriod(MediaPeriod mediaPeriod)
Releases the period.
|
void |
releaseSourceInternal()
Releases the source.
|
addEventListener, createEventDispatcher, createEventDispatcher, createEventDispatcher, prepareSource, prepareSource, refreshSourceInfo, releaseSource, removeEventListenerpublic 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,
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.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 prepareSourceInternal(ExoPlayer player, boolean isTopLevelSource, @Nullable TransferListener mediaTransferListener)
BaseMediaSourceBaseMediaSource.releaseSourceInternal().prepareSourceInternal in class BaseMediaSourceplayer - 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).mediaTransferListener - The transfer listener which should be informed of any media data
transfers. May be null if no listener is available. Note that this listener should usually
be only informed of transfers related to the media loads and not of auxiliary loads for
manifests and other data.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 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 releaseSourceInternal()
BaseMediaSourceBaseMediaSource.prepareSourceInternal(ExoPlayer, boolean, TransferListener).releaseSourceInternal in class BaseMediaSourcepublic void onSourceInfoRefreshed(long durationUs,
boolean isSeekable)
durationUs - The duration of the period, or C.TIME_UNSET.isSeekable - Whether the period is seekable.