Class DefaultMediaSourceFactory
- java.lang.Object
-
- com.google.android.exoplayer2.source.DefaultMediaSourceFactory
-
- All Implemented Interfaces:
MediaSource.Factory,MediaSourceFactory
@Deprecated public final class DefaultMediaSourceFactory extends Object implements MediaSourceFactory
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 defaultMediaSource.Factoryimplementation.This implementation delegates calls to
createMediaSource(MediaItem)to the following factories:DashMediaSource.Factoryif the item'suriends in '.mpd' or if itsmimeType fieldis explicitly set toMimeTypes.APPLICATION_MPD(Requires the exoplayer-dash module to be added to the app).HlsMediaSource.Factoryif the item'suriends in '.m3u8' or if itsmimeType fieldis explicitly set toMimeTypes.APPLICATION_M3U8(Requires the exoplayer-hls module to be added to the app).SsMediaSource.Factoryif the item'suriends in '.ism', '.ism/Manifest' or if itsmimeType fieldis explicitly set toMimeTypes.APPLICATION_SS(Requires the exoplayer-smoothstreaming module to be added to the app).ProgressiveMediaSource.Factoryserves as a fallback if the item'suridoesn't match one of the above. It tries to infer the required extractor by using theDefaultExtractorsFactoryor theExtractorsFactoryprovided in the constructor. AnUnrecognizedInputFormatExceptionis thrown if none of the available extractors can read the stream.
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)andsetAdViewProvider(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 interfaceDefaultMediaSourceFactory.AdsLoaderProviderDeprecated.UseAdsLoader.Providerinstead.
-
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 DefaultMediaSourceFactoryclearLocalAdInsertionComponents()Deprecated.Clear any values set viasetLocalAdInsertionComponents(AdsLoader.Provider, AdViewProvider).MediaSourcecreateMediaSource(MediaItem mediaItem)Deprecated.Creates a newMediaSourcewith the specifiedMediaItem.DefaultMediaSourceFactoryexperimentalUseProgressiveMediaSourceForSubtitles(boolean useProgressiveMediaSourceForSubtitles)Deprecated.Sets whether aProgressiveMediaSourceorSingleSampleMediaSourceis constructed to handleMediaItem.LocalConfiguration.subtitleConfigurations.@com.google.android.exoplayer2.C.ContentType int[]getSupportedTypes()Deprecated.Returns thecontent typessupported by media sources created by this factory.DefaultMediaSourceFactorysetAdsLoaderProvider(AdsLoader.Provider adsLoaderProvider)Deprecated.DefaultMediaSourceFactorysetAdViewProvider(AdViewProvider adViewProvider)Deprecated.DefaultMediaSourceFactorysetCmcdConfigurationFactory(CmcdConfiguration.Factory cmcdConfigurationFactory)Deprecated.DefaultMediaSourceFactorysetDataSourceFactory(DataSource.Factory dataSourceFactory)Deprecated.Sets theDataSource.Factoryused to createDataSourceinstances for requesting media data.DefaultMediaSourceFactorysetDrmSessionManagerProvider(DrmSessionManagerProvider drmSessionManagerProvider)Deprecated.DefaultMediaSourceFactorysetLiveMaxOffsetMs(long liveMaxOffsetMs)Deprecated.Sets the maximum offset from the live edge for live streams, in milliseconds.DefaultMediaSourceFactorysetLiveMaxSpeed(float maxSpeed)Deprecated.Sets the maximum playback speed for live streams.DefaultMediaSourceFactorysetLiveMinOffsetMs(long liveMinOffsetMs)Deprecated.Sets the minimum offset from the live edge for live streams, in milliseconds.DefaultMediaSourceFactorysetLiveMinSpeed(float minSpeed)Deprecated.Sets the minimum playback speed for live streams.DefaultMediaSourceFactorysetLiveTargetOffsetMs(long liveTargetOffsetMs)Deprecated.Sets the target live offset for live streams, in milliseconds.DefaultMediaSourceFactorysetLoadErrorHandlingPolicy(LoadErrorHandlingPolicy loadErrorHandlingPolicy)Deprecated.Sets an optionalLoadErrorHandlingPolicy.DefaultMediaSourceFactorysetLocalAdInsertionComponents(AdsLoader.Provider adsLoaderProvider, AdViewProvider adViewProvider)Deprecated.Sets the components required for local ad insertion for media items that haveads configurationsDefaultMediaSourceFactorysetServerSideAdInsertionMediaSourceFactory(MediaSource.Factory serverSideAdInsertionMediaSourceFactory)Deprecated.Sets theMediaSource.Factoryused to handleMediaIteminstances containing aUriidentified as resolving to content with server side ad insertion (SSAI).
-
-
-
Constructor Detail
-
DefaultMediaSourceFactory
public DefaultMediaSourceFactory(Context context)
Deprecated.Creates a new instance.- Parameters:
context- Any context.
-
DefaultMediaSourceFactory
public DefaultMediaSourceFactory(Context context, ExtractorsFactory extractorsFactory)
Deprecated.Creates a new instance.Note that this constructor is only useful to try and ensure that ExoPlayer's
DefaultExtractorsFactorycan be removed by ProGuard or R8.- Parameters:
context- Any context.extractorsFactory- AnExtractorsFactoryused to extract progressive media from its container.
-
DefaultMediaSourceFactory
public DefaultMediaSourceFactory(DataSource.Factory dataSourceFactory)
Deprecated.Creates a new instance.Note that this constructor is only useful to try and ensure that ExoPlayer's
DefaultDataSource.Factorycan be removed by ProGuard or R8.- Parameters:
dataSourceFactory- ADataSource.Factoryto createDataSourceinstances for requesting media data.
-
DefaultMediaSourceFactory
public DefaultMediaSourceFactory(DataSource.Factory dataSourceFactory, ExtractorsFactory extractorsFactory)
Deprecated.Creates a new instance.Note that this constructor is only useful to try and ensure that ExoPlayer's
DefaultDataSource.FactoryandDefaultExtractorsFactorycan be removed by ProGuard or R8.- Parameters:
dataSourceFactory- ADataSource.Factoryto createDataSourceinstances for requesting media data.extractorsFactory- AnExtractorsFactoryused to extract progressive media from its container.
-
-
Method Detail
-
experimentalUseProgressiveMediaSourceForSubtitles
@CanIgnoreReturnValue public DefaultMediaSourceFactory experimentalUseProgressiveMediaSourceForSubtitles(boolean useProgressiveMediaSourceForSubtitles)
Deprecated.Sets whether aProgressiveMediaSourceorSingleSampleMediaSourceis constructed to handleMediaItem.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 thatProgressiveMediaSourceshould be used for subtitles instead ofSingleSampleMediaSource.- Returns:
- This factory, for convenience.
-
setAdsLoaderProvider
@CanIgnoreReturnValue @Deprecated public DefaultMediaSourceFactory setAdsLoaderProvider(@Nullable AdsLoader.Provider adsLoaderProvider)
Deprecated.Sets theAdsLoader.Providerthat providesAdsLoaderinstances for media items that haveads configurations.This will override or clear the
AdsLoader.Providerset bysetLocalAdInsertionComponents(AdsLoader.Provider, AdViewProvider).- Parameters:
adsLoaderProvider- A provider forAdsLoaderinstances.- Returns:
- This factory, for convenience.
-
setAdViewProvider
@CanIgnoreReturnValue @Deprecated public DefaultMediaSourceFactory setAdViewProvider(@Nullable AdViewProvider adViewProvider)
Deprecated.Sets theAdViewProviderthat provides information about views for the ad playback UI.This will override or clear the
AdViewProviderset bysetLocalAdInsertionComponents(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 setLocalAdInsertionComponents(AdsLoader.Provider adsLoaderProvider, AdViewProvider adViewProvider)
Deprecated.Sets the components required for local ad insertion for media items that haveads configurationsThis will override the values set by
setAdsLoaderProvider(AdsLoader.Provider)andsetAdViewProvider(AdViewProvider).- Parameters:
adsLoaderProvider- A provider forAdsLoaderinstances.adViewProvider- A provider for information about views for the ad playback UI.- Returns:
- This factory, for convenience.
-
clearLocalAdInsertionComponents
@CanIgnoreReturnValue public DefaultMediaSourceFactory clearLocalAdInsertionComponents()
Deprecated.Clear any values set viasetLocalAdInsertionComponents(AdsLoader.Provider, AdViewProvider).This will also clear any values set by
setAdsLoaderProvider(AdsLoader.Provider)andsetAdViewProvider(AdViewProvider).- Returns:
- This factory, for convenience.
-
setDataSourceFactory
@CanIgnoreReturnValue public DefaultMediaSourceFactory setDataSourceFactory(DataSource.Factory dataSourceFactory)
Deprecated.Sets theDataSource.Factoryused to createDataSourceinstances for requesting media data.- Parameters:
dataSourceFactory- TheDataSource.Factory.- Returns:
- This factory, for convenience.
-
setServerSideAdInsertionMediaSourceFactory
@CanIgnoreReturnValue public DefaultMediaSourceFactory setServerSideAdInsertionMediaSourceFactory(@Nullable MediaSource.Factory serverSideAdInsertionMediaSourceFactory)
Deprecated.Sets theMediaSource.Factoryused to handleMediaIteminstances containing aUriidentified as resolving to content with server side ad insertion (SSAI).SSAI URIs are those with a
schemeofC.SSAI_SCHEME.- Parameters:
serverSideAdInsertionMediaSourceFactory- TheMediaSource.Factoryfor SSAI content, ornullto remove a previously setMediaSource.Factory.- Returns:
- This factory, for convenience.
-
setLiveTargetOffsetMs
@CanIgnoreReturnValue public DefaultMediaSourceFactory setLiveTargetOffsetMs(long liveTargetOffsetMs)
Deprecated.Sets the target live offset for live streams, in milliseconds.- Parameters:
liveTargetOffsetMs- The target live offset, in milliseconds, orC.TIME_UNSETto use the media-defined default.- Returns:
- This factory, for convenience.
-
setLiveMinOffsetMs
@CanIgnoreReturnValue public DefaultMediaSourceFactory 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, orC.TIME_UNSETto use the media-defined default.- Returns:
- This factory, for convenience.
-
setLiveMaxOffsetMs
@CanIgnoreReturnValue public DefaultMediaSourceFactory 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, orC.TIME_UNSETto use the media-defined default.- Returns:
- This factory, for convenience.
-
setLiveMinSpeed
@CanIgnoreReturnValue public DefaultMediaSourceFactory 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, orC.RATE_UNSETto use the media-defined default.- Returns:
- This factory, for convenience.
-
setLiveMaxSpeed
@CanIgnoreReturnValue public DefaultMediaSourceFactory 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, orC.RATE_UNSETto use the media-defined default.- Returns:
- This factory, for convenience.
-
setCmcdConfigurationFactory
@CanIgnoreReturnValue public DefaultMediaSourceFactory setCmcdConfigurationFactory(CmcdConfiguration.Factory cmcdConfigurationFactory)
Deprecated.Description copied from interface:MediaSource.Factory- Specified by:
setCmcdConfigurationFactoryin interfaceMediaSource.Factory- Returns:
- This factory, for convenience.
-
setDrmSessionManagerProvider
@CanIgnoreReturnValue public DefaultMediaSourceFactory setDrmSessionManagerProvider(DrmSessionManagerProvider drmSessionManagerProvider)
Deprecated.Description copied from interface:MediaSource.Factory- Specified by:
setDrmSessionManagerProviderin interfaceMediaSource.Factory- Returns:
- This factory, for convenience.
-
setLoadErrorHandlingPolicy
@CanIgnoreReturnValue public DefaultMediaSourceFactory setLoadErrorHandlingPolicy(LoadErrorHandlingPolicy loadErrorHandlingPolicy)
Deprecated.Description copied from interface:MediaSource.FactorySets an optionalLoadErrorHandlingPolicy.- Specified by:
setLoadErrorHandlingPolicyin interfaceMediaSource.Factory- Returns:
- This factory, for convenience.
-
getSupportedTypes
@ContentType public @com.google.android.exoplayer2.C.ContentType int[] getSupportedTypes()
Deprecated.Description copied from interface:MediaSource.FactoryReturns thecontent typessupported by media sources created by this factory.- Specified by:
getSupportedTypesin interfaceMediaSource.Factory
-
createMediaSource
public MediaSource createMediaSource(MediaItem mediaItem)
Deprecated.Description copied from interface:MediaSource.FactoryCreates a newMediaSourcewith the specifiedMediaItem.- Specified by:
createMediaSourcein interfaceMediaSource.Factory- Parameters:
mediaItem- The media item to play.- Returns:
- The new
media source.
-
-