FakeAdaptiveMediaSource


@UnstableApi
class FakeAdaptiveMediaSource : FakeMediaSource


Fake MediaSource that provides a given timeline. Creating the period returns a from the given TrackGroupArray.

Summary

Public constructors

FakeAdaptiveMediaSource(
    timeline: Timeline!,
    trackGroupArray: TrackGroupArray!,
    chunkSourceFactory: FakeChunkSource.Factory!
)

Public functions

Unit

Releases a media period created by createMediaPeriod.

Protected functions

MediaPeriod!
createMediaPeriod(
    id: MediaSource.MediaPeriodId!,
    trackGroupArray: TrackGroupArray!,
    allocator: Allocator!,
    mediaSourceEventDispatcher: MediaSourceEventListener.EventDispatcher!,
    drmSessionManager: DrmSessionManager!,
    drmEventDispatcher: DrmSessionEventListener.EventDispatcher!,
    transferListener: TransferListener?
)

Creates a MediaPeriod for this media source.

Inherited Constants

From androidx.media3.test.utils.FakeMediaSource
const MediaItem!

The media item used by the fake media source.

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.test.utils.FakeMediaSource
Unit

Assert that a media period for the given id has been created.

Unit

Assert that the source and all periods have been released.

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.

java-static FakeMediaSource!
createWithWindowId(windowId: Any!)

Convenience method to create a FakeMediaSource with the given window id.

(Mutable)List<MediaSource.MediaPeriodId!>!

Returns a list of MediaPeriodIds, with one element for each created media period.

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.

MediaPeriod!

Returns the last created active MediaPeriod.

MediaItem!

Returns the MediaItem whose media is provided by the source.

Boolean

Returns whether the source is currently prepared.

Boolean

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

Unit

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

synchronized Unit
prepareSourceInternal(mediaTransferListener: TransferListener?)

Starts source preparation and enables the source, see prepareSource.

Unit
releasePeriod(mediaPeriod: MediaPeriod!)

Releases the period.

Unit

Releases the source, see releaseSource.

synchronized Unit
setAllowPreparation(allowPreparation: Boolean)

Sets whether the next call to prepareSource is allowed to finish.

Unit
setCanUpdateMediaItems(canUpdateMediaItems: Boolean)

Sets whether the source allows to update its MediaItem via updateMediaItem.

Unit
setNewSourceInfo(newTimeline: Timeline!)

Sets a new timeline.

synchronized Unit
setNewSourceInfo(newTimeline: Timeline!, sendManifestLoadEvents: Boolean)

Sets a new timeline.

Unit
setPeriodDefersOnPreparedCallback(
    periodDefersOnPreparedCallback: Boolean
)

Sets whether the created period should defer to call onPrepared.

Unit

Updates the MediaItem for this source.

Public constructors

FakeAdaptiveMediaSource

FakeAdaptiveMediaSource(
    timeline: Timeline!,
    trackGroupArray: TrackGroupArray!,
    chunkSourceFactory: FakeChunkSource.Factory!
)

Public functions

releaseMediaPeriod

fun releaseMediaPeriod(mediaPeriod: MediaPeriod!): Unit

Releases a media period created by createMediaPeriod.

Protected functions

createMediaPeriod

protected fun createMediaPeriod(
    id: MediaSource.MediaPeriodId!,
    trackGroupArray: TrackGroupArray!,
    allocator: Allocator!,
    mediaSourceEventDispatcher: MediaSourceEventListener.EventDispatcher!,
    drmSessionManager: DrmSessionManager!,
    drmEventDispatcher: DrmSessionEventListener.EventDispatcher!,
    transferListener: TransferListener?
): MediaPeriod!

Creates a MediaPeriod for this media source.

Parameters
id: MediaSource.MediaPeriodId!

The identifier of the period.

trackGroupArray: TrackGroupArray!

The TrackGroupArray supported by the media period.

allocator: Allocator!

An Allocator from which to obtain media buffer allocations.

mediaSourceEventDispatcher: MediaSourceEventListener.EventDispatcher!

An MediaSourceEventListener.EventDispatcher to dispatch media source events.

drmSessionManager: DrmSessionManager!

A DrmSessionManager to allow DRM interactions.

drmEventDispatcher: DrmSessionEventListener.EventDispatcher!

An MediaSourceEventListener.EventDispatcher to dispatch DRM events.

transferListener: TransferListener?

The transfer listener which should be informed of any data transfers. May be null if no listener is available.

Returns
MediaPeriod!

A new MediaPeriod.