DefaultPreloadManager


@UnstableApi
class DefaultPreloadManager : 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 = )
annotation DefaultPreloadManager.Status.Stage

Stages for the preload status.

Public constructors

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

This function is deprecated.

Use Builder instead.

Public functions

MediaSource!

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

Unit
setCurrentPlayingIndex(currentPlayingIndex: Int)

Sets the index of the current playing media.

Protected functions

Unit

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

Unit
preloadSourceInternal(mediaSource: MediaSource!, startPositionsUs: Long)

Preloads the given MediaSource.

Unit

Releases the preload manager, see release.

Unit

Releases the given MediaSource.

Inherited functions

From androidx.media3.exoplayer.source.preload.BasePreloadManager
Unit
add(mediaItem: MediaItem!, rankingData: T!)

Adds a MediaItem with its rankingData to the preload manager.

Unit
add(mediaSource: MediaSource!, rankingData: T!)

Adds a MediaSource with its rankingData to the preload manager.

Unit

Adds a Listener to listen to the preload events.

Unit

Clears all the listeners.

MediaSource?

Returns the MediaSource for the given MediaItem.

Int

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

TargetPreloadStatusControl.PreloadStatus?

Returns the target preload status of the given MediaSource.

Unit

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

Unit

Called when the given MediaSource completes preloading.

Unit

Called when an error occurs.

Unit

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

Unit

Releases the preload manager.

Boolean
remove(mediaItem: MediaItem!)

Removes a MediaItem from the preload manager.

Boolean
remove(mediaSource: MediaSource!)

Removes a MediaSource from the preload manager.

Unit

Removes a Listener.

Unit

Resets the preload manager.

Boolean

Returns whether the next MediaSource should start preloading.

Public constructors

DefaultPreloadManager

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

Public functions

createMediaSourceForPreloading

fun createMediaSourceForPreloading(mediaSource: 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

fun setCurrentPlayingIndex(currentPlayingIndex: Int): Unit

Sets the index of the current playing media.

Parameters
currentPlayingIndex: Int

The index of current playing media.

Protected functions

clearSourceInternal

protected fun clearSourceInternal(mediaSource: MediaSource!): Unit

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 fun preloadSourceInternal(mediaSource: MediaSource!, startPositionsUs: Long): Unit

Preloads the given MediaSource.

Parameters
mediaSource: MediaSource!

The media source to preload.

startPositionsUs: Long

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

releaseInternal

protected fun releaseInternal(): Unit

Releases the preload manager, see release.

releaseSourceInternal

protected fun releaseSourceInternal(mediaSource: MediaSource!): Unit

Releases the given MediaSource.

Parameters
mediaSource: MediaSource!

The media source to release.