public final class

HlsMediaSource.Factory

extends java.lang.Object

implements MediaSourceFactory

 java.lang.Object

↳androidx.media3.exoplayer.hls.HlsMediaSource.Factory

Overview

Factory for HlsMediaSources.

Summary

Constructors
publicFactory(DataSource.Factory dataSourceFactory)

Creates a new factory for HlsMediaSources.

publicFactory(HlsDataSourceFactory hlsDataSourceFactory)

Creates a new factory for HlsMediaSources.

Methods
public HlsMediaSourcecreateMediaSource(MediaItem mediaItem)

Returns a new HlsMediaSource using the current parameters.

public int[]getSupportedTypes()

public HlsMediaSource.FactorysetAllowChunklessPreparation(boolean allowChunklessPreparation)

Sets whether chunkless preparation is allowed.

public HlsMediaSource.FactorysetCompositeSequenceableLoaderFactory(CompositeSequenceableLoaderFactory compositeSequenceableLoaderFactory)

Sets the factory to create composite SequenceableLoaders for when this media source loads data from multiple streams (video, audio etc...).

public HlsMediaSource.FactorysetDrmSessionManagerProvider(DrmSessionManagerProvider drmSessionManagerProvider)

public HlsMediaSource.FactorysetExtractorFactory(HlsExtractorFactory extractorFactory)

Sets the factory for Extractors for the segments.

public HlsMediaSource.FactorysetLoadErrorHandlingPolicy(LoadErrorHandlingPolicy loadErrorHandlingPolicy)

Sets the LoadErrorHandlingPolicy.

public HlsMediaSource.FactorysetMetadataType(int metadataType)

Sets the type of metadata to extract from the HLS source (defaults to HlsMediaSource.METADATA_TYPE_ID3).

public HlsMediaSource.FactorysetPlaylistParserFactory(HlsPlaylistParserFactory playlistParserFactory)

Sets the factory from which playlist parsers will be obtained.

public HlsMediaSource.FactorysetPlaylistTrackerFactory(HlsPlaylistTracker.Factory playlistTrackerFactory)

Sets the HlsPlaylistTracker factory.

public HlsMediaSource.FactorysetUseSessionKeys(boolean useSessionKeys)

Sets whether to use #EXT-X-SESSION-KEY tags provided in the multivariant playlist.

from java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructors

public Factory(DataSource.Factory dataSourceFactory)

Creates a new factory for HlsMediaSources.

Parameters:

dataSourceFactory: A data source factory that will be wrapped by a DefaultHlsDataSourceFactory to create DataSources for manifests, segments and keys.

public Factory(HlsDataSourceFactory hlsDataSourceFactory)

Creates a new factory for HlsMediaSources.

Parameters:

hlsDataSourceFactory: An HlsDataSourceFactory for DataSources for manifests, segments and keys.

Methods

public HlsMediaSource.Factory setExtractorFactory(HlsExtractorFactory extractorFactory)

Sets the factory for Extractors for the segments. The default value is HlsExtractorFactory.DEFAULT.

Parameters:

extractorFactory: An HlsExtractorFactory for Extractors for the segments.

Returns:

This factory, for convenience.

public HlsMediaSource.Factory setLoadErrorHandlingPolicy(LoadErrorHandlingPolicy loadErrorHandlingPolicy)

Sets the LoadErrorHandlingPolicy. The default value is created by calling DefaultLoadErrorHandlingPolicy.DefaultLoadErrorHandlingPolicy().

Parameters:

loadErrorHandlingPolicy: A LoadErrorHandlingPolicy.

Returns:

This factory, for convenience.

public HlsMediaSource.Factory setPlaylistParserFactory(HlsPlaylistParserFactory playlistParserFactory)

Sets the factory from which playlist parsers will be obtained. The default value is a DefaultHlsPlaylistParserFactory.

Parameters:

playlistParserFactory: An HlsPlaylistParserFactory.

Returns:

This factory, for convenience.

public HlsMediaSource.Factory setPlaylistTrackerFactory(HlsPlaylistTracker.Factory playlistTrackerFactory)

Sets the HlsPlaylistTracker factory. The default value is DefaultHlsPlaylistTracker.FACTORY.

Parameters:

playlistTrackerFactory: A factory for HlsPlaylistTracker instances.

Returns:

This factory, for convenience.

public HlsMediaSource.Factory setCompositeSequenceableLoaderFactory(CompositeSequenceableLoaderFactory compositeSequenceableLoaderFactory)

Sets the factory to create composite SequenceableLoaders for when this media source loads data from multiple streams (video, audio etc...). The default is an instance of DefaultCompositeSequenceableLoaderFactory.

Parameters:

compositeSequenceableLoaderFactory: A factory to create composite SequenceableLoaders for when this media source loads data from multiple streams (video, audio etc...).

Returns:

This factory, for convenience.

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.

public HlsMediaSource.Factory setMetadataType(int metadataType)

Sets the type of metadata to extract from the HLS source (defaults to HlsMediaSource.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_ID3 then 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_EMSG then 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.

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.

public HlsMediaSource.Factory setDrmSessionManagerProvider(DrmSessionManagerProvider drmSessionManagerProvider)

public HlsMediaSource createMediaSource(MediaItem mediaItem)

Returns a new HlsMediaSource using the current parameters.

Parameters:

mediaItem: The MediaItem.

Returns:

The new HlsMediaSource.

public int[] getSupportedTypes()