Class HlsMediaSource.Factory
- java.lang.Object
-
- com.google.android.exoplayer2.source.hls.HlsMediaSource.Factory
-
- All Implemented Interfaces:
MediaSource.Factory,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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description HlsMediaSourcecreateMediaSource(MediaItem mediaItem)Returns a newHlsMediaSourceusing the current parameters.@com.google.android.exoplayer2.C.ContentType int[]getSupportedTypes()Returns thecontent typessupported by media sources created by this factory.HlsMediaSource.FactorysetAllowChunklessPreparation(boolean allowChunklessPreparation)Sets whether chunkless preparation is allowed.HlsMediaSource.FactorysetCmcdConfigurationFactory(CmcdConfiguration.Factory cmcdConfigurationFactory)HlsMediaSource.FactorysetCompositeSequenceableLoaderFactory(CompositeSequenceableLoaderFactory compositeSequenceableLoaderFactory)Sets the factory to create compositeSequenceableLoaders for when this media source loads data from multiple streams (video, audio etc...).HlsMediaSource.FactorysetDrmSessionManagerProvider(DrmSessionManagerProvider drmSessionManagerProvider)HlsMediaSource.FactorysetExtractorFactory(HlsExtractorFactory extractorFactory)Sets the factory forExtractors for the segments.HlsMediaSource.FactorysetLoadErrorHandlingPolicy(LoadErrorHandlingPolicy loadErrorHandlingPolicy)Sets an optionalLoadErrorHandlingPolicy.HlsMediaSource.FactorysetMetadataType(@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).HlsMediaSource.FactorysetPlaylistParserFactory(HlsPlaylistParserFactory playlistParserFactory)Sets the factory from which playlist parsers will be obtained.HlsMediaSource.FactorysetPlaylistTrackerFactory(HlsPlaylistTracker.Factory playlistTrackerFactory)Sets theHlsPlaylistTrackerfactory.HlsMediaSource.FactorysetTimestampAdjusterInitializationTimeoutMs(long timestampAdjusterInitializationTimeoutMs)Sets the timeout for the loading thread to wait for the timestamp adjuster to initialize, in milliseconds.The default value is zero, which is interpreted as an infinite timeout.HlsMediaSource.FactorysetUseSessionKeys(boolean useSessionKeys)Sets whether to use #EXT-X-SESSION-KEY tags provided in the multivariant playlist.
-
-
-
Constructor Detail
-
Factory
public Factory(DataSource.Factory dataSourceFactory)
Creates a new factory forHlsMediaSources.The factory will use the following default components:
- 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.The factory will use the following default components:
- Parameters:
hlsDataSourceFactory- AnHlsDataSourceFactoryforDataSources for manifests, segments and keys.
-
-
Method Detail
-
setExtractorFactory
@CanIgnoreReturnValue 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
@CanIgnoreReturnValue public HlsMediaSource.Factory setLoadErrorHandlingPolicy(LoadErrorHandlingPolicy loadErrorHandlingPolicy)
Description copied from interface:MediaSource.FactorySets an optionalLoadErrorHandlingPolicy.- Specified by:
setLoadErrorHandlingPolicyin interfaceMediaSource.Factory- Returns:
- This factory, for convenience.
-
setPlaylistParserFactory
@CanIgnoreReturnValue public HlsMediaSource.Factory setPlaylistParserFactory(HlsPlaylistParserFactory playlistParserFactory)
Sets the factory from which playlist parsers will be obtained.- Parameters:
playlistParserFactory- AnHlsPlaylistParserFactory.- Returns:
- This factory, for convenience.
-
setPlaylistTrackerFactory
@CanIgnoreReturnValue public HlsMediaSource.Factory setPlaylistTrackerFactory(HlsPlaylistTracker.Factory playlistTrackerFactory)
Sets theHlsPlaylistTrackerfactory.- Parameters:
playlistTrackerFactory- A factory forHlsPlaylistTrackerinstances.- Returns:
- This factory, for convenience.
-
setCompositeSequenceableLoaderFactory
@CanIgnoreReturnValue public HlsMediaSource.Factory setCompositeSequenceableLoaderFactory(CompositeSequenceableLoaderFactory compositeSequenceableLoaderFactory)
Sets the factory to create compositeSequenceableLoaders for when this media source loads data from multiple streams (video, audio etc...).- 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
@CanIgnoreReturnValue 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 multivariant playlist.- Parameters:
allowChunklessPreparation- Whether chunkless preparation is allowed.- Returns:
- This factory, for convenience.
-
setMetadataType
@CanIgnoreReturnValue 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
@CanIgnoreReturnValue public HlsMediaSource.Factory setUseSessionKeys(boolean useSessionKeys)
Sets whether to use #EXT-X-SESSION-KEY tags provided in the multivariant playlist. If enabled, it's assumed that any single session key declared in the multivariant 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.
-
setCmcdConfigurationFactory
@CanIgnoreReturnValue public HlsMediaSource.Factory setCmcdConfigurationFactory(CmcdConfiguration.Factory cmcdConfigurationFactory)
Description copied from interface:MediaSource.Factory- Specified by:
setCmcdConfigurationFactoryin interfaceMediaSource.Factory- Returns:
- This factory, for convenience.
-
setDrmSessionManagerProvider
@CanIgnoreReturnValue public HlsMediaSource.Factory setDrmSessionManagerProvider(DrmSessionManagerProvider drmSessionManagerProvider)
Description copied from interface:MediaSource.Factory- Specified by:
setDrmSessionManagerProviderin interfaceMediaSource.Factory- Returns:
- This factory, for convenience.
-
setTimestampAdjusterInitializationTimeoutMs
@CanIgnoreReturnValue public HlsMediaSource.Factory setTimestampAdjusterInitializationTimeoutMs(long timestampAdjusterInitializationTimeoutMs)
Sets the timeout for the loading thread to wait for the timestamp adjuster to initialize, in milliseconds.The default value is zero, which is interpreted as an infinite timeout.- Parameters:
timestampAdjusterInitializationTimeoutMs- The timeout in milliseconds. A timeout of zero is interpreted as an infinite timeout.- Returns:
- This factory, for convenience.
-
createMediaSource
public HlsMediaSource createMediaSource(MediaItem mediaItem)
Returns a newHlsMediaSourceusing the current parameters.- Specified by:
createMediaSourcein interfaceMediaSource.Factory- Parameters:
mediaItem- TheMediaItem.- Returns:
- The new
HlsMediaSource. - Throws:
NullPointerException- ifMediaItem.localConfigurationisnull.
-
getSupportedTypes
@ContentType public @com.google.android.exoplayer2.C.ContentType int[] getSupportedTypes()
Description copied from interface:MediaSource.FactoryReturns thecontent typessupported by media sources created by this factory.- Specified by:
getSupportedTypesin interfaceMediaSource.Factory
-
-