DefaultMediaSourceFactory


public final class DefaultMediaSourceFactory implements 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(
    DataSource.Factory dataSourceFactory,
    ExtractorsFactory extractorsFactory
)

Creates a new instance.

Public methods

DefaultMediaSourceFactory

Clear any values set via setLocalAdInsertionComponents.

MediaSource

Creates a new MediaSource with the specified MediaItem.

DefaultMediaSourceFactory
@CanIgnoreReturnValue
@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.

int[]

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

DefaultMediaSourceFactory

This method is deprecated.

Use setLocalAdInsertionComponents instead.

DefaultMediaSourceFactory

This method 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(
    AdsLoader.Provider adsLoaderProvider,
    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.

Public constructors

DefaultMediaSourceFactory

public DefaultMediaSourceFactory(Context context)

Creates a new instance.

Parameters
Context context

Any context.

DefaultMediaSourceFactory

@UnstableApi
public DefaultMediaSourceFactory(DataSource.Factory dataSourceFactory)

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
DataSource.Factory dataSourceFactory

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

DefaultMediaSourceFactory

@UnstableApi
public 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
public DefaultMediaSourceFactory(
    DataSource.Factory dataSourceFactory,
    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
DataSource.Factory dataSourceFactory

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

ExtractorsFactory extractorsFactory

An ExtractorsFactory used to extract progressive media from its container.

Public methods

clearLocalAdInsertionComponents

@CanIgnoreReturnValue
public DefaultMediaSourceFactory clearLocalAdInsertionComponents()

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
public 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

@CanIgnoreReturnValue
@UnstableApi
public DefaultMediaSourceFactory 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
DefaultMediaSourceFactory

This factory, for convenience.

getSupportedTypes

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

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

setAdViewProvider

@CanIgnoreReturnValue
@UnstableApi
public DefaultMediaSourceFactory setAdViewProvider(@Nullable AdViewProvider adViewProvider)

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

This will override or clear the AdViewProvider set by setLocalAdInsertionComponents.

Parameters
@Nullable AdViewProvider adViewProvider

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

Returns
DefaultMediaSourceFactory

This factory, for convenience.

setAdsLoaderProvider

@CanIgnoreReturnValue
@UnstableApi
public DefaultMediaSourceFactory setAdsLoaderProvider(@Nullable AdsLoader.Provider adsLoaderProvider)

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
@Nullable AdsLoader.Provider adsLoaderProvider

A provider for AdsLoader instances.

Returns
DefaultMediaSourceFactory

This factory, for convenience.

setCmcdConfigurationFactory

@CanIgnoreReturnValue
@UnstableApi
public DefaultMediaSourceFactory setCmcdConfigurationFactory(
    CmcdConfiguration.Factory cmcdConfigurationFactory
)

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

Returns
DefaultMediaSourceFactory

This factory, for convenience.

setDataSourceFactory

@CanIgnoreReturnValue
public DefaultMediaSourceFactory setDataSourceFactory(DataSource.Factory dataSourceFactory)

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

Parameters
DataSource.Factory dataSourceFactory

The DataSource.Factory.

Returns
DefaultMediaSourceFactory

This factory, for convenience.

setDrmSessionManagerProvider

@CanIgnoreReturnValue
@UnstableApi
public DefaultMediaSourceFactory setDrmSessionManagerProvider(
    DrmSessionManagerProvider drmSessionManagerProvider
)

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

Returns
DefaultMediaSourceFactory

This factory, for convenience.

setExternalImageLoader

@CanIgnoreReturnValue
@UnstableApi
public DefaultMediaSourceFactory setExternalImageLoader(@Nullable ExternalLoader externalImageLoader)

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
@Nullable ExternalLoader externalImageLoader

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

Returns
DefaultMediaSourceFactory

This factory, for convenience.

setLiveMaxOffsetMs

@CanIgnoreReturnValue
@UnstableApi
public DefaultMediaSourceFactory setLiveMaxOffsetMs(long liveMaxOffsetMs)

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

Parameters
long liveMaxOffsetMs

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
public DefaultMediaSourceFactory setLiveMaxSpeed(float maxSpeed)

Sets the maximum playback speed for live streams.

Parameters
float maxSpeed

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
public DefaultMediaSourceFactory setLiveMinOffsetMs(long liveMinOffsetMs)

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

Parameters
long liveMinOffsetMs

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
public DefaultMediaSourceFactory setLiveMinSpeed(float minSpeed)

Sets the minimum playback speed for live streams.

Parameters
float minSpeed

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
public DefaultMediaSourceFactory setLiveTargetOffsetMs(long liveTargetOffsetMs)

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

Parameters
long liveTargetOffsetMs

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

Returns
DefaultMediaSourceFactory

This factory, for convenience.

setLoadErrorHandlingPolicy

@CanIgnoreReturnValue
@UnstableApi
public DefaultMediaSourceFactory setLoadErrorHandlingPolicy(
    LoadErrorHandlingPolicy loadErrorHandlingPolicy
)

Sets an optional LoadErrorHandlingPolicy.

Returns
DefaultMediaSourceFactory

This factory, for convenience.

setLocalAdInsertionComponents

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

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
AdsLoader.Provider adsLoaderProvider

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
public DefaultMediaSourceFactory setServerSideAdInsertionMediaSourceFactory(
    @Nullable MediaSource.Factory serverSideAdInsertionMediaSourceFactory
)

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
@Nullable MediaSource.Factory serverSideAdInsertionMediaSourceFactory

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

Returns
DefaultMediaSourceFactory

This factory, for convenience.

setSubtitleParserFactory

@CanIgnoreReturnValue
@UnstableApi
public DefaultMediaSourceFactory 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
DefaultMediaSourceFactory

This factory, for convenience.