PillarboxPreloadManager

class PillarboxPreloadManager(context: Context, targetPreloadStatusControl: TargetPreloadStatusControl<Int>? = null, mediaSourceFactory: PillarboxMediaSourceFactory = PillarboxMediaSourceFactory(context), trackSelector: TrackSelector = PillarboxTrackSelector(context), bandwidthMeter: BandwidthMeter = PillarboxBandwidthMeter(context), renderersFactory: RenderersFactory = PillarboxRenderersFactory(context), loadControl: LoadControl = PillarboxLoadControl(), playbackThread: HandlerThread = HandlerThread("PillarboxPreloadManager:Playback", Process.THREAD_PRIORITY_AUDIO))

Helper class for Media3's DefaultPreloadManager that simplifies preloading of media items for PillarboxExoPlayer.

Parameters

context

The Context.

targetPreloadStatusControl

The TargetPreloadStatusControl to decide when to preload an item and for how long.

mediaSourceFactory
trackSelector

The TrackSelector for this preload manager.

bandwidthMeter

The BandwidthMeter for this preload manager.

renderersFactory

The RenderersFactory for this preload manager.

loadControl

The LoadControl for this preload manager.

playbackThread

The Thread on which the players run. Its lifecycle is handled internally by PillarboxPreloadManager.

See also

Constructors

Link copied to clipboard
constructor(context: Context, targetPreloadStatusControl: TargetPreloadStatusControl<Int>? = null, mediaSourceFactory: PillarboxMediaSourceFactory = PillarboxMediaSourceFactory(context), trackSelector: TrackSelector = PillarboxTrackSelector(context), bandwidthMeter: BandwidthMeter = PillarboxBandwidthMeter(context), renderersFactory: RenderersFactory = PillarboxRenderersFactory(context), loadControl: LoadControl = PillarboxLoadControl(), playbackThread: HandlerThread = HandlerThread("PillarboxPreloadManager:Playback", Process.THREAD_PRIORITY_AUDIO))

Types

Link copied to clipboard

Default implementation of TargetPreloadStatusControl that manages the preload status of items based on their proximity to the currently playing item.

Properties

Link copied to clipboard

The index of the currently playing media item.

Link copied to clipboard

The Looper associated with the Thread on which playback operations are performed by the PillarboxExoPlayer.

Link copied to clipboard

Gets the count of the MediaSources currently being managed by the preload manager.

Functions

Link copied to clipboard
fun add(mediaItem: MediaItem, rankingData: Int)

Adds a MediaItem with its rankingData to the preload manager.

fun add(mediaSource: MediaSource, rankingData: Int)

Adds a MediaSource with its rankingData to the preload manager.

Link copied to clipboard

Returns the MediaSource for the given MediaItem.

Link copied to clipboard

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

Link copied to clipboard
fun release()

Releases the preload manager. The preload manager must not be used after calling this method.

Link copied to clipboard
fun remove(mediaItem: MediaItem): Boolean

Removes a MediaItem from the preload manager.

fun remove(mediaSource: MediaSource): Boolean

Removes a MediaSource from the preload manager.

Link copied to clipboard
fun reset()

Resets the preload manager. All sources that the preload manager is holding will be released.