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.

Defines the preload status for the DefaultPreloadManager.

Stages for the preload status.

Public methods

void
setCurrentPlayingIndex(int currentPlayingIndex)

Sets the index of the current playing media.

Protected methods

BasePreloadManager.MediaSourceHolder
createMediaSourceHolder(
    MediaItem mediaItem,
    @Nullable MediaSource mediaSource,
    Integer rankingData
)

Returns the MediaSourceHolder that the preload manager creates for preloading based on the given MediaItem and MediaSource.

void

Preloads the given MediaSourceHolder.

void

Releases the preload manager, see release.

void

Releases the given MediaSourceHolder.

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 PreloadManagerListener to listen to the preload events.

final void
addMediaItems(List<MediaItem> mediaItems, List<T> rankingDataList)

Adds a list of media items with their rankingData to the preload manager.

final void
addMediaSources(
    List<MediaSource> mediaSources,
    List<T> rankingDataList
)

Adds a list of media sources with their rankingData to the preload manager.

void

Clears all the listeners.

final @Nullable MediaSource

Returns the MediaSource for the given MediaItem.

@Nullable BasePreloadManager.MediaSourceHolder
final int

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

final @Nullable PreloadStatusT
final @Nullable PreloadStatusT
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
onCompleted(
    MediaItem mediaItem,
    Predicate<PreloadStatusT> shouldNotifyListenerAndAdvancePredicate
)

Called when the given MediaItem completes preloading.

final void
onCompleted(
    MediaSource mediaSource,
    Predicate<PreloadStatusT> shouldNotifyListenerAndAdvancePredicate
)

Called when the given MediaSource completes preloading.

final void
onError(
    PreloadException error,
    MediaItem mediaItem,
    Predicate<PreloadStatusT> shouldNotifyListenerAndAdvancePredicate
)

Called when an error occurs.

final void
onError(
    PreloadException error,
    MediaSource mediaSource,
    Predicate<PreloadStatusT> shouldNotifyListenerAndAdvancePredicate
)

Called when an error occurs.

final void
onMediaSourceUpdated(
    MediaItem mediaItem,
    MediaSource updatedMediaSource
)

Called when the given MediaItem has its corresponding MediaSource updated.

final void
onSkipped(
    MediaSource mediaSource,
    Predicate<PreloadStatusT> shouldAdvancePredicate
)

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

final void

Called when there is a MediaSource has been cleared.

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

final void

Removes a list of media items from the preload manager.

final void

Removes a list of media sources from the preload manager.

final void

Resets the preload manager.

boolean

Returns whether the next MediaSource should start preloading.

Public methods

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

createMediaSourceHolder

protected BasePreloadManager.MediaSourceHolder createMediaSourceHolder(
    MediaItem mediaItem,
    @Nullable MediaSource mediaSource,
    Integer rankingData
)

Returns the MediaSourceHolder that the preload manager creates for preloading based on the given MediaItem and MediaSource.

Parameters
MediaItem mediaItem

The MediaItem.

@Nullable MediaSource mediaSource

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

Integer rankingData

The ranking data that is associated with the mediaItem.

Returns
BasePreloadManager.MediaSourceHolder

The MediaSourceHolder the preload manager creates for preloading.

preloadMediaSourceHolderInternal

protected void preloadMediaSourceHolderInternal(
    BasePreloadManager.MediaSourceHolder mediaSourceHolder,
    DefaultPreloadManager.PreloadStatus targetPreloadStatus
)

Preloads the given MediaSourceHolder.

Parameters
BasePreloadManager.MediaSourceHolder mediaSourceHolder

The MediaSourceHolder to preload.

DefaultPreloadManager.PreloadStatus targetPreloadStatus

The target preload status.

releaseInternal

protected void releaseInternal()

Releases the preload manager, see release.

releaseMediaSourceHolderInternal

protected void releaseMediaSourceHolderInternal(
    BasePreloadManager.MediaSourceHolder mediaSourceHolder
)

Releases the given MediaSourceHolder.

Parameters
BasePreloadManager.MediaSourceHolder mediaSourceHolder

The MediaSourceHolder to remove.