DefaultPreloadManager


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

Stages that for the preload status.

Public constructors

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

Constructs a new instance.

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

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 to preload.

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.

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

Constructs a new instance.

Parameters
targetPreloadStatusControl: TargetPreloadStatusControl<Int!>!

The TargetPreloadStatusControl.

mediaSourceFactory: MediaSource.Factory!

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.

rendererCapabilitiesListFactory: RendererCapabilitiesList.Factory!

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.

preloadLooper: Looper!

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

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

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.