DefaultPreloadManager


@UnstableApi
public final class DefaultPreloadManager extends BasePreloadManager


A preload manager that preloads with the PreloadMediaSource to load the media data into the SampleQueue.

Summary

Nested types

An implementation of TargetPreloadStatusControl.PreloadStatus that describes the preload status of the PreloadMediaSource.

@Documented
@Retention(value = RetentionPolicy.SOURCE)
@Target(value = TYPE_USE)
@IntDef(value = )
public annotation DefaultPreloadManager.Status.Stage

Stages that for the preload status.

Public constructors

DefaultPreloadManager(
    TargetPreloadStatusControl<Integer> targetPreloadStatusControl,
    MediaSource.Factory mediaSourceFactory,
    TrackSelector trackSelector,
    BandwidthMeter bandwidthMeter,
    RendererCapabilitiesList.Factory rendererCapabilitiesListFactory,
    Allocator allocator,
    Looper preloadLooper
)

Constructs a new instance.

Public methods

MediaSource

Returns the MediaSource that the preload manager creates for preloading based on the given source.

void
setCurrentPlayingIndex(int currentPlayingIndex)

Sets the index of the current playing media.

Protected methods

void
preloadSourceInternal(MediaSource mediaSource, long startPositionsUs)

Preloads the given MediaSource.

void

Releases the preload manager, see release.

void

Releases the given MediaSource.

Inherited methods

From androidx.media3.exoplayer.source.preload.BasePreloadManager
final void
add(MediaItem mediaItem, T rankingData)

Adds a MediaItem with its rankingData to the preload manager.

final void
add(MediaSource mediaSource, T rankingData)

Adds a MediaSource with its rankingData to the preload manager.

final @Nullable MediaSource

Returns the MediaSource for the given MediaItem.

final int

Gets the count of the media sources currently being managed by the preload manager.

final @Nullable TargetPreloadStatusControl.PreloadStatus

Returns the target preload status of the given MediaSource.

final void

Invalidates the current preload progress, and triggers a new preload progress based on the new priorities of the managed media sources.

final void

Called when the given MediaSource completes to preload.

final void

Releases the preload manager.

final boolean
remove(MediaItem mediaItem)

Removes a MediaItem from the preload manager.

final boolean
remove(MediaSource mediaSource)

Removes a MediaSource from the preload manager.

boolean

Returns whether the next MediaSource should start preloading.

Public constructors

DefaultPreloadManager

public DefaultPreloadManager(
    TargetPreloadStatusControl<Integer> targetPreloadStatusControl,
    MediaSource.Factory mediaSourceFactory,
    TrackSelector trackSelector,
    BandwidthMeter bandwidthMeter,
    RendererCapabilitiesList.Factory rendererCapabilitiesListFactory,
    Allocator allocator,
    Looper preloadLooper
)

Constructs a new instance.

Parameters
TargetPreloadStatusControl<Integer> targetPreloadStatusControl

The TargetPreloadStatusControl.

MediaSource.Factory mediaSourceFactory

The MediaSource.Factory.

TrackSelector trackSelector

The TrackSelector. The instance passed should be initialized.

BandwidthMeter bandwidthMeter

The BandwidthMeter. It should be the same bandwidth meter of the ExoPlayer that will play the managed PreloadMediaSource.

RendererCapabilitiesList.Factory rendererCapabilitiesListFactory

The RendererCapabilitiesList.Factory. To make preloading work properly, it must create a RendererCapabilitiesList holding an array of renderer capabilities that matches the count and the renderer types of the array of renderers created by the RenderersFactory used by the ExoPlayer that will play the managed PreloadMediaSource.

Allocator allocator

The Allocator. It should be the same allocator of the that will play the managed PreloadMediaSource.

Looper preloadLooper

The Looper that will be used for preloading. It should be the same playback looper of the ExoPlayer that will play the manager .

Public methods

createMediaSourceForPreloading

public MediaSource createMediaSourceForPreloading(MediaSource mediaSource)

Returns the MediaSource that the preload manager creates for preloading based on the given source. The default implementation returns the same source.

Parameters
MediaSource mediaSource

The source based on which the preload manager creates for preloading.

Returns
MediaSource

The source the preload manager creates for preloading.

setCurrentPlayingIndex

public void setCurrentPlayingIndex(int currentPlayingIndex)

Sets the index of the current playing media.

Parameters
int currentPlayingIndex

The index of current playing media.

Protected methods

preloadSourceInternal

protected void preloadSourceInternal(MediaSource mediaSource, long startPositionsUs)

Preloads the given MediaSource.

Parameters
MediaSource mediaSource

The media source to preload.

long startPositionsUs

The expected starting position in microseconds, or TIME_UNSET to indicate the default start position.

releaseInternal

protected void releaseInternal()

Releases the preload manager, see release.

releaseSourceInternal

protected void releaseSourceInternal(MediaSource mediaSource)

Releases the given MediaSource.

Parameters
MediaSource mediaSource

The media source to release.