FakeAdaptiveMediaSource


@UnstableApi
public class FakeAdaptiveMediaSource extends 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,
    FakeChunkSource.Factory chunkSourceFactory
)

Public methods

void

Releases a media period created by createMediaPeriod.

Protected methods

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

Creates a MediaPeriod for this media source.

Inherited Constants

From androidx.media3.test.utils.FakeMediaSource
static final MediaItem

The media item used by the fake media source.

Inherited methods

From androidx.media3.exoplayer.source.BaseMediaSource
final void
@UnstableApi
addDrmEventListener(
    Handler handler,
    DrmSessionEventListener eventListener
)

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

final void
@UnstableApi
addEventListener(
    Handler handler,
    MediaSourceEventListener eventListener
)

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

final DrmSessionEventListener.EventDispatcher

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

final DrmSessionEventListener.EventDispatcher
createDrmEventDispatcher(
    int windowIndex,
    @Nullable MediaSource.MediaPeriodId mediaPeriodId
)

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

final MediaSourceEventListener.EventDispatcher

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

final MediaSourceEventListener.EventDispatcher
createEventDispatcher(
    MediaSource.MediaPeriodId mediaPeriodId,
    long mediaTimeOffsetMs
)

This method is deprecated.

Use createEventDispatcher instead.

final MediaSourceEventListener.EventDispatcher
createEventDispatcher(
    int windowIndex,
    @Nullable MediaSource.MediaPeriodId mediaPeriodId
)

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

final MediaSourceEventListener.EventDispatcher
createEventDispatcher(
    int windowIndex,
    @Nullable MediaSource.MediaPeriodId mediaPeriodId,
    long mediaTimeOffsetMs
)

This method is deprecated.

Use createEventDispatcher instead.

final void

Disables the source for the creation of MediaPeriods.

void

Disables the source, see disable.

final void

Enables the source for the creation of MediaPeriods.

void

Enables the source, see enable.

final PlayerId

Returns the PlayerId of the player using this media source.

final boolean

Returns whether the source is enabled.

final void
@UnstableApi
prepareSource(
    MediaSource.MediaSourceCaller caller,
    @Nullable TransferListener mediaTransferListener
)

This method is deprecated.

Implement prepareSource instead.

final void
@UnstableApi
prepareSource(
    MediaSource.MediaSourceCaller caller,
    @Nullable TransferListener mediaTransferListener,
    PlayerId playerId
)

Registers a MediaSourceCaller.

final boolean

Returns whether the source has prepareSource called.

final void

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

final void

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

final void

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

final void

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

final void

Sets the PlayerId of the player using this media source.

From androidx.media3.test.utils.FakeMediaSource
void

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

void

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(
    MediaSource.MediaPeriodId id,
    Allocator allocator,
    long startPositionUs
)

Returns a new MediaPeriod identified by periodId.

static FakeMediaSource

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

List<MediaSource.MediaPeriodId>

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

@Nullable 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.

@Nullable Timeline
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.

void

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

synchronized void

Starts source preparation and enables the source, see prepareSource.

void

Releases the period.

void

Releases the source, see releaseSource.

synchronized void
setAllowPreparation(boolean allowPreparation)

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

void
setCanUpdateMediaItems(boolean canUpdateMediaItems)

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

void

Sets a new timeline.

synchronized void
setNewSourceInfo(Timeline newTimeline, boolean sendManifestLoadEvents)

Sets a new timeline.

void
setPeriodDefersOnPreparedCallback(
    boolean periodDefersOnPreparedCallback
)

Sets whether the created period should defer to call onPrepared.

void

Updates the MediaItem for this source.

Public constructors

FakeAdaptiveMediaSource

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

Public methods

releaseMediaPeriod

public void releaseMediaPeriod(MediaPeriod mediaPeriod)

Releases a media period created by createMediaPeriod.

Protected methods

createMediaPeriod

protected MediaPeriod createMediaPeriod(
    MediaSource.MediaPeriodId id,
    TrackGroupArray trackGroupArray,
    Allocator allocator,
    MediaSourceEventListener.EventDispatcher mediaSourceEventDispatcher,
    DrmSessionManager drmSessionManager,
    DrmSessionEventListener.EventDispatcher drmEventDispatcher,
    @Nullable TransferListener transferListener
)

Creates a MediaPeriod for this media source.

Parameters
MediaSource.MediaPeriodId id

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.

MediaSourceEventListener.EventDispatcher mediaSourceEventDispatcher

An MediaSourceEventListener.EventDispatcher to dispatch media source events.

DrmSessionManager drmSessionManager

A DrmSessionManager to allow DRM interactions.

DrmSessionEventListener.EventDispatcher drmEventDispatcher

An MediaSourceEventListener.EventDispatcher to dispatch DRM events.

@Nullable 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.