DefaultMediaSourceFactory


class DefaultMediaSourceFactory : MediaSourceFactory


The default MediaSource.Factory implementation.

This implementation delegates calls to createMediaSource to the following factories:

Ad support for media items with ad tag URIs

To support media items with ads configuration, setAdsLoaderProvider and setAdViewProvider need to be called to configure the factory with the required providers.

Summary

Nested types

This interface is deprecated.

Use AdsLoader.Provider instead.

Public constructors

Creates a new instance.

Creates a new instance.

@UnstableApi
DefaultMediaSourceFactory(
    context: Context!,
    extractorsFactory: ExtractorsFactory!
)

Creates a new instance.

@UnstableApi
DefaultMediaSourceFactory(
    dataSourceFactory: DataSource.Factory!,
    extractorsFactory: ExtractorsFactory!
)

Creates a new instance.

Public functions

DefaultMediaSourceFactory!

Clear any values set via setLocalAdInsertionComponents.

MediaSource!

Creates a new MediaSource with the specified MediaItem.

DefaultMediaSourceFactory!

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

IntArray<Int>!

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

DefaultMediaSourceFactory!

This function is deprecated.

Use setLocalAdInsertionComponents instead.

DefaultMediaSourceFactory!

This function is deprecated.

Use setLocalAdInsertionComponents instead.

DefaultMediaSourceFactory!

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

DefaultMediaSourceFactory!

Sets the DataSource.Factory used to create DataSource instances for requesting media data.

DefaultMediaSourceFactory!

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

DefaultMediaSourceFactory!

Sets the ExternalLoader to be called when loading starts in when loading images in an external Image Management Framework (for example, Glide).

DefaultMediaSourceFactory!

Sets the maximum offset from the live edge for live streams, in milliseconds.

DefaultMediaSourceFactory!

Sets the maximum playback speed for live streams.

DefaultMediaSourceFactory!

Sets the minimum offset from the live edge for live streams, in milliseconds.

DefaultMediaSourceFactory!

Sets the minimum playback speed for live streams.

DefaultMediaSourceFactory!

Sets the target live offset for live streams, in milliseconds.

DefaultMediaSourceFactory!

Sets an optional LoadErrorHandlingPolicy.

DefaultMediaSourceFactory!
@CanIgnoreReturnValue
setLocalAdInsertionComponents(
    adsLoaderProvider: AdsLoader.Provider!,
    adViewProvider: AdViewProvider!
)

Sets the components required for local ad insertion for media items that have ads configurations

DefaultMediaSourceFactory!

Sets the MediaSource.Factory used to handle MediaItem instances containing a Uri identified as resolving to content with server side ad insertion (SSAI).

DefaultMediaSourceFactory!

Sets the SubtitleParser.Factory to be used for parsing subtitles during extraction if experimentalParseSubtitlesDuringExtraction is enabled.

Public constructors

DefaultMediaSourceFactory

DefaultMediaSourceFactory(context: Context!)

Creates a new instance.

Parameters
context: Context!

Any context.

DefaultMediaSourceFactory

@UnstableApi
DefaultMediaSourceFactory(dataSourceFactory: DataSource.Factory!)

Creates a new instance.

Note that this constructor is only useful to try and ensure that ExoPlayer's can be removed by ProGuard or R8.

Parameters
dataSourceFactory: DataSource.Factory!

A DataSource.Factory to create DataSource instances for requesting media data.

DefaultMediaSourceFactory

@UnstableApi
DefaultMediaSourceFactory(
    context: Context!,
    extractorsFactory: ExtractorsFactory!
)

Creates a new instance.

Note that this constructor is only useful to try and ensure that ExoPlayer's can be removed by ProGuard or R8.

Parameters
context: Context!

Any context.

extractorsFactory: ExtractorsFactory!

An ExtractorsFactory used to extract progressive media from its container.

DefaultMediaSourceFactory

@UnstableApi
DefaultMediaSourceFactory(
    dataSourceFactory: DataSource.Factory!,
    extractorsFactory: ExtractorsFactory!
)

Creates a new instance.

Note that this constructor is only useful to try and ensure that ExoPlayer's and DefaultExtractorsFactory can be removed by ProGuard or R8.

Parameters
dataSourceFactory: DataSource.Factory!

A DataSource.Factory to create DataSource instances for requesting media data.

extractorsFactory: ExtractorsFactory!

