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,
    Allocator allocator,
    Looper preloadLooper
)

Creates a new factory for PreloadMediaSource.

Public methods

PreloadMediaSource

Creates a new MediaSource with the specified MediaItem.

PreloadMediaSource
int[]

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

PreloadMediaSource.Factory
setCmcdConfigurationFactory(
    CmcdConfiguration.Factory cmcdConfigurationFactory
)

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

PreloadMediaSource.Factory
setDrmSessionManagerProvider(
    DrmSessionManagerProvider drmSessionManagerProvider
)

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

PreloadMediaSource.Factory
setLoadErrorHandlingPolicy(
    LoadErrorHandlingPolicy loadErrorHandlingPolicy
)

Sets an optional LoadErrorHandlingPolicy.

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 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,
    Allocator allocator,
    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.

Allocator allocator

The Allocator. It should be the same allocator of the 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.

setCmcdConfigurationFactory

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

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

public PreloadMediaSource.Factory setLoadErrorHandlingPolicy(
    LoadErrorHandlingPolicy loadErrorHandlingPolicy
)

Sets an optional LoadErrorHandlingPolicy.

Returns
PreloadMediaSource.Factory

This factory, for convenience.