MediaSource.Factory


public interface MediaSource.Factory


Factory for creating MediaSources from MediaItems.

Summary

Constants

default static final MediaSource.Factory

An instance that throws UnsupportedOperationException from createMediaSource and getSupportedTypes.

Public methods

abstract MediaSource

Creates a new MediaSource with the specified MediaItem.

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

abstract int[]

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

default MediaSource.Factory

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

abstract MediaSource.Factory

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

abstract MediaSource.Factory

Sets an optional LoadErrorHandlingPolicy.

default MediaSource.Factory

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

Constants

UNSUPPORTED

@UnstableApi
default static final MediaSource.Factory UNSUPPORTED

An instance that throws UnsupportedOperationException from createMediaSource and getSupportedTypes.

Public methods

createMediaSource

@UnstableApi
abstract MediaSource createMediaSource(MediaItem mediaItem)

Creates a new MediaSource with the specified MediaItem.

Parameters
MediaItem mediaItem

The media item to play.

Returns
MediaSource

The new media source.

experimentalParseSubtitlesDuringExtraction

@UnstableApi
default MediaSource.Factory experimentalParseSubtitlesDuringExtraction(
    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). 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
boolean parseSubtitlesDuringExtraction

Whether to parse subtitles during extraction or rendering.

Returns
MediaSource.Factory

This factory, for convenience.

getSupportedTypes

@UnstableApi
@C.ContentType
abstract int[] getSupportedTypes()

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

setCmcdConfigurationFactory

@UnstableApi
default MediaSource.Factory setCmcdConfigurationFactory(
    CmcdConfiguration.Factory cmcdConfigurationFactory
)

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

Returns
MediaSource.Factory

This factory, for convenience.

setDrmSessionManagerProvider

@UnstableApi
abstract MediaSource.Factory setDrmSessionManagerProvider(
    DrmSessionManagerProvider drmSessionManagerProvider
)

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

Returns
MediaSource.Factory

This factory, for convenience.

setLoadErrorHandlingPolicy

@UnstableApi
abstract MediaSource.Factory setLoadErrorHandlingPolicy(
    LoadErrorHandlingPolicy loadErrorHandlingPolicy
)

Sets an optional LoadErrorHandlingPolicy.

Returns
MediaSource.Factory

This factory, for convenience.

setSubtitleParserFactory

@UnstableApi
default MediaSource.Factory setSubtitleParserFactory(SubtitleParser.Factory subtitleParserFactory)

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

Parameters
SubtitleParser.Factory subtitleParserFactory

The SubtitleParser.Factory for parsing subtitles during extraction.

Returns
MediaSource.Factory

This factory, for convenience.