Back to Exoplayer

HlsMediaSource.Factory (ExoPlayer library)

docs/doc/reference/com/google/android/exoplayer2/source/hls/HlsMediaSource.Factory.html

latest18.0 KB
Original Source

Package com.google.android.exoplayer2.source.hls

Class HlsMediaSource.Factory

  • java.lang.Object

    • com.google.android.exoplayer2.source.hls.HlsMediaSource.Factory
  • All Implemented Interfaces:MediaSource.Factory, MediaSourceFactoryEnclosing class:HlsMediaSource


public static final classHlsMediaSource.Factoryextends[Object](https://developer.android.com/reference/java/lang/Object.html "class or interface in java.lang")implements[MediaSourceFactory](../MediaSourceFactory.html "interface in com.google.android.exoplayer2.source")

Factory for HlsMediaSources.

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 for HlsMediaSources. | | Factory​(DataSource.Factory dataSourceFactory) | Creates a new factory for HlsMediaSources. |

Method Summary

All Methods Instance Methods Concrete Methods | Modifier and Type | Method | Description | | --- | --- | --- | | HlsMediaSource | createMediaSource​(MediaItem mediaItem) | Returns a new HlsMediaSource using the current parameters. | | @com.google.android.exoplayer2.C.ContentType int[] | getSupportedTypes() | Returns the content types supported by media sources created by this factory. | | HlsMediaSource.Factory | setAllowChunklessPreparation​(boolean allowChunklessPreparation) | Sets whether chunkless preparation is allowed. | | HlsMediaSource.Factory | setCmcdConfigurationFactory​(CmcdConfiguration.Factory cmcdConfigurationFactory) | Sets the CmcdConfiguration.Factory used to obtain a CmcdConfiguration for a MediaItem. | | 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...). | | HlsMediaSource.Factory | setDrmSessionManagerProvider​(DrmSessionManagerProvider drmSessionManagerProvider) | Sets the DrmSessionManagerProvider used to obtain a DrmSessionManager for a MediaItem. | | HlsMediaSource.Factory | setExtractorFactory​(HlsExtractorFactory extractorFactory) | Sets the factory for Extractors for the segments. | | HlsMediaSource.Factory | setLoadErrorHandlingPolicy​(LoadErrorHandlingPolicy loadErrorHandlingPolicy) | Sets an optional LoadErrorHandlingPolicy. | | 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 to HlsMediaSource.METADATA_TYPE_ID3). | | HlsMediaSource.Factory | setPlaylistParserFactory​(HlsPlaylistParserFactory playlistParserFactory) | Sets the factory from which playlist parsers will be obtained. | | HlsMediaSource.Factory | setPlaylistTrackerFactory​(HlsPlaylistTracker.Factory playlistTrackerFactory) | Sets the HlsPlaylistTracker factory. | | 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. | | HlsMediaSource.Factory | setUseSessionKeys​(boolean useSessionKeys) | Sets whether to use #EXT-X-SESSION-KEY tags provided in the multivariant playlist. |

- 

Methods inherited from class java.lang.Object

clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail

- 

Factory

public Factory​([DataSource.Factory](../../upstream/DataSource.Factory.html "interface in com.google.android.exoplayer2.upstream")dataSourceFactory)

Creates a new factory for HlsMediaSources.

The factory will use the following default components:

  - [`DefaultDrmSessionManagerProvider`](../../drm/DefaultDrmSessionManagerProvider.html "class in com.google.android.exoplayer2.drm")
  - [`DefaultHlsPlaylistParserFactory`](playlist/DefaultHlsPlaylistParserFactory.html "class in com.google.android.exoplayer2.source.hls.playlist")
  - [`DefaultHlsPlaylistTracker.FACTORY`](playlist/DefaultHlsPlaylistTracker.html#FACTORY)
  - [`HlsExtractorFactory.DEFAULT`](HlsExtractorFactory.html#DEFAULT)
  - [`DefaultLoadErrorHandlingPolicy`](../../upstream/DefaultLoadErrorHandlingPolicy.html "class in com.google.android.exoplayer2.upstream")
  - [`DefaultCompositeSequenceableLoaderFactory`](../DefaultCompositeSequenceableLoaderFactory.html "class in com.google.android.exoplayer2.source")

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

- 

Factory

public Factory​([HlsDataSourceFactory](HlsDataSourceFactory.html "interface in com.google.android.exoplayer2.source.hls")hlsDataSourceFactory)

Creates a new factory for HlsMediaSources.

The factory will use the following default components:

  - [`DefaultDrmSessionManagerProvider`](../../drm/DefaultDrmSessionManagerProvider.html "class in com.google.android.exoplayer2.drm")
  - [`DefaultHlsPlaylistParserFactory`](playlist/DefaultHlsPlaylistParserFactory.html "class in com.google.android.exoplayer2.source.hls.playlist")
  - [`DefaultHlsPlaylistTracker.FACTORY`](playlist/DefaultHlsPlaylistTracker.html#FACTORY)
  - [`HlsExtractorFactory.DEFAULT`](HlsExtractorFactory.html#DEFAULT)
  - [`DefaultLoadErrorHandlingPolicy`](../../upstream/DefaultLoadErrorHandlingPolicy.html "class in com.google.android.exoplayer2.upstream")
  - [`DefaultCompositeSequenceableLoaderFactory`](../DefaultCompositeSequenceableLoaderFactory.html "class in com.google.android.exoplayer2.source")

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

Method Detail

- 

setExtractorFactory

@CanIgnoreReturnValue
public[HlsMediaSource.Factory](HlsMediaSource.Factory.html "class in com.google.android.exoplayer2.source.hls")setExtractorFactory​(@Nullable[HlsExtractorFactory](HlsExtractorFactory.html "interface in com.google.android.exoplayer2.source.hls")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.

- 

setLoadErrorHandlingPolicy

@CanIgnoreReturnValue
public[HlsMediaSource.Factory](HlsMediaSource.Factory.html "class in com.google.android.exoplayer2.source.hls")setLoadErrorHandlingPolicy​([LoadErrorHandlingPolicy](../../upstream/LoadErrorHandlingPolicy.html "interface in com.google.android.exoplayer2.upstream")loadErrorHandlingPolicy)

Description copied from interface: MediaSource.Factory

Sets an optional LoadErrorHandlingPolicy. Specified by:setLoadErrorHandlingPolicy in interface MediaSource.FactoryReturns:This factory, for convenience.

- 

setPlaylistParserFactory

@CanIgnoreReturnValue
public[HlsMediaSource.Factory](HlsMediaSource.Factory.html "class in com.google.android.exoplayer2.source.hls")setPlaylistParserFactory​([HlsPlaylistParserFactory](playlist/HlsPlaylistParserFactory.html "interface in com.google.android.exoplayer2.source.hls.playlist")playlistParserFactory)

Sets the factory from which playlist parsers will be obtained. Parameters:playlistParserFactory - An HlsPlaylistParserFactory.Returns:This factory, for convenience.

- 

setPlaylistTrackerFactory

@CanIgnoreReturnValue
public[HlsMediaSource.Factory](HlsMediaSource.Factory.html "class in com.google.android.exoplayer2.source.hls")setPlaylistTrackerFactory​([HlsPlaylistTracker.Factory](playlist/HlsPlaylistTracker.Factory.html "interface in com.google.android.exoplayer2.source.hls.playlist")playlistTrackerFactory)

Sets the HlsPlaylistTracker factory. Parameters:playlistTrackerFactory - A factory for HlsPlaylistTracker instances.Returns:This factory, for convenience.

- 

setCompositeSequenceableLoaderFactory

@CanIgnoreReturnValue
public[HlsMediaSource.Factory](HlsMediaSource.Factory.html "class in com.google.android.exoplayer2.source.hls")setCompositeSequenceableLoaderFactory​([CompositeSequenceableLoaderFactory](../CompositeSequenceableLoaderFactory.html "interface in com.google.android.exoplayer2.source")compositeSequenceableLoaderFactory)

Sets the factory to create composite SequenceableLoaders for when this media source loads data from multiple streams (video, audio etc...). 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.

- 

setAllowChunklessPreparation

@CanIgnoreReturnValue
public[HlsMediaSource.Factory](HlsMediaSource.Factory.html "class in com.google.android.exoplayer2.source.hls")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](HlsMediaSource.Factory.html "class in com.google.android.exoplayer2.source.hls")setMetadataType​(@com.google.android.exoplayer2.source.hls.HlsMediaSource.MetadataType 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.

- 

setUseSessionKeys

@CanIgnoreReturnValue
public[HlsMediaSource.Factory](HlsMediaSource.Factory.html "class in com.google.android.exoplayer2.source.hls")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](HlsMediaSource.Factory.html "class in com.google.android.exoplayer2.source.hls")setCmcdConfigurationFactory​([CmcdConfiguration.Factory](../../upstream/CmcdConfiguration.Factory.html "interface in com.google.android.exoplayer2.upstream")cmcdConfigurationFactory)

Description copied from interface: MediaSource.Factory

Sets the CmcdConfiguration.Factory used to obtain a CmcdConfiguration for a MediaItem. Specified by:setCmcdConfigurationFactory in interface MediaSource.FactoryReturns:This factory, for convenience.

- 

setDrmSessionManagerProvider

@CanIgnoreReturnValue
public[HlsMediaSource.Factory](HlsMediaSource.Factory.html "class in com.google.android.exoplayer2.source.hls")setDrmSessionManagerProvider​([DrmSessionManagerProvider](../../drm/DrmSessionManagerProvider.html "interface in com.google.android.exoplayer2.drm")drmSessionManagerProvider)

Description copied from interface: MediaSource.Factory

Sets the DrmSessionManagerProvider used to obtain a DrmSessionManager for a MediaItem. Specified by:setDrmSessionManagerProvider in interface MediaSource.FactoryReturns:This factory, for convenience.

- 

setTimestampAdjusterInitializationTimeoutMs

@CanIgnoreReturnValue
public[HlsMediaSource.Factory](HlsMediaSource.Factory.html "class in com.google.android.exoplayer2.source.hls")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](HlsMediaSource.html "class in com.google.android.exoplayer2.source.hls")createMediaSource​([MediaItem](../../MediaItem.html "class in com.google.android.exoplayer2")mediaItem)

Returns a new HlsMediaSource using the current parameters. Specified by:createMediaSource in interface MediaSource.FactoryParameters:mediaItem - The MediaItem.Returns:The new HlsMediaSource.Throws:NullPointerException - if MediaItem.localConfiguration is null.

- 

getSupportedTypes

[@ContentType](../../C.ContentType.html "annotation in com.google.android.exoplayer2")public @com.google.android.exoplayer2.C.ContentType int[] getSupportedTypes()

Description copied from interface: MediaSource.Factory

Returns the content types supported by media sources created by this factory. Specified by:getSupportedTypes in interface MediaSource.Factory