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

## 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 for `HlsMediaSource`s.

- - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `Factory​(HlsDataSourceFactory hlsDataSourceFactory)` | Creates a new factory for `HlsMediaSource`s.
    `Factory​(DataSource.Factory dataSourceFactory)` | Creates a new factory for `HlsMediaSource`s.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods Deprecated Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `HlsMediaSource` | `createMediaSource​(Uri uri)` | Deprecated. Use `createMediaSource(MediaItem)` instead.
    `HlsMediaSource` | `createMediaSource​(MediaItem mediaItem)` | Returns a new `HlsMediaSource` using the current parameters.
    `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` | `setCompositeSequenceableLoaderFactory​(CompositeSequenceableLoaderFactory compositeSequenceableLoaderFactory)` | Sets the factory to create composite `SequenceableLoader`s for when this media source loads data from multiple streams (video, audio etc...).
    `HlsMediaSource.Factory` | `setDrmHttpDataSourceFactory​(HttpDataSource.Factory drmHttpDataSourceFactory)` | Sets the `HttpDataSource.Factory` to be used for creating `HttpMediaDrmCallbacks` to execute key and provisioning requests over HTTP.
    `HlsMediaSource.Factory` | `setDrmSessionManager​(DrmSessionManager drmSessionManager)` | Sets the `DrmSessionManager` to use for all media items regardless of their `MediaItem.DrmConfiguration`.
    `HlsMediaSource.Factory` | `setDrmSessionManagerProvider​(DrmSessionManagerProvider drmSessionManagerProvider)` | Sets the `DrmSessionManagerProvider` used to obtain a `DrmSessionManager` for a `MediaItem`.
    `HlsMediaSource.Factory` | `setDrmUserAgent​(String userAgent)` | Sets the optional user agent to be used for DRM requests.
    `HlsMediaSource.Factory` | `setExtractorFactory​(HlsExtractorFactory extractorFactory)` | Sets the factory for `Extractor`s for the segments.
    `HlsMediaSource.Factory` | `setLoadErrorHandlingPolicy​(LoadErrorHandlingPolicy loadErrorHandlingPolicy)` | Sets the `LoadErrorHandlingPolicy`.
    `HlsMediaSource.Factory` | `setMetadataType​(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` | `setStreamKeys​(List<StreamKey> streamKeys)` | Deprecated. Use `MediaItem.Builder.setStreamKeys(List)` and `createMediaSource(MediaItem)` instead.
    `HlsMediaSource.Factory` | `setTag​(Object tag)` | Deprecated. Use `MediaItem.Builder.setTag(Object)` and `createMediaSource(MediaItem)` instead.
    `HlsMediaSource.Factory` | `setUseSessionKeys​(boolean useSessionKeys)` | Sets whether to use #EXT-X-SESSION-KEY tags provided in the master 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 dataSourceFactory)

      Creates a new factory for `HlsMediaSource`s.
      Parameters:
        `dataSourceFactory` - A data source factory that will be wrapped by a `DefaultHlsDataSourceFactory` to create `DataSource`s for manifests, segments and keys.

    - #### Factory

          public Factory​(HlsDataSourceFactory hlsDataSourceFactory)

      Creates a new factory for `HlsMediaSource`s.
      Parameters:
        `hlsDataSourceFactory` - An `HlsDataSourceFactory` for `DataSource`s for manifests, segments and keys.

  - ### Method Detail

    - #### setTag

          @Deprecated
          public HlsMediaSource.Factory setTag​(@Nullable
                                               Object tag)

      Deprecated.
      Use `MediaItem.Builder.setTag(Object)` and `createMediaSource(MediaItem)` instead.

    - #### setExtractorFactory

          public HlsMediaSource.Factory setExtractorFactory​(@Nullable
                                                            HlsExtractorFactory extractorFactory)

      Sets the factory for `Extractor`s for the segments. The default value is `HlsExtractorFactory.DEFAULT`.
      Parameters:
        `extractorFactory` - An `HlsExtractorFactory` for `Extractor`s for the segments.
      Returns:
        This factory, for convenience.

    - #### setLoadErrorHandlingPolicy

          public HlsMediaSource.Factory setLoadErrorHandlingPolicy​(@Nullable
                                                                   LoadErrorHandlingPolicy loadErrorHandlingPolicy)

      Sets the `LoadErrorHandlingPolicy`. The default value is created by calling `DefaultLoadErrorHandlingPolicy()`.
      Specified by:
        `setLoadErrorHandlingPolicy` in interface `MediaSourceFactory`
      Parameters:
        `loadErrorHandlingPolicy` - A `LoadErrorHandlingPolicy`.
      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 a `DefaultHlsPlaylistParserFactory`.
      Parameters:
        `playlistParserFactory` - An `HlsPlaylistParserFactory`.
      Returns:
        This factory, for convenience.

    - #### setPlaylistTrackerFactory

          public HlsMediaSource.Factory setPlaylistTrackerFactory​(@Nullable
                                                                  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.

    - #### setCompositeSequenceableLoaderFactory

          public HlsMediaSource.Factory setCompositeSequenceableLoaderFactory​(@Nullable
                                                                              CompositeSequenceableLoaderFactory compositeSequenceableLoaderFactory)

      Sets the factory to create composite `SequenceableLoader`s 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 `SequenceableLoader`s 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​(@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

          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: `MediaSourceFactory`
      Sets the `DrmSessionManagerProvider` used to obtain a `DrmSessionManager` for a `MediaItem`.

      If not set, `DefaultDrmSessionManagerProvider` is used.

      If set, calls to the following (deprecated) methods are ignored:

      - `MediaSourceFactory.setDrmUserAgent(String)`
      - `MediaSourceFactory.setDrmHttpDataSourceFactory(HttpDataSource.Factory)`
      Specified by:
        `setDrmSessionManagerProvider` in interface `MediaSourceFactory`
      Returns:
        This factory, for convenience.

    - #### setDrmSessionManager

          public HlsMediaSource.Factory setDrmSessionManager​(@Nullable
                                                             DrmSessionManager drmSessionManager)

      Description copied from interface: `MediaSourceFactory`
      Sets the `DrmSessionManager` to use for all media items regardless of their `MediaItem.DrmConfiguration`.

      Calling this with a non-null `drmSessionManager` is equivalent to calling `setDrmSessionManagerProvider(unusedMediaItem -> drmSessionManager)`.

      Specified by:
        `setDrmSessionManager` in interface `MediaSourceFactory`
      Parameters:
        `drmSessionManager` - The `DrmSessionManager`, or `null` to use the `DefaultDrmSessionManager`.
      Returns:
        This factory, for convenience.

    - #### setDrmHttpDataSourceFactory

          public HlsMediaSource.Factory setDrmHttpDataSourceFactory​(@Nullable
                                                                    HttpDataSource.Factory drmHttpDataSourceFactory)

      Description copied from interface: `MediaSourceFactory`
      Sets the `HttpDataSource.Factory` to be used for creating `HttpMediaDrmCallbacks` to execute key and provisioning requests over HTTP.

      Calls to this method are ignored if either a `DrmSessionManager provider` or `concrete DrmSessionManager` are provided.

      Specified by:
        `setDrmHttpDataSourceFactory` in interface `MediaSourceFactory`
      Parameters:
        `drmHttpDataSourceFactory` - The HTTP data source factory, or `null` to use `DefaultHttpDataSourceFactory`.
      Returns:
        This factory, for convenience.

    - #### setDrmUserAgent

          public HlsMediaSource.Factory setDrmUserAgent​(@Nullable
                                                        String userAgent)

      Description copied from interface: `MediaSourceFactory`
      Sets the optional user agent to be used for DRM requests.

      Calls to this method are ignored if any of the following are provided:

      - A `DrmSessionManager provider`.
      - A `concrete DrmSessionManager`.
      - A `DRM HttpDataSource.Factory`.
      Specified by:
        `setDrmUserAgent` in interface `MediaSourceFactory`
      Parameters:
        `userAgent` - The user agent to be used for DRM requests, or `null` to use the default.
      Returns:
        This factory, for convenience.

    - #### setStreamKeys

          @Deprecated
          public HlsMediaSource.Factory setStreamKeys​(@Nullable
                                                      List<StreamKey> streamKeys)

      Deprecated.
      Use `MediaItem.Builder.setStreamKeys(List)` and `createMediaSource(MediaItem)` instead.
      Specified by:
        `setStreamKeys` in interface `MediaSourceFactory`

    - #### createMediaSource

          @Deprecated
          public HlsMediaSource createMediaSource​(Uri uri)

      Deprecated.
      Use `createMediaSource(MediaItem)` instead.
      Specified by:
        `createMediaSource` in interface `MediaSourceFactory`

    - #### createMediaSource

          public HlsMediaSource createMediaSource​(MediaItem mediaItem)

      Returns a new `HlsMediaSource` using the current parameters.
      Specified by:
        `createMediaSource` in interface `MediaSourceFactory`
      Parameters:
        `mediaItem` - The `MediaItem`.
      Returns:
        The new `HlsMediaSource`.
      Throws:
        `NullPointerException` - if `MediaItem.playbackProperties` is `null`.

    - #### getSupportedTypes

          public int[] getSupportedTypes()

      Description copied from interface: `MediaSourceFactory`
      Returns the `content types` supported by media sources created by this factory.
      Specified by:
        `getSupportedTypes` in interface `MediaSourceFactory`