public interface

MediaSource.Factory

 androidx.media3.exoplayer.source.MediaSource.Factory

Subclasses:

ImaServerSideAdInsertionMediaSource.Factory, RtspMediaSource.Factory, HlsMediaSource.Factory, SsMediaSource.Factory, DashMediaSource.Factory, ExternallyLoadedMediaSource.Factory, ProgressiveMediaSource.Factory, DefaultMediaSourceFactory, MediaSourceFactory, PreloadMediaSource.Factory, FakeMediaSourceFactory

Overview

Factory for creating MediaSources from MediaItems.

Summary

Fields
public static final MediaSource.FactoryUNSUPPORTED

An instance that throws java.lang.UnsupportedOperationException from MediaSource.Factory.createMediaSource(MediaItem) and MediaSource.Factory.getSupportedTypes().

Methods
public MediaSourcecreateMediaSource(MediaItem mediaItem)

Creates a new MediaSource with the specified MediaItem.

public MediaSource.FactoryexperimentalParseSubtitlesDuringExtraction(boolean parseSubtitlesDuringExtraction)

Sets whether subtitles should be parsed as part of extraction (before being added to the sample queue) or as part of rendering (when being taken from the sample queue).

public int[]getSupportedTypes()

Returns the supported by media sources created by this factory.

public MediaSource.FactorysetCmcdConfigurationFactory(CmcdConfiguration.Factory cmcdConfigurationFactory)

Sets the used to obtain a CmcdConfiguration for a MediaItem.

public MediaSource.FactorysetDrmSessionManagerProvider(DrmSessionManagerProvider drmSessionManagerProvider)

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

public MediaSource.FactorysetLoadErrorHandlingPolicy(LoadErrorHandlingPolicy loadErrorHandlingPolicy)

Sets an optional LoadErrorHandlingPolicy.

public MediaSource.FactorysetSubtitleParserFactory(SubtitleParser.Factory subtitleParserFactory)

Sets the to be used for parsing subtitles during extraction.

Fields

public static final MediaSource.Factory UNSUPPORTED

An instance that throws java.lang.UnsupportedOperationException from MediaSource.Factory.createMediaSource(MediaItem) and MediaSource.Factory.getSupportedTypes().

Methods

public MediaSource.Factory setCmcdConfigurationFactory(CmcdConfiguration.Factory cmcdConfigurationFactory)

Sets the used to obtain a CmcdConfiguration for a MediaItem.

Returns:

This factory, for convenience.

public MediaSource.Factory setDrmSessionManagerProvider(DrmSessionManagerProvider drmSessionManagerProvider)

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

Returns:

This factory, for convenience.

public MediaSource.Factory setLoadErrorHandlingPolicy(LoadErrorHandlingPolicy loadErrorHandlingPolicy)

Sets an optional LoadErrorHandlingPolicy.

Returns:

This factory, for convenience.

public MediaSource.Factory experimentalParseSubtitlesDuringExtraction(boolean parseSubtitlesDuringExtraction)

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

Sets whether subtitles should be parsed as part of extraction (before being added to the sample queue) or as part of rendering (when being taken from the sample queue). Defaults to true (i.e. subtitles will be parsed during extraction).

This method is experimental and will be renamed or removed in a future release.

Parameters:

parseSubtitlesDuringExtraction: Whether to parse subtitles during extraction or rendering.

Returns:

This factory, for convenience.

public MediaSource.Factory setSubtitleParserFactory(SubtitleParser.Factory subtitleParserFactory)

Sets the to be used for parsing subtitles during extraction.

Parameters:

subtitleParserFactory: The for parsing subtitles during extraction.

Returns:

This factory, for convenience.

public int[] getSupportedTypes()

Returns the supported by media sources created by this factory.

public MediaSource createMediaSource(MediaItem mediaItem)

Creates a new MediaSource with the specified MediaItem.

Parameters:

mediaItem: The media item to play.

Returns:

The new media source.