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

A builder for DefaultPreloadManager instances.

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 for the preload status.

Public constructors

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

This method is deprecated.

Use Builder instead.

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

Clears the preloaded data of the given MediaSource, while not releasing the instance of it.

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.

void

Adds a Listener to listen to the preload events.

void

Clears all the listeners.

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 preloading.

final void

Called when an error occurs.

final void

Called when the given MediaSource has been skipped before completing preloading.

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.

void

Removes a Listener.

final void

Resets 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
)

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

clearSourceInternal

protected void clearSourceInternal(MediaSource mediaSource)

Clears the preloaded data of the given MediaSource, while not releasing the instance of it.

Parameters
MediaSource mediaSource

The media source to clear.

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.