An ExtractorsFactory used to extract progressive media from its container.

Public functions

clearLocalAdInsertionComponents

@CanIgnoreReturnValue
fun clearLocalAdInsertionComponents(): DefaultMediaSourceFactory!

Clear any values set via setLocalAdInsertionComponents.

This will also clear any values set by setAdsLoaderProvider and setAdViewProvider.

Returns
DefaultMediaSourceFactory!

This factory, for convenience.

createMediaSource

@UnstableApi
fun createMediaSource(mediaItem: MediaItem!): MediaSource!

Creates a new MediaSource with the specified MediaItem.

Parameters
mediaItem: MediaItem!

The media item to play.

Returns
MediaSource!

The new media source.

experimentalParseSubtitlesDuringExtraction

@CanIgnoreReturnValue
@UnstableApi
fun experimentalParseSubtitlesDuringExtraction(
    parseSubtitlesDuringExtraction: Boolean
): DefaultMediaSourceFactory!

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 false (i.e. subtitles will be parsed as part of rendering).

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

Parameters
parseSubtitlesDuringExtraction: Boolean

Whether to parse subtitles during extraction or rendering.

Returns
DefaultMediaSourceFactory!

This factory, for convenience.

getSupportedTypes

@UnstableApi
@C.ContentType
fun getSupportedTypes(): IntArray<Int>!

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

setAdViewProvider

@CanIgnoreReturnValue
@UnstableApi
fun setAdViewProvider(adViewProvider: AdViewProvider?): DefaultMediaSourceFactory!

Sets the AdViewProvider that provides information about views for the ad playback UI.

This will override or clear the AdViewProvider set by setLocalAdInsertionComponents.

Parameters
adViewProvider: AdViewProvider?

A provider for information about views for the ad playback UI.

Returns
DefaultMediaSourceFactory!

This factory, for convenience.

setAdsLoaderProvider

@CanIgnoreReturnValue
@UnstableApi
fun setAdsLoaderProvider(adsLoaderProvider: AdsLoader.Provider?): DefaultMediaSourceFactory!

Sets the AdsLoader.Provider that provides AdsLoader instances for media items that have ads configurations.

This will override or clear the AdsLoader.Provider set by setLocalAdInsertionComponents.

Parameters
adsLoaderProvider: AdsLoader.Provider?

A provider for AdsLoader instances.

Returns
DefaultMediaSourceFactory!

This factory, for convenience.

setCmcdConfigurationFactory

@CanIgnoreReturnValue
@UnstableApi
fun setCmcdConfigurationFactory(
    cmcdConfigurationFactory: CmcdConfiguration.Factory!
): DefaultMediaSourceFactory!

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

Returns
DefaultMediaSourceFactory!

This factory, for convenience.

setDataSourceFactory

@CanIgnoreReturnValue
fun setDataSourceFactory(dataSourceFactory: DataSource.Factory!): DefaultMediaSourceFactory!

Sets the DataSource.Factory used to create DataSource instances for requesting media data.

Parameters
dataSourceFactory: DataSource.Factory!

The DataSource.Factory.

Returns
DefaultMediaSourceFactory!

This factory, for convenience.

setDrmSessionManagerProvider

@CanIgnoreReturnValue
@UnstableApi
fun setDrmSessionManagerProvider(
    drmSessionManagerProvider: DrmSessionManagerProvider!
): DefaultMediaSourceFactory!

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

Returns
DefaultMediaSourceFactory!

This factory, for convenience.

setExternalImageLoader

@CanIgnoreReturnValue
@UnstableApi
fun setExternalImageLoader(externalImageLoader: ExternalLoader?): DefaultMediaSourceFactory!

Sets the ExternalLoader to be called when loading starts in when loading images in an external Image Management Framework (for example, Glide).

This loader is only used when the mimeType is set to APPLICATION_EXTERNALLY_LOADED_IMAGE.

Parameters
externalImageLoader: ExternalLoader?

The ExternalLoader to load the media or null to remove a previously set ExternalLoader.

Returns
DefaultMediaSourceFactory!

This factory, for convenience.

setLiveMaxOffsetMs

@CanIgnoreReturnValue
@UnstableApi
fun setLiveMaxOffsetMs(liveMaxOffsetMs: Long): DefaultMediaSourceFactory!

Sets the maximum offset from the live edge for live streams, in milliseconds.

