Back to Exoplayer

DefaultMediaSourceFactory (ExoPlayer library)

docs/doc/reference/com/google/android/exoplayer2/source/DefaultMediaSourceFactory.html

latest27.9 KB
Original Source

Package com.google.android.exoplayer2.source

Class DefaultMediaSourceFactory

  • java.lang.Object

    • com.google.android.exoplayer2.source.DefaultMediaSourceFactory
  • All Implemented Interfaces:MediaSource.Factory, MediaSourceFactory


[@Deprecated](https://developer.android.com/reference/java/lang/Deprecated.html "class or interface in java.lang")public final classDefaultMediaSourceFactoryextends[Object](https://developer.android.com/reference/java/lang/Object.html "class or interface in java.lang")implements[MediaSourceFactory](MediaSourceFactory.html "interface in com.google.android.exoplayer2.source")

Deprecated. com.google.android.exoplayer2 is deprecated. Please migrate to androidx.media3 (which contains the same ExoPlayer code). See the migration guide for more details, including a script to help with the migration.

The default MediaSource.Factory implementation.

This implementation delegates calls to createMediaSource(MediaItem) to the following factories:

Ad support for media items with ad tag URIs

To support media items with ads configuration, setAdsLoaderProvider(com.google.android.exoplayer2.source.ads.AdsLoader.Provider) and setAdViewProvider(com.google.android.exoplayer2.ui.AdViewProvider) need to be called to configure the factory with the required providers.

Nested Class Summary

Nested Classes | Modifier and Type | Class | Description | | --- | --- | --- | | static interface | DefaultMediaSourceFactory.AdsLoaderProvider | Deprecated. Use AdsLoader.Provider instead.

|

Field Summary

- 

Fields inherited from interface com.google.android.exoplayer2.source.MediaSourceFactory

UNSUPPORTED

Constructor Summary

Constructors | Constructor | Description | | --- | --- | | DefaultMediaSourceFactory​(Context context) | Deprecated.

Creates a new instance. | | DefaultMediaSourceFactory​(Context context, ExtractorsFactory extractorsFactory) | Deprecated.

Creates a new instance. | | DefaultMediaSourceFactory​(DataSource.Factory dataSourceFactory) | Deprecated.

Creates a new instance. | | DefaultMediaSourceFactory​(DataSource.Factory dataSourceFactory, ExtractorsFactory extractorsFactory) | Deprecated.

Creates a new instance. |

Method Summary

All Methods Instance Methods Concrete Methods Deprecated Methods | Modifier and Type | Method | Description | | --- | --- | --- | | DefaultMediaSourceFactory | clearLocalAdInsertionComponents() | Deprecated.

Clear any values set via setLocalAdInsertionComponents(AdsLoader.Provider, AdViewProvider). | | MediaSource | createMediaSource​(MediaItem mediaItem) | Deprecated.

Creates a new MediaSource with the specified MediaItem. | | DefaultMediaSourceFactory | experimentalUseProgressiveMediaSourceForSubtitles​(boolean useProgressiveMediaSourceForSubtitles) | Deprecated.

Sets whether a ProgressiveMediaSource or SingleSampleMediaSource is constructed to handle MediaItem.LocalConfiguration.subtitleConfigurations. | | @com.google.android.exoplayer2.C.ContentType int[] | getSupportedTypes() | Deprecated.

Returns the content types supported by media sources created by this factory. | | DefaultMediaSourceFactory | setAdsLoaderProvider​(AdsLoader.Provider adsLoaderProvider) | Deprecated. Use setLocalAdInsertionComponents(AdsLoader.Provider, AdViewProvider) instead.

| | DefaultMediaSourceFactory | setAdViewProvider​(AdViewProvider adViewProvider) | Deprecated. Use setLocalAdInsertionComponents(AdsLoader.Provider, AdViewProvider) instead.

| | DefaultMediaSourceFactory | setCmcdConfigurationFactory​(CmcdConfiguration.Factory cmcdConfigurationFactory) | Deprecated.

Sets the CmcdConfiguration.Factory used to obtain a CmcdConfiguration for a MediaItem. | | DefaultMediaSourceFactory | setDataSourceFactory​(DataSource.Factory dataSourceFactory) | Deprecated.

Sets the DataSource.Factory used to create DataSource instances for requesting media data. | | DefaultMediaSourceFactory | setDrmSessionManagerProvider​(DrmSessionManagerProvider drmSessionManagerProvider) | Deprecated.

Sets the DrmSessionManagerProvider used to obtain a DrmSessionManager for a MediaItem. | | DefaultMediaSourceFactory | setLiveMaxOffsetMs​(long liveMaxOffsetMs) | Deprecated.

Sets the maximum offset from the live edge for live streams, in milliseconds. | | DefaultMediaSourceFactory | setLiveMaxSpeed​(float maxSpeed) | Deprecated.

Sets the maximum playback speed for live streams. | | DefaultMediaSourceFactory | setLiveMinOffsetMs​(long liveMinOffsetMs) | Deprecated.

Sets the minimum offset from the live edge for live streams, in milliseconds. | | DefaultMediaSourceFactory | setLiveMinSpeed​(float minSpeed) | Deprecated.

Sets the minimum playback speed for live streams. | | DefaultMediaSourceFactory | setLiveTargetOffsetMs​(long liveTargetOffsetMs) | Deprecated.

Sets the target live offset for live streams, in milliseconds. | | DefaultMediaSourceFactory | setLoadErrorHandlingPolicy​(LoadErrorHandlingPolicy loadErrorHandlingPolicy) | Deprecated.

Sets an optional LoadErrorHandlingPolicy. | | DefaultMediaSourceFactory | setLocalAdInsertionComponents​(AdsLoader.Provider adsLoaderProvider, AdViewProvider adViewProvider) | Deprecated.

Sets the components required for local ad insertion for media items that have ads configurations | | DefaultMediaSourceFactory | setServerSideAdInsertionMediaSourceFactory​(MediaSource.Factory serverSideAdInsertionMediaSourceFactory) | Deprecated.

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

- 

Methods inherited from class java.lang.Object

clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail

- 

DefaultMediaSourceFactory

public DefaultMediaSourceFactory​([Context](https://developer.android.com/reference/android/content/Context.html "class or interface in android.content")context)

Deprecated.

Creates a new instance. Parameters:context - Any context.

- 

DefaultMediaSourceFactory

public DefaultMediaSourceFactory​([Context](https://developer.android.com/reference/android/content/Context.html "class or interface in android.content")context,[ExtractorsFactory](../extractor/ExtractorsFactory.html "interface in com.google.android.exoplayer2.extractor")extractorsFactory)

Deprecated.

Creates a new instance.

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

Parameters:context - Any context.extractorsFactory - An ExtractorsFactory used to extract progressive media from its container.

- 

DefaultMediaSourceFactory

public DefaultMediaSourceFactory​([DataSource.Factory](../upstream/DataSource.Factory.html "interface in com.google.android.exoplayer2.upstream")dataSourceFactory)

Deprecated.

Creates a new instance.

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

Parameters:dataSourceFactory - A DataSource.Factory to create DataSource instances for requesting media data.

- 

DefaultMediaSourceFactory

public DefaultMediaSourceFactory​([DataSource.Factory](../upstream/DataSource.Factory.html "interface in com.google.android.exoplayer2.upstream")dataSourceFactory,[ExtractorsFactory](../extractor/ExtractorsFactory.html "interface in com.google.android.exoplayer2.extractor")extractorsFactory)

Deprecated.

Creates a new instance.

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

Parameters:dataSourceFactory - A DataSource.Factory to create DataSource instances for requesting media data.extractorsFactory - An ExtractorsFactory used to extract progressive media from its container.

Method Detail

- 

experimentalUseProgressiveMediaSourceForSubtitles

@CanIgnoreReturnValue
public[DefaultMediaSourceFactory](DefaultMediaSourceFactory.html "class in com.google.android.exoplayer2.source")experimentalUseProgressiveMediaSourceForSubtitles​(boolean useProgressiveMediaSourceForSubtitles)

Deprecated.

Sets whether a ProgressiveMediaSource or SingleSampleMediaSource is constructed to handle MediaItem.LocalConfiguration.subtitleConfigurations. Defaults to false (i.e. SingleSampleMediaSource.

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

Parameters:useProgressiveMediaSourceForSubtitles - Indicates that ProgressiveMediaSource should be used for subtitles instead of SingleSampleMediaSource.Returns:This factory, for convenience.

- 

setAdsLoaderProvider

@CanIgnoreReturnValue[@Deprecated](https://developer.android.com/reference/java/lang/Deprecated.html "class or interface in java.lang")public[DefaultMediaSourceFactory](DefaultMediaSourceFactory.html "class in com.google.android.exoplayer2.source")setAdsLoaderProvider​(@Nullable[AdsLoader.Provider](ads/AdsLoader.Provider.html "interface in com.google.android.exoplayer2.source.ads")adsLoaderProvider)

Deprecated. Use setLocalAdInsertionComponents(AdsLoader.Provider, AdViewProvider) instead.

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(AdsLoader.Provider, AdViewProvider).

Parameters:adsLoaderProvider - A provider for AdsLoader instances.Returns:This factory, for convenience.

- 

setAdViewProvider

@CanIgnoreReturnValue[@Deprecated](https://developer.android.com/reference/java/lang/Deprecated.html "class or interface in java.lang")public[DefaultMediaSourceFactory](DefaultMediaSourceFactory.html "class in com.google.android.exoplayer2.source")setAdViewProvider​(@Nullable[AdViewProvider](../ui/AdViewProvider.html "interface in com.google.android.exoplayer2.ui")adViewProvider)

Deprecated. Use setLocalAdInsertionComponents(AdsLoader.Provider, AdViewProvider) instead.

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

This will override or clear the AdViewProvider set by setLocalAdInsertionComponents(AdsLoader.Provider, AdViewProvider).

Parameters:adViewProvider - A provider for information about views for the ad playback UI.Returns:This factory, for convenience.

- 

setLocalAdInsertionComponents

@CanIgnoreReturnValue
public[DefaultMediaSourceFactory](DefaultMediaSourceFactory.html "class in com.google.android.exoplayer2.source")setLocalAdInsertionComponents​([AdsLoader.Provider](ads/AdsLoader.Provider.html "interface in com.google.android.exoplayer2.source.ads")adsLoaderProvider,[AdViewProvider](../ui/AdViewProvider.html "interface in com.google.android.exoplayer2.ui")adViewProvider)

Deprecated.

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

This will override the values set by setAdsLoaderProvider(AdsLoader.Provider) and setAdViewProvider(AdViewProvider).

Parameters:adsLoaderProvider - A provider for AdsLoader instances.adViewProvider - A provider for information about views for the ad playback UI.Returns:This factory, for convenience.

- 

clearLocalAdInsertionComponents

@CanIgnoreReturnValue
public[DefaultMediaSourceFactory](DefaultMediaSourceFactory.html "class in com.google.android.exoplayer2.source")clearLocalAdInsertionComponents()

Deprecated.

Clear any values set via setLocalAdInsertionComponents(AdsLoader.Provider, AdViewProvider).

This will also clear any values set by setAdsLoaderProvider(AdsLoader.Provider) and setAdViewProvider(AdViewProvider).

Returns:This factory, for convenience.

- 

setDataSourceFactory

@CanIgnoreReturnValue
public[DefaultMediaSourceFactory](DefaultMediaSourceFactory.html "class in com.google.android.exoplayer2.source")setDataSourceFactory​([DataSource.Factory](../upstream/DataSource.Factory.html "interface in com.google.android.exoplayer2.upstream")dataSourceFactory)

Deprecated.

Sets the DataSource.Factory used to create DataSource instances for requesting media data. Parameters:dataSourceFactory - The DataSource.Factory.Returns:This factory, for convenience.

- 

setServerSideAdInsertionMediaSourceFactory

@CanIgnoreReturnValue
public[DefaultMediaSourceFactory](DefaultMediaSourceFactory.html "class in com.google.android.exoplayer2.source")setServerSideAdInsertionMediaSourceFactory​(@Nullable[MediaSource.Factory](MediaSource.Factory.html "interface in com.google.android.exoplayer2.source")serverSideAdInsertionMediaSourceFactory)

Deprecated.

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 C.SSAI_SCHEME.

Parameters:serverSideAdInsertionMediaSourceFactory - The MediaSource.Factory for SSAI content, or null to remove a previously set MediaSource.Factory.Returns:This factory, for convenience.

- 

setLiveTargetOffsetMs

@CanIgnoreReturnValue
public[DefaultMediaSourceFactory](DefaultMediaSourceFactory.html "class in com.google.android.exoplayer2.source")setLiveTargetOffsetMs​(long liveTargetOffsetMs)

Deprecated.

Sets the target live offset for live streams, in milliseconds. Parameters:liveTargetOffsetMs - The target live offset, in milliseconds, or C.TIME_UNSET to use the media-defined default.Returns:This factory, for convenience.

- 

setLiveMinOffsetMs

@CanIgnoreReturnValue
public[DefaultMediaSourceFactory](DefaultMediaSourceFactory.html "class in com.google.android.exoplayer2.source")setLiveMinOffsetMs​(long liveMinOffsetMs)

Deprecated.

Sets the minimum offset from the live edge for live streams, in milliseconds. Parameters:liveMinOffsetMs - The minimum allowed live offset, in milliseconds, or C.TIME_UNSET to use the media-defined default.Returns:This factory, for convenience.

- 

setLiveMaxOffsetMs

@CanIgnoreReturnValue
public[DefaultMediaSourceFactory](DefaultMediaSourceFactory.html "class in com.google.android.exoplayer2.source")setLiveMaxOffsetMs​(long liveMaxOffsetMs)

Deprecated.

Sets the maximum offset from the live edge for live streams, in milliseconds. Parameters:liveMaxOffsetMs - The maximum allowed live offset, in milliseconds, or C.TIME_UNSET to use the media-defined default.Returns:This factory, for convenience.

- 

setLiveMinSpeed

@CanIgnoreReturnValue
public[DefaultMediaSourceFactory](DefaultMediaSourceFactory.html "class in com.google.android.exoplayer2.source")setLiveMinSpeed​(float minSpeed)

Deprecated.

Sets the minimum playback speed for live streams. Parameters:minSpeed - The minimum factor by which playback can be sped up for live streams, or C.RATE_UNSET to use the media-defined default.Returns:This factory, for convenience.

- 

setLiveMaxSpeed

@CanIgnoreReturnValue
public[DefaultMediaSourceFactory](DefaultMediaSourceFactory.html "class in com.google.android.exoplayer2.source")setLiveMaxSpeed​(float maxSpeed)

Deprecated.

Sets the maximum playback speed for live streams. Parameters:maxSpeed - The maximum factor by which playback can be sped up for live streams, or C.RATE_UNSET to use the media-defined default.Returns:This factory, for convenience.

- 

setCmcdConfigurationFactory

@CanIgnoreReturnValue
public[DefaultMediaSourceFactory](DefaultMediaSourceFactory.html "class in com.google.android.exoplayer2.source")setCmcdConfigurationFactory​([CmcdConfiguration.Factory](../upstream/CmcdConfiguration.Factory.html "interface in com.google.android.exoplayer2.upstream")cmcdConfigurationFactory)

Deprecated.

Description copied from interface: MediaSource.Factory

Sets the CmcdConfiguration.Factory used to obtain a CmcdConfiguration for a MediaItem. Specified by:setCmcdConfigurationFactory in interface MediaSource.FactoryReturns:This factory, for convenience.

- 

setDrmSessionManagerProvider

@CanIgnoreReturnValue
public[DefaultMediaSourceFactory](DefaultMediaSourceFactory.html "class in com.google.android.exoplayer2.source")setDrmSessionManagerProvider​([DrmSessionManagerProvider](../drm/DrmSessionManagerProvider.html "interface in com.google.android.exoplayer2.drm")drmSessionManagerProvider)

Deprecated.

Description copied from interface: MediaSource.Factory

Sets the DrmSessionManagerProvider used to obtain a DrmSessionManager for a MediaItem. Specified by:setDrmSessionManagerProvider in interface MediaSource.FactoryReturns:This factory, for convenience.

- 

setLoadErrorHandlingPolicy

@CanIgnoreReturnValue
public[DefaultMediaSourceFactory](DefaultMediaSourceFactory.html "class in com.google.android.exoplayer2.source")setLoadErrorHandlingPolicy​([LoadErrorHandlingPolicy](../upstream/LoadErrorHandlingPolicy.html "interface in com.google.android.exoplayer2.upstream")loadErrorHandlingPolicy)

Deprecated.

Description copied from interface: MediaSource.Factory

Sets an optional LoadErrorHandlingPolicy. Specified by:setLoadErrorHandlingPolicy in interface MediaSource.FactoryReturns:This factory, for convenience.

- 

getSupportedTypes

[@ContentType](../C.ContentType.html "annotation in com.google.android.exoplayer2")public @com.google.android.exoplayer2.C.ContentType int[] getSupportedTypes()

Deprecated.

Description copied from interface: MediaSource.Factory

Returns the content types supported by media sources created by this factory. Specified by:getSupportedTypes in interface MediaSource.Factory

- 

createMediaSource

public[MediaSource](MediaSource.html "interface in com.google.android.exoplayer2.source")createMediaSource​([MediaItem](../MediaItem.html "class in com.google.android.exoplayer2")mediaItem)

Deprecated.

Description copied from interface: MediaSource.Factory

Creates a new MediaSource with the specified MediaItem. Specified by:createMediaSource in interface MediaSource.FactoryParameters:mediaItem - The media item to play.Returns:The new media source.