SsMediaSource
@UnstableApi
public final class SsMediaSource extends BaseMediaSource implements Loader.Callback
| java.lang.Object | ||
| ↳ | androidx.media3.exoplayer.source.BaseMediaSource | |
| ↳ | androidx.media3.exoplayer.smoothstreaming.SsMediaSource |
A SmoothStreaming MediaSource.
Summary
Nested types |
|---|
public final class SsMediaSource.Factory implements MediaSourceFactoryFactory for |
Constants |
|
|---|---|
static final long |
The default presentation delay for live streams. |
Public methods |
|
|---|---|
boolean |
canUpdateMediaItem(MediaItem mediaItem)Returns whether the |
MediaPeriod |
createPeriod(Returns a new |
synchronized MediaItem |
Returns the |
void |
Throws any pending error encountered while loading or refreshing source information. |
void |
onLoadCanceled(Called when a load has been canceled. |
void |
onLoadCompleted(Called when a load has completed. |
Loader.LoadErrorAction |
onLoadError(Called when a load encounters an error. |
void |
onLoadStarted(Called when a load has started for the first time or through a retry. |
void |
releasePeriod(MediaPeriod mediaPeriod)Releases the period. |
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 methods |
||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
||||||||||||||||||||||||||||||||||||||||||||
Constants
DEFAULT_LIVE_PRESENTATION_DELAY_MS
public static final long DEFAULT_LIVE_PRESENTATION_DELAY_MS = 30000
The default presentation delay for live streams. The presentation delay is the duration by which the default start position precedes the end of the live window.
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. |
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.
| Throws | |
|---|---|
java.io.IOException |
onLoadCanceled
public void onLoadCanceled(
ParsingLoadable<SsManifest> loadable,
long elapsedRealtimeMs,
long loadDurationMs,
boolean released
)
Called when a load has been canceled.
Note: If the Loader has not been released then there is guaranteed to be a memory barrier between load exiting and this callback being called. If the Loader has been released then this callback may be called before load exits.
| Parameters | |
|---|---|
ParsingLoadable<SsManifest> loadable |
The loadable whose load has been canceled. |
long elapsedRealtimeMs |
|
long loadDurationMs |
The duration in milliseconds of the load since |
boolean released |
True if the load was canceled because the |
onLoadCompleted
public void onLoadCompleted(
ParsingLoadable<SsManifest> loadable,
long elapsedRealtimeMs,
long loadDurationMs
)
Called when a load has completed.
Note: There is guaranteed to be a memory barrier between load exiting and this callback being called.
| Parameters | |
|---|---|
ParsingLoadable<SsManifest> loadable |
The loadable whose load has completed. |
long elapsedRealtimeMs |
|
long loadDurationMs |
The duration in milliseconds of the load since |
onLoadError
public Loader.LoadErrorAction onLoadError(
ParsingLoadable<SsManifest> loadable,
long elapsedRealtimeMs,
long loadDurationMs,
IOException error,
int errorCount
)
Called when a load encounters an error.
Note: There is guaranteed to be a memory barrier between load exiting and this callback being called.
| Parameters | |
|---|---|
ParsingLoadable<SsManifest> loadable |
The loadable whose load has encountered an error. |
long elapsedRealtimeMs |
|
long loadDurationMs |
The duration in milliseconds of the load since |
IOException error |
The load error. |
int errorCount |
The number of errors this load has encountered, including this one. |
| Returns | |
|---|---|
Loader.LoadErrorAction |
The desired error handling action. One of |
onLoadStarted
public void onLoadStarted(
ParsingLoadable<SsManifest> loadable,
long elapsedRealtimeMs,
long loadDurationMs,
int retryCount
)
Called when a load has started for the first time or through a retry.
This is called for the first time with retryCount == 0 just before the load is started.
| Parameters | |
|---|---|
ParsingLoadable<SsManifest> loadable |
The loadable whose load has started. |
long elapsedRealtimeMs |
|
long loadDurationMs |
The duration in milliseconds of the load since |
int retryCount |
The number of failed attempts since |
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. |
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.