Parameters
liveMaxOffsetMs: Long

The maximum allowed live offset, in milliseconds, or TIME_UNSET to use the media-defined default.

Returns
DefaultMediaSourceFactory!

This factory, for convenience.

setLiveMaxSpeed

@CanIgnoreReturnValue
@UnstableApi
fun setLiveMaxSpeed(maxSpeed: Float): DefaultMediaSourceFactory!

Sets the maximum playback speed for live streams.

Parameters
maxSpeed: Float

The maximum factor by which playback can be sped up for live streams, or RATE_UNSET to use the media-defined default.

Returns
DefaultMediaSourceFactory!

This factory, for convenience.

setLiveMinOffsetMs

@CanIgnoreReturnValue
@UnstableApi
fun setLiveMinOffsetMs(liveMinOffsetMs: Long): DefaultMediaSourceFactory!

Sets the minimum offset from the live edge for live streams, in milliseconds.

Parameters
liveMinOffsetMs: Long

The minimum allowed live offset, in milliseconds, or TIME_UNSET to use the media-defined default.

Returns
DefaultMediaSourceFactory!

This factory, for convenience.

setLiveMinSpeed

@CanIgnoreReturnValue
@UnstableApi
fun setLiveMinSpeed(minSpeed: Float): DefaultMediaSourceFactory!

Sets the minimum playback speed for live streams.

Parameters
minSpeed: Float

The minimum factor by which playback can be sped up for live streams, or RATE_UNSET to use the media-defined default.

Returns
DefaultMediaSourceFactory!

This factory, for convenience.

setLiveTargetOffsetMs

@CanIgnoreReturnValue
@UnstableApi
fun setLiveTargetOffsetMs(liveTargetOffsetMs: Long): DefaultMediaSourceFactory!

Sets the target live offset for live streams, in milliseconds.

Parameters
liveTargetOffsetMs: Long

The target live offset, in milliseconds, or TIME_UNSET to use the media-defined default.

Returns
DefaultMediaSourceFactory!

This factory, for convenience.

setLoadErrorHandlingPolicy

@CanIgnoreReturnValue
@UnstableApi
fun setLoadErrorHandlingPolicy(
    loadErrorHandlingPolicy: LoadErrorHandlingPolicy!
): DefaultMediaSourceFactory!

Sets an optional LoadErrorHandlingPolicy.

Returns
DefaultMediaSourceFactory!

This factory, for convenience.

setLocalAdInsertionComponents

@CanIgnoreReturnValue
fun setLocalAdInsertionComponents(
    adsLoaderProvider: AdsLoader.Provider!,
    adViewProvider: AdViewProvider!
): DefaultMediaSourceFactory!

Sets the components required for local ad insertion for media items that have ads configurations

This will override the values set by setAdsLoaderProvider and setAdViewProvider.

Parameters
adsLoaderProvider: AdsLoader.Provider!

A provider for AdsLoader instances.

adViewProvider: AdViewProvider!

A provider for information about views for the ad playback UI.

Returns
DefaultMediaSourceFactory!

This factory, for convenience.

setServerSideAdInsertionMediaSourceFactory

@CanIgnoreReturnValue
@UnstableApi
fun setServerSideAdInsertionMediaSourceFactory(
    serverSideAdInsertionMediaSourceFactory: MediaSource.Factory?
): DefaultMediaSourceFactory!

Sets the MediaSource.Factory used to handle MediaItem instances containing a Uri identified as resolving to content with server side ad insertion (SSAI).

SSAI URIs are those with a scheme of SSAI_SCHEME.

Parameters
serverSideAdInsertionMediaSourceFactory: MediaSource.Factory?

The MediaSource.Factory for SSAI content, or null to remove a previously set MediaSource.Factory.

Returns
DefaultMediaSourceFactory!

This factory, for convenience.

setSubtitleParserFactory

@CanIgnoreReturnValue
@UnstableApi
fun setSubtitleParserFactory(subtitleParserFactory: SubtitleParser.Factory!): DefaultMediaSourceFactory!

Sets the SubtitleParser.Factory to be used for parsing subtitles during extraction if experimentalParseSubtitlesDuringExtraction is enabled.

Parameters
subtitleParserFactory: SubtitleParser.Factory!

The SubtitleParser.Factory for parsing subtitles during extraction.

Returns
DefaultMediaSourceFactory!

This factory, for convenience.