@UnstableApi
class SsMediaSource : BaseMediaSource, Loader.Callback


A SmoothStreaming MediaSource.

Summary

Nested types

Factory for SsMediaSource.

Constants

const Long

The default presentation delay for live streams.

Public functions

Boolean

Returns whether the MediaItem for this source can be updated with the provided item.

MediaPeriod!
createPeriod(
    id: MediaSource.MediaPeriodId!,
    allocator: Allocator!,
    startPositionUs: Long
)

Returns a new MediaPeriod identified by periodId.

Unit

Throws any pending error encountered while loading or refreshing source information.

Unit
onLoadCanceled(
    loadable: ParsingLoadable<SsManifest!>!,
    elapsedRealtimeMs: Long,
    loadDurationMs: Long,
    released: Boolean
)

Called when a load has been canceled.

Unit
onLoadCompleted(
    loadable: ParsingLoadable<SsManifest!>!,
    elapsedRealtimeMs: Long,
    loadDurationMs: Long
)

Called when a load has completed.

Loader.LoadErrorAction!
onLoadError(
    loadable: ParsingLoadable<SsManifest!>!,
    elapsedRealtimeMs: Long,
    loadDurationMs: Long,
    error: IOException!,
    errorCount: Int
)

Called when a load encounters an error.

Unit
releasePeriod(mediaPeriod: MediaPeriod!)

Releases the period.

synchronized Unit

Updates the MediaItem for this source.

Protected functions

Unit
prepareSourceInternal(mediaTransferListener: TransferListener?)

Starts source preparation and enables the source, see prepareSource.

Unit

Releases the source, see releaseSource.

Public properties

MediaItem!
@GuardedBy(value = "this")
mediaItem

Inherited functions

From androidx.media3.exoplayer.source.BaseMediaSource
Unit
addDrmEventListener(
    handler: Handler!,
    eventListener: DrmSessionEventListener!
)

Adds a DrmSessionEventListener to the list of listeners which are notified of DRM events for this media source.

Unit
addEventListener(
    handler: Handler!,
    eventListener: MediaSourceEventListener!
)

Adds a MediaSourceEventListener to the list of listeners which are notified of media source events.

DrmSessionEventListener.EventDispatcher!

Returns a DrmSessionEventListener.EventDispatcher which dispatches all events to the registered listeners with the specified MediaPeriodId

DrmSessionEventListener.EventDispatcher!
createDrmEventDispatcher(
    windowIndex: Int,
    mediaPeriodId: MediaSource.MediaPeriodId?
)

Returns a DrmSessionEventListener.EventDispatcher which dispatches all events to the registered listeners with the specified window index and MediaPeriodId.

MediaSourceEventListener.EventDispatcher!

Returns a MediaSourceEventListener.EventDispatcher which dispatches all events to the registered listeners with the specified MediaPeriodId.

MediaSourceEventListener.EventDispatcher!
createEventDispatcher(
    mediaPeriodId: MediaSource.MediaPeriodId!,
    mediaTimeOffsetMs: Long
)

This function is deprecated.

Use createEventDispatcher instead.

MediaSourceEventListener.EventDispatcher!
createEventDispatcher(
    windowIndex: Int,
    mediaPeriodId: MediaSource.MediaPeriodId?
)

Returns a MediaSourceEventListener.EventDispatcher which dispatches all events to the registered listeners with the specified window index and MediaPeriodId.

MediaSourceEventListener.EventDispatcher!
createEventDispatcher(
    windowIndex: Int,
    mediaPeriodId: MediaSource.MediaPeriodId?,
    mediaTimeOffsetMs: Long
)

This function is deprecated.

Use createEventDispatcher instead.

Unit

Disables the source for the creation of MediaPeriods.

Unit

Disables the source, see disable.

Unit

Enables the source for the creation of MediaPeriods.

Unit

Enables the source, see enable.

Boolean

Returns whether the source is enabled.

Unit
prepareSource(
    caller: MediaSource.MediaSourceCaller!,
    mediaTransferListener: TransferListener?
)

This function is deprecated.

Implement prepareSource instead.

Unit
prepareSource(
    caller: MediaSource.MediaSourceCaller!,
    mediaTransferListener: TransferListener?,
    playerId: PlayerId!
)

Registers a MediaSourceCaller.

Boolean

Returns whether the source has prepareSource called.

Unit

Updates timeline and manifest and notifies all listeners of the update.

Unit

Unregisters a caller, and disables and releases the source if no longer required.

Unit

Removes a DrmSessionEventListener from the list of listeners which are notified of DRM events for this media source.

Unit

Removes a MediaSourceEventListener from the list of listeners which are notified of media source events.

From androidx.media3.exoplayer.source.MediaSource
Timeline?

Returns the initial placeholder timeline that is returned immediately when the real timeline is not yet known, or null to let the player create an initial timeline.

Boolean

Returns true if the media source is guaranteed to never have zero or more than one window.

Constants

DEFAULT_LIVE_PRESENTATION_DELAY_MS

const val DEFAULT_LIVE_PRESENTATION_DELAY_MS = 30000: Long

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 functions

canUpdateMediaItem

fun canUpdateMediaItem(mediaItem: MediaItem!): Boolean

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.

Parameters
mediaItem: MediaItem!

The new MediaItem.

Returns
Boolean

Whether the source can be updated using this item.

createPeriod

fun createPeriod(
    id: MediaSource.MediaPeriodId!,
    allocator: Allocator!,
    startPositionUs: Long
): MediaPeriod!

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
id: MediaSource.MediaPeriodId!

The identifier of the period.

allocator: Allocator!

An Allocator from which to obtain media buffer allocations.

startPositionUs: Long

The expected start position, in microseconds.

Returns
MediaPeriod!

A new MediaPeriod.

maybeThrowSourceInfoRefreshError

fun maybeThrowSourceInfoRefreshError(): Unit

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.

onLoadCanceled

fun onLoadCanceled(
    loadable: ParsingLoadable<SsManifest!>!,
    elapsedRealtimeMs: Long,
    loadDurationMs: Long,
    released: Boolean
): Unit

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 has been released then this callback may be called before load exits.

Parameters
loadable: ParsingLoadable<SsManifest!>!

The loadable whose load has been canceled.

elapsedRealtimeMs: Long

elapsedRealtime when the load was canceled.

loadDurationMs: Long

The duration in milliseconds of the load since startLoading was called up to the point at which it was canceled.

released: Boolean

True if the load was canceled because the Loader was released. False otherwise.

onLoadCompleted

fun onLoadCompleted(
    loadable: ParsingLoadable<SsManifest!>!,
    elapsedRealtimeMs: Long,
    loadDurationMs: Long
): Unit

Called when a load has completed.

Note: There is guaranteed to be a memory barrier between load exiting and this callback being called.

Parameters
loadable: ParsingLoadable<SsManifest!>!

The loadable whose load has completed.

elapsedRealtimeMs: Long

elapsedRealtime when the load ended.

loadDurationMs: Long

The duration in milliseconds of the load since startLoading was called.

onLoadError

fun onLoadError(
    loadable: ParsingLoadable<SsManifest!>!,
    elapsedRealtimeMs: Long,
    loadDurationMs: Long,
    error: IOException!,
    errorCount: Int
): Loader.LoadErrorAction!

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
loadable: ParsingLoadable<SsManifest!>!

The loadable whose load has encountered an error.

elapsedRealtimeMs: Long

elapsedRealtime when the error occurred.

loadDurationMs: Long

The duration in milliseconds of the load since startLoading was called up to the point at which the error occurred.

error: IOException!

The load error.

errorCount: Int

The number of errors this load has encountered, including this one.

Returns
Loader.LoadErrorAction!

The desired error handling action. One of RETRY, RETRY_RESET_ERROR_COUNT, DONT_RETRY, DONT_RETRY_FATAL or a retry action created by createRetryAction.

releasePeriod

fun releasePeriod(mediaPeriod: MediaPeriod!): Unit

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 fun updateMediaItem(mediaItem: MediaItem!): Unit

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.

Parameters
mediaItem: MediaItem!

The new MediaItem.

Protected functions

prepareSourceInternal

protected fun prepareSourceInternal(mediaTransferListener: TransferListener?): Unit

Starts source preparation and enables the source, see prepareSource. This method is called at most once until the next call to releaseSourceInternal.

Parameters
mediaTransferListener: TransferListener?

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 fun releaseSourceInternal(): Unit

Releases the source, see releaseSource. This method is called exactly once after each call to prepareSourceInternal.

Public properties

mediaItem

@GuardedBy(value = "this")
val mediaItemMediaItem!