Class HlsMediaSource.Factory
- java.lang.Object
-
- com.google.android.exoplayer2.source.hls.HlsMediaSource.Factory
-
- All Implemented Interfaces:
MediaSourceFactory
- Enclosing class:
- HlsMediaSource
public static final class HlsMediaSource.Factory extends Object implements MediaSourceFactory
Factory forHlsMediaSources.
-
-
Field Summary
-
Fields inherited from interface com.google.android.exoplayer2.source.MediaSourceFactory
UNSUPPORTED
-
-
Constructor Summary
Constructors Constructor Description Factory(HlsDataSourceFactory hlsDataSourceFactory)Creates a new factory forHlsMediaSources.Factory(DataSource.Factory dataSourceFactory)Creates a new factory forHlsMediaSources.
-
Method Summary
-
-
-
Constructor Detail
-
Factory
public Factory(DataSource.Factory dataSourceFactory)
Creates a new factory forHlsMediaSources.- Parameters:
dataSourceFactory- A data source factory that will be wrapped by aDefaultHlsDataSourceFactoryto createDataSources for manifests, segments and keys.
-
Factory
public Factory(HlsDataSourceFactory hlsDataSourceFactory)
Creates a new factory forHlsMediaSources.- Parameters:
hlsDataSourceFactory- AnHlsDataSourceFactoryforDataSources for manifests, segments and keys.
-
-
Method Detail
-
setTag
@Deprecated public HlsMediaSource.Factory setTag(@Nullable Object tag)
Deprecated.UseMediaItem.Builder.setTag(Object)andcreateMediaSource(MediaItem)instead.
-
setExtractorFactory
public HlsMediaSource.Factory setExtractorFactory(@Nullable HlsExtractorFactory extractorFactory)
Sets the factory forExtractors for the segments. The default value isHlsExtractorFactory.DEFAULT.- Parameters:
extractorFactory- AnHlsExtractorFactoryforExtractors for the segments.- Returns:
- This factory, for convenience.
-
setLoadErrorHandlingPolicy
public HlsMediaSource.Factory setLoadErrorHandlingPolicy(@Nullable LoadErrorHandlingPolicy loadErrorHandlingPolicy)
Sets theLoadErrorHandlingPolicy. The default value is created by callingDefaultLoadErrorHandlingPolicy().- Specified by:
setLoadErrorHandlingPolicyin interfaceMediaSourceFactory- Parameters:
loadErrorHandlingPolicy- ALoadErrorHandlingPolicy.- Returns:
- This factory, for convenience.
-
setPlaylistParserFactory
public HlsMediaSource.Factory setPlaylistParserFactory(@Nullable HlsPlaylistParserFactory playlistParserFactory)
Sets the factory from which playlist parsers will be obtained. The default value is aDefaultHlsPlaylistParserFactory.- Parameters:
playlistParserFactory- AnHlsPlaylistParserFactory.- Returns:
- This factory, for convenience.
-
setPlaylistTrackerFactory
public HlsMediaSource.Factory setPlaylistTrackerFactory(@Nullable HlsPlaylistTracker.Factory playlistTrackerFactory)
Sets theHlsPlaylistTrackerfactory. The default value isDefaultHlsPlaylistTracker.FACTORY.- Parameters:
playlistTrackerFactory- A factory forHlsPlaylistTrackerinstances.- Returns:
- This factory, for convenience.
-
setCompositeSequenceableLoaderFactory
public HlsMediaSource.Factory setCompositeSequenceableLoaderFactory(@Nullable CompositeSequenceableLoaderFactory compositeSequenceableLoaderFactory)
Sets the factory to create compositeSequenceableLoaders for when this media source loads data from multiple streams (video, audio etc...). The default is an instance ofDefaultCompositeSequenceableLoaderFactory.- Parameters:
compositeSequenceableLoaderFactory- A factory to create compositeSequenceableLoaders for when this media source loads data from multiple streams (video, audio etc...).- Returns:
- This factory, for convenience.
-
setAllowChunklessPreparation
public HlsMediaSource.Factory setAllowChunklessPreparation(boolean allowChunklessPreparation)
Sets whether chunkless preparation is allowed. If true, preparation without chunk downloads will be enabled for streams that provide sufficient information in their master playlist.- Parameters:
allowChunklessPreparation- Whether chunkless preparation is allowed.- Returns:
- This factory, for convenience.
-
setMetadataType
public HlsMediaSource.Factory setMetadataType(@com.google.android.exoplayer2.source.hls.HlsMediaSource.MetadataType int metadataType)
Sets the type of metadata to extract from the HLS source (defaults toHlsMediaSource.METADATA_TYPE_ID3).HLS supports in-band ID3 in both TS and fMP4 streams, but in the fMP4 case the data is wrapped in an EMSG box [spec].
If this is set to
HlsMediaSource.METADATA_TYPE_ID3then raw ID3 metadata of will be extracted from TS sources. From fMP4 streams EMSGs containing metadata of this type (in the variant stream only) will be unwrapped to expose the inner data. All other in-band metadata will be dropped.If this is set to
HlsMediaSource.METADATA_TYPE_EMSGthen all EMSG data from the fMP4 variant stream will be extracted. No metadata will be extracted from TS streams, since they don't support EMSG.- Parameters:
metadataType- The type of metadata to extract.- Returns:
- This factory, for convenience.
-
setUseSessionKeys
public HlsMediaSource.Factory setUseSessionKeys(boolean useSessionKeys)
Sets whether to use #EXT-X-SESSION-KEY tags provided in the master playlist. If enabled, it's assumed that any single session key declared in the master playlist can be used to obtain all of the keys required for playback. For media where this is not true, this option should not be enabled.- Parameters:
useSessionKeys- Whether to use #EXT-X-SESSION-KEY tags.- Returns:
- This factory, for convenience.
-
setDrmSessionManagerProvider
public HlsMediaSource.Factory setDrmSessionManagerProvider(@Nullable DrmSessionManagerProvider drmSessionManagerProvider)
Description copied from interface:MediaSourceFactorySets theDrmSessionManagerProviderused to obtain aDrmSessionManagerfor aMediaItem.If not set,
DefaultDrmSessionManagerProvideris used.If set, calls to the following (deprecated) methods are ignored:
- Specified by:
setDrmSessionManagerProviderin interfaceMediaSourceFactory- Returns:
- This factory, for convenience.
-
setDrmSessionManager
@Deprecated public HlsMediaSource.Factory setDrmSessionManager(@Nullable DrmSessionManager drmSessionManager)
Deprecated.Description copied from interface:MediaSourceFactorySets theDrmSessionManagerto use for all media items regardless of theirMediaItem.DrmConfiguration.Calling this with a non-null
drmSessionManageris equivalent to callingsetDrmSessionManagerProvider(unusedMediaItem -> drmSessionManager).- Specified by:
setDrmSessionManagerin interfaceMediaSourceFactory- Parameters:
drmSessionManager- TheDrmSessionManager, ornullto use theDefaultDrmSessionManager.- Returns:
- This factory, for convenience.
-
setDrmHttpDataSourceFactory
@Deprecated public HlsMediaSource.Factory setDrmHttpDataSourceFactory(@Nullable HttpDataSource.Factory drmHttpDataSourceFactory)
Deprecated.Description copied from interface:MediaSourceFactorySets theHttpDataSource.Factoryto be used for creatingHttpMediaDrmCallbacksto execute key and provisioning requests over HTTP.Calls to this method are ignored if either a
DrmSessionManager providerorconcrete DrmSessionManagerare provided.- Specified by:
setDrmHttpDataSourceFactoryin interfaceMediaSourceFactory- Parameters:
drmHttpDataSourceFactory- The HTTP data source factory, ornullto useDefaultHttpDataSource.Factory.- Returns:
- This factory, for convenience.
-
setDrmUserAgent
@Deprecated public HlsMediaSource.Factory setDrmUserAgent(@Nullable String userAgent)
Deprecated.Description copied from interface:MediaSourceFactorySets the optional user agent to be used for DRM requests.Calls to this method are ignored if any of the following are provided:
- Specified by:
setDrmUserAgentin interfaceMediaSourceFactory- Parameters:
userAgent- The user agent to be used for DRM requests, ornullto use the default.- Returns:
- This factory, for convenience.
-
setStreamKeys
@Deprecated public HlsMediaSource.Factory setStreamKeys(@Nullable List<StreamKey> streamKeys)
Deprecated.UseMediaItem.Builder.setStreamKeys(List)andcreateMediaSource(MediaItem)instead.- Specified by:
setStreamKeysin interfaceMediaSourceFactory
-
createMediaSource
@Deprecated public HlsMediaSource createMediaSource(Uri uri)
Deprecated.UsecreateMediaSource(MediaItem)instead.- Specified by:
createMediaSourcein interfaceMediaSourceFactory
-
createMediaSource
public HlsMediaSource createMediaSource(MediaItem mediaItem)
Returns a newHlsMediaSourceusing the current parameters.- Specified by:
createMediaSourcein interfaceMediaSourceFactory- Parameters:
mediaItem- TheMediaItem.- Returns:
- The new
HlsMediaSource. - Throws:
NullPointerException- ifMediaItem.localConfigurationisnull.
-
getSupportedTypes
public int[] getSupportedTypes()
Description copied from interface:MediaSourceFactoryReturns thecontent typessupported by media sources created by this factory.- Specified by:
getSupportedTypesin interfaceMediaSourceFactory
-
-