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.Factory
implementation.This implementation delegates calls to
createMediaSource(MediaItem)
to the following factories:DashMediaSource.Factory
if the item'suri
ends in '.mpd' or if itsmimeType field
is explicitly set toMimeTypes.APPLICATION_MPD
(Requires the exoplayer-dash module to be added to the app).HlsMediaSource.Factory
if the item'suri
ends in '.m3u8' or if itsmimeType field
is explicitly set toMimeTypes.APPLICATION_M3U8
(Requires the exoplayer-hls module to be added to the app).SsMediaSource.Factory
if the item'suri
ends in '.ism', '.ism/Manifest' or if itsmimeType field
is explicitly set toMimeTypes.APPLICATION_SS
(Requires the exoplayer-smoothstreaming module to be added to the app).ProgressiveMediaSource.Factory
serves as a fallback if the item'suri
doesn't match one of the above. It tries to infer the required extractor by using theDefaultExtractorsFactory
or theExtractorsFactory
provided in the constructor. AnUnrecognizedInputFormatException
is 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 interface
DefaultMediaSourceFactory.AdsLoaderProvider
Deprecated.UseAdsLoader.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 viasetLocalAdInsertionComponents(AdsLoader.Provider, AdViewProvider)
.MediaSource
createMediaSource(MediaItem mediaItem)
Deprecated.Creates a newMediaSource
with the specifiedMediaItem
.DefaultMediaSourceFactory
experimentalUseProgressiveMediaSourceForSubtitles(boolean useProgressiveMediaSourceForSubtitles)
Deprecated.Sets whether aProgressiveMediaSource
orSingleSampleMediaSource
is constructed to handleMediaItem.LocalConfiguration.subtitleConfigurations
.@com.google.android.exoplayer2.C.ContentType int[]
getSupportedTypes()
Deprecated.Returns thecontent types
supported by media sources created by this factory.DefaultMediaSourceFactory
setAdsLoaderProvider(AdsLoader.Provider adsLoaderProvider)
Deprecated.DefaultMediaSourceFactory
setAdViewProvider(AdViewProvider adViewProvider)
Deprecated.DefaultMediaSourceFactory
setCmcdConfigurationFactory(CmcdConfiguration.Factory cmcdConfigurationFactory)
Deprecated.DefaultMediaSourceFactory
setDataSourceFactory(DataSource.Factory dataSourceFactory)
Deprecated.Sets theDataSource.Factory
used to createDataSource
instances for requesting media data.DefaultMediaSourceFactory
setDrmSessionManagerProvider(DrmSessionManagerProvider drmSessionManagerProvider)
Deprecated.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 optionalLoadErrorHandlingPolicy
.DefaultMediaSourceFactory
setLocalAdInsertionComponents(AdsLoader.Provider adsLoaderProvider, AdViewProvider adViewProvider)
Deprecated.Sets the components required for local ad insertion for media items that haveads configurations
DefaultMediaSourceFactory
setServerSideAdInsertionMediaSourceFactory(MediaSource.Factory serverSideAdInsertionMediaSourceFactory)
Deprecated.Sets theMediaSource.Factory
used to handleMediaItem
instances containing aUri
identified 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
DefaultExtractorsFactory
can be removed by ProGuard or R8.- Parameters:
context
- Any context.extractorsFactory
- AnExtractorsFactory
used 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.Factory
can be removed by ProGuard or R8.- Parameters:
dataSourceFactory
- ADataSource.Factory
to createDataSource
instances 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.Factory
andDefaultExtractorsFactory
can be removed by ProGuard or R8.- Parameters:
dataSourceFactory
- ADataSource.Factory
to createDataSource
instances for requesting media data.extractorsFactory
- AnExtractorsFactory
used to extract progressive media from its container.
-
-
Method Detail
-
experimentalUseProgressiveMediaSourceForSubtitles
@CanIgnoreReturnValue public DefaultMediaSourceFactory experimentalUseProgressiveMediaSourceForSubtitles(boolean useProgressiveMediaSourceForSubtitles)
Deprecated.Sets whether aProgressiveMediaSource
orSingleSampleMediaSource
is 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 thatProgressiveMediaSource
should be used for subtitles instead ofSingleSampleMediaSource
.- Returns:
- This factory, for convenience.
-
setAdsLoaderProvider
@CanIgnoreReturnValue @Deprecated public DefaultMediaSourceFactory setAdsLoaderProvider(@Nullable AdsLoader.Provider adsLoaderProvider)
Deprecated.Sets theAdsLoader.Provider
that providesAdsLoader
instances for media items that haveads configurations
.This will override or clear the
AdsLoader.Provider
set bysetLocalAdInsertionComponents(AdsLoader.Provider, AdViewProvider)
.- Parameters:
adsLoaderProvider
- A provider forAdsLoader
instances.- Returns:
- This factory, for convenience.
-
setAdViewProvider
@CanIgnoreReturnValue @Deprecated public DefaultMediaSourceFactory setAdViewProvider(@Nullable AdViewProvider adViewProvider)
Deprecated.Sets theAdViewProvider
that provides information about views for the ad playback UI.This will override or clear the
AdViewProvider
set 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 configurations
This will override the values set by
setAdsLoaderProvider(AdsLoader.Provider)
andsetAdViewProvider(AdViewProvider)
.- Parameters:
adsLoaderProvider
- A provider forAdsLoader
instances.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.Factory
used to createDataSource
instances 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.Factory
used to handleMediaItem
instances containing aUri
identified as resolving to content with server side ad insertion (SSAI).SSAI URIs are those with a
scheme
ofC.SSAI_SCHEME
.- Parameters:
serverSideAdInsertionMediaSourceFactory
- TheMediaSource.Factory
for SSAI content, ornull
to 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_UNSET
to 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_UNSET
to 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_UNSET
to 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_UNSET
to 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_UNSET
to 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:
setCmcdConfigurationFactory
in interfaceMediaSource.Factory
- Returns:
- This factory, for convenience.
-
setDrmSessionManagerProvider
@CanIgnoreReturnValue public DefaultMediaSourceFactory setDrmSessionManagerProvider(DrmSessionManagerProvider drmSessionManagerProvider)
Deprecated.Description copied from interface:MediaSource.Factory
- Specified by:
setDrmSessionManagerProvider
in interfaceMediaSource.Factory
- Returns:
- This factory, for convenience.
-
setLoadErrorHandlingPolicy
@CanIgnoreReturnValue public DefaultMediaSourceFactory setLoadErrorHandlingPolicy(LoadErrorHandlingPolicy loadErrorHandlingPolicy)
Deprecated.Description copied from interface:MediaSource.Factory
Sets an optionalLoadErrorHandlingPolicy
.- Specified by:
setLoadErrorHandlingPolicy
in interfaceMediaSource.Factory
- Returns:
- This factory, for convenience.
-
getSupportedTypes
@ContentType public @com.google.android.exoplayer2.C.ContentType int[] getSupportedTypes()
Deprecated.Description copied from interface:MediaSource.Factory
Returns thecontent types
supported by media sources created by this factory.- Specified by:
getSupportedTypes
in interfaceMediaSource.Factory
-
createMediaSource
public MediaSource createMediaSource(MediaItem mediaItem)
Deprecated.Description copied from interface:MediaSource.Factory
Creates a newMediaSource
with the specifiedMediaItem
.- Specified by:
createMediaSource
in interfaceMediaSource.Factory
- Parameters:
mediaItem
- The media item to play.- Returns:
- The new
media source
.
-
-