ProgressiveMediaSource
@UnstableApi
public final class ProgressiveMediaSource extends BaseMediaSource
| java.lang.Object | ||
| ↳ | androidx.media3.exoplayer.source.BaseMediaSource | |
| ↳ | androidx.media3.exoplayer.source.ProgressiveMediaSource |
Provides one period that loads data from a 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 sniff will be used to extract samples from the input stream.
Note that the built-in extractor for FLV streams does not support seeking.
Summary
Nested types |
|---|
public final class ProgressiveMediaSource.Factory implements MediaSourceFactoryFactory for |
public interface ProgressiveMediaSource.ListenerA listener of |
Constants |
|
|---|---|
static final int |
DEFAULT_LOADING_CHECK_INTERVAL_BYTES = 1048576The default number of bytes that should be loaded between each invocation of |
Public methods |
|
|---|---|
boolean |
canUpdateMediaItem(MediaItem mediaItem)Returns whether the |
void |
Clears the |
MediaPeriod |
createPeriod(Returns a new |
synchronized MediaItem |
Returns the |
void |
Throws any pending error encountered while loading or refreshing source information. |
void |
onSourceInfoRefreshed(long durationUs, SeekMap seekMap, boolean isLive)Called when the duration, the |
void |
releasePeriod(MediaPeriod mediaPeriod)Releases the period. |
void |
setListener(ProgressiveMediaSource.Listener listener)Sets the |
synchronized void |
updateMediaItem(MediaItem mediaItem)Updates the |
Protected methods |
|
|---|---|
void |
prepareSourceInternal(@Nullable TransferListener mediaTransferListener)Starts source preparation and enables the source, see |
void |
Releases the source, see |
Inherited fields |
|---|
Inherited methods |
||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
||||||||||||||||||||||||||||||||||||||||||||||
|
Constants
DEFAULT_LOADING_CHECK_INTERVAL_BYTES
public static final int DEFAULT_LOADING_CHECK_INTERVAL_BYTES = 1048576
The default number of bytes that should be loaded between each invocation of onContinueLoadingRequested.
Public methods
canUpdateMediaItem
public boolean canUpdateMediaItem(MediaItem mediaItem)
Returns whether the MediaItem for this source can be updated with the provided item.
Should not be called directly from application code.
This method must be called on the application thread.
| Returns | |
|---|---|
boolean |
Whether the source can be updated using this item. |
clearListener
public void clearListener()
Clears the Listener.
This method must be called on the playback thread.
createPeriod
public MediaPeriod createPeriod(
MediaSource.MediaPeriodId id,
Allocator allocator,
long startPositionUs
)
Returns a new MediaPeriod identified by periodId.
Should not be called directly from application code.
This method must be called on the playback thread and only if the source is enabled.
| Parameters | |
|---|---|
MediaSource.MediaPeriodId id |
The identifier of the period. |
Allocator allocator |
An |
long startPositionUs |
The expected start position, in microseconds. |
| Returns | |
|---|---|
MediaPeriod |
A new |
getMediaItem
synchronized public MediaItem getMediaItem()
Returns the MediaItem whose media is provided by the source.
Should not be called directly from application code.
This method must be called on the application thread.
maybeThrowSourceInfoRefreshError
public void maybeThrowSourceInfoRefreshError()
Throws any pending error encountered while loading or refreshing source information.
Should not be called directly from application code.
This method must be called on the playback thread and only after prepareSource.
onSourceInfoRefreshed
public void onSourceInfoRefreshed(long durationUs, SeekMap seekMap, boolean isLive)
Called when the duration, the SeekMap of the period, or the categorization as live stream changes.
| Parameters | |
|---|---|
long durationUs |
The duration of the period, or |
SeekMap seekMap |
The |
boolean isLive |
Whether the period is live. |
releasePeriod
public void releasePeriod(MediaPeriod mediaPeriod)
Releases the period.
Should not be called directly from application code.
This method must be called on the playback thread.
| Parameters | |
|---|---|
MediaPeriod mediaPeriod |
The period to release. |
setListener
public void setListener(ProgressiveMediaSource.Listener listener)
Sets the Listener.
This method must be called on the playback thread.
updateMediaItem
synchronized public void updateMediaItem(MediaItem mediaItem)
Updates the MediaItem for this source.
Should not be called directly from application code.
This method must be called on the playback thread and only if canUpdateMediaItem returns true for the new MediaItem.
Protected methods
prepareSourceInternal
protected void prepareSourceInternal(@Nullable TransferListener mediaTransferListener)
Starts source preparation and enables the source, see prepareSource. This method is called at most once until the next call to releaseSourceInternal.
This method is called on the playback thread.
| Parameters | |
|---|---|
@Nullable TransferListener 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. |
releaseSourceInternal
protected void releaseSourceInternal()
Releases the source, see releaseSource. This method is called exactly once after each call to prepareSourceInternal.
This method is called on the playback thread.