public final class ExtractorMediaSource extends java.lang.Object implements MediaSource, MediaSource.Listener
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
Listener of
ExtractorMediaSource events. |
MediaSource.Listener| Modifier and Type | Field and Description |
|---|---|
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. |
| Constructor and Description |
|---|
ExtractorMediaSource(android.net.Uri uri,
DataSource.Factory dataSourceFactory,
ExtractorsFactory extractorsFactory,
android.os.Handler eventHandler,
ExtractorMediaSource.EventListener eventListener) |
ExtractorMediaSource(android.net.Uri uri,
DataSource.Factory dataSourceFactory,
ExtractorsFactory extractorsFactory,
android.os.Handler eventHandler,
ExtractorMediaSource.EventListener eventListener,
java.lang.String customCacheKey) |
ExtractorMediaSource(android.net.Uri uri,
DataSource.Factory dataSourceFactory,
ExtractorsFactory extractorsFactory,
int minLoadableRetryCount,
android.os.Handler eventHandler,
ExtractorMediaSource.EventListener eventListener,
java.lang.String customCacheKey) |
| Modifier and Type | Method and Description |
|---|---|
MediaPeriod |
createPeriod(int index,
Allocator allocator,
long positionUs)
Returns a new
MediaPeriod corresponding to the period at the specified index. |
void |
maybeThrowSourceInfoRefreshError()
Throws any pending error encountered while loading or refreshing source information.
|
void |
onSourceInfoRefreshed(Timeline newTimeline,
java.lang.Object manifest)
Called when manifest and/or timeline has been refreshed.
|
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 ExtractorMediaSource(android.net.Uri uri,
DataSource.Factory dataSourceFactory,
ExtractorsFactory extractorsFactory,
android.os.Handler eventHandler,
ExtractorMediaSource.EventListener eventListener)
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.public ExtractorMediaSource(android.net.Uri uri,
DataSource.Factory dataSourceFactory,
ExtractorsFactory extractorsFactory,
android.os.Handler eventHandler,
ExtractorMediaSource.EventListener eventListener,
java.lang.String customCacheKey)
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.public ExtractorMediaSource(android.net.Uri uri,
DataSource.Factory dataSourceFactory,
ExtractorsFactory extractorsFactory,
int minLoadableRetryCount,
android.os.Handler eventHandler,
ExtractorMediaSource.EventListener eventListener,
java.lang.String customCacheKey)
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.public void prepareSource(ExoPlayer player, boolean isTopLevelSource, MediaSource.Listener listener)
MediaSourceprepareSource 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
MediaSourcemaybeThrowSourceInfoRefreshError in interface MediaSourcejava.io.IOExceptionpublic MediaPeriod createPeriod(int index, Allocator allocator, long positionUs)
MediaSourceMediaPeriod corresponding to the period at the specified index.
This method may be called multiple times with the same index without an intervening call to
MediaSource.releasePeriod(MediaPeriod).createPeriod in interface MediaSourceindex - The index of the period.allocator - An Allocator from which to obtain media buffer allocations.positionUs - The player's current playback position.MediaPeriod.public void releasePeriod(MediaPeriod mediaPeriod)
MediaSourcereleasePeriod in interface MediaSourcemediaPeriod - The period to release.public void releaseSource()
MediaSourceThis method should be called when the source is no longer required. It may be called in any state.
releaseSource in interface MediaSourcepublic void onSourceInfoRefreshed(Timeline newTimeline, java.lang.Object manifest)
MediaSource.ListeneronSourceInfoRefreshed in interface MediaSource.ListenernewTimeline - The source's timeline.manifest - The loaded manifest.