PreloadMediaSource.Factory


public final class PreloadMediaSource.Factory implements MediaSource.Factory


Factory for PreloadMediaSource.

Summary

Public constructors

Factory(
    MediaSource.Factory mediaSourceFactory,
    PreloadMediaSource.PreloadControl preloadControl,
    TrackSelector trackSelector,
    BandwidthMeter bandwidthMeter,
    RendererCapabilities[] rendererCapabilities,
    LoadControl loadControl,
    Looper preloadLooper
)

Creates a new factory for PreloadMediaSource.

Inherited methods

From androidx.media3.exoplayer.source.MediaSource.Factory
MediaSource.Factory
@UnstableApi
experimentalParseSubtitlesDuringExtraction(
    boolean parseSubtitlesDuringExtraction
)

This method is deprecated.

This method (and all support for 'legacy' subtitle decoding during rendering) will be removed in a future release.

MediaSource.Factory

Sets the set of video codecs for which within GOP sample dependency information should be parsed as part of extraction.

MediaSource.Factory

Sets a supplier for an ReleasableExecutor that is used for loading the media.

MediaSource.Factory

Sets the SubtitleParser.Factory to be used for parsing subtitles during extraction.

Public constructors

Factory

public Factory(
    MediaSource.Factory mediaSourceFactory,
    PreloadMediaSource.PreloadControl preloadControl,
    TrackSelector trackSelector,
    BandwidthMeter bandwidthMeter,
    RendererCapabilities[] rendererCapabilities,
    LoadControl loadControl,
    Looper preloadLooper
)

Creates a new factory for PreloadMediaSource.

Parameters
MediaSource.Factory mediaSourceFactory

The underlying MediaSource.Factory.

PreloadMediaSource.PreloadControl preloadControl

The PreloadControl that will control the progress of preloading the created PreloadMediaSource instances.

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 is injected by setBandwidthMeter.

RendererCapabilities[] rendererCapabilities

The array of RendererCapabilities. It should be derived from the same RenderersFactory of the ExoPlayer that is injected by setRenderersFactory.

LoadControl loadControl

The LoadControl. It should be the same instance of the ExoPlayer that is injected by setLoadControl.

Looper preloadLooper

The Looper that will be used for preloading. It should be the same looper with setPlaybackLooper that will play the created PreloadMediaSource instances.

Public methods

createMediaSource

public PreloadMediaSource createMediaSource(MediaItem mediaItem)

Creates a new MediaSource with the specified MediaItem.

Parameters
MediaItem mediaItem

The media item to play.

Returns
PreloadMediaSource

The new media source.

createMediaSource

public PreloadMediaSource createMediaSource(MediaSource mediaSource)

getSupportedTypes

public int[] getSupportedTypes()

Returns the content types supported by media sources created by this factory.

setClock

@CanIgnoreReturnValue
public PreloadMediaSource.Factory setClock(Clock clock)

Sets the Clock that will be used by the PreloadMediaSource. Should only be set for testing purposes.

Returns
PreloadMediaSource.Factory

This factory, for convenience.

setCmcdConfigurationFactory

@CanIgnoreReturnValue
public PreloadMediaSource.Factory setCmcdConfigurationFactory(
    CmcdConfiguration.Factory cmcdConfigurationFactory
)

Sets the CmcdConfiguration.Factory used to obtain a CmcdConfiguration for a MediaItem.

Returns
PreloadMediaSource.Factory

This factory, for convenience.

setDrmSessionManagerProvider

@CanIgnoreReturnValue
public PreloadMediaSource.Factory setDrmSessionManagerProvider(
    DrmSessionManagerProvider drmSessionManagerProvider
)

Sets the DrmSessionManagerProvider used to obtain a DrmSessionManager for a MediaItem.

Returns
PreloadMediaSource.Factory

This factory, for convenience.

setLoadErrorHandlingPolicy

@CanIgnoreReturnValue
public PreloadMediaSource.Factory setLoadErrorHandlingPolicy(
    LoadErrorHandlingPolicy loadErrorHandlingPolicy
)

Sets an optional LoadErrorHandlingPolicy.

Returns
PreloadMediaSource.Factory

This factory, for convenience.