Package com.google.android.exoplayer2.source

## Interface MediaSourceFactory

- All Known Implementing Classes:
    `DashMediaSource.Factory`, `DefaultMediaSourceFactory`, `HlsMediaSource.Factory`, `ProgressiveMediaSource.Factory`, `RtspMediaSource.Factory`, `SsMediaSource.Factory`

      public interface MediaSourceFactory

  Factory for creating `MediaSources` from `MediaItems`.

- - ### Method Summary

    All Methods Instance Methods Abstract Methods Default Methods Deprecated Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `default MediaSource` | `createMediaSource​(Uri uri)` | Deprecated. Use `createMediaSource(MediaItem)` instead.
    `MediaSource` | `createMediaSource​(MediaItem mediaItem)` | Creates a new `MediaSource` with the specified `MediaItem`.
    `int[]` | `getSupportedTypes()` | Returns the `content types` supported by media sources created by this factory.
    `MediaSourceFactory` | `setDrmHttpDataSourceFactory​(HttpDataSource.Factory drmHttpDataSourceFactory)` | Deprecated. Use `setDrmSessionManagerProvider(DrmSessionManagerProvider)` and pass an implementation that configures the returned `DrmSessionManager` with the desired `HttpDataSource.Factory`.
    `MediaSourceFactory` | `setDrmSessionManager​(DrmSessionManager drmSessionManager)` | Deprecated. Use `setDrmSessionManagerProvider(DrmSessionManagerProvider)` and pass an implementation that always returns the same instance.
    `MediaSourceFactory` | `setDrmSessionManagerProvider​(DrmSessionManagerProvider drmSessionManagerProvider)` | Sets the `DrmSessionManagerProvider` used to obtain a `DrmSessionManager` for a `MediaItem`.
    `MediaSourceFactory` | `setDrmUserAgent​(String userAgent)` | Deprecated. Use `setDrmSessionManagerProvider(DrmSessionManagerProvider)` and pass an implementation that configures the returned `DrmSessionManager` with the desired `userAgent`.
    `MediaSourceFactory` | `setLoadErrorHandlingPolicy​(LoadErrorHandlingPolicy loadErrorHandlingPolicy)` | Sets an optional `LoadErrorHandlingPolicy`.
    `default MediaSourceFactory` | `setStreamKeys​(List<StreamKey> streamKeys)` | Deprecated. Use `MediaItem.PlaybackProperties.streamKeys` instead.

- - ### Method Detail

    - #### setStreamKeys

          @Deprecated
          default MediaSourceFactory setStreamKeys​(@Nullable
                                                   List<StreamKey> streamKeys)

      Deprecated.
      Use `MediaItem.PlaybackProperties.streamKeys` instead.

    - #### setDrmSessionManagerProvider

          MediaSourceFactory setDrmSessionManagerProvider​(@Nullable
                                                          DrmSessionManagerProvider drmSessionManagerProvider)

      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:

      - `setDrmUserAgent(String)`
      - `setDrmHttpDataSourceFactory(HttpDataSource.Factory)`
      Returns:
        This factory, for convenience.

    - #### setDrmSessionManager

          @Deprecated
          MediaSourceFactory setDrmSessionManager​(@Nullable
                                                  DrmSessionManager drmSessionManager)

      Deprecated.
      Use `setDrmSessionManagerProvider(DrmSessionManagerProvider)` and pass an implementation that always returns the same instance.
      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)`.

      Parameters:
        `drmSessionManager` - The `DrmSessionManager`, or `null` to use the `DefaultDrmSessionManager`.
      Returns:
        This factory, for convenience.

    - #### setDrmHttpDataSourceFactory

          @Deprecated
          MediaSourceFactory setDrmHttpDataSourceFactory​(@Nullable
                                                         HttpDataSource.Factory drmHttpDataSourceFactory)

      Deprecated.
      Use `setDrmSessionManagerProvider(DrmSessionManagerProvider)` and pass an implementation that configures the returned `DrmSessionManager` with the desired `HttpDataSource.Factory`.
      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.

      Parameters:
        `drmHttpDataSourceFactory` - The HTTP data source factory, or `null` to use `DefaultHttpDataSourceFactory`.
      Returns:
        This factory, for convenience.

    - #### setDrmUserAgent

          @Deprecated
          MediaSourceFactory setDrmUserAgent​(@Nullable
                                             String userAgent)

      Deprecated.
      Use `setDrmSessionManagerProvider(DrmSessionManagerProvider)` and pass an implementation that configures the returned `DrmSessionManager` with the desired `userAgent`.
      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`.
      Parameters:
        `userAgent` - The user agent to be used for DRM requests, or `null` to use the default.
      Returns:
        This factory, for convenience.

    - #### setLoadErrorHandlingPolicy

          MediaSourceFactory setLoadErrorHandlingPolicy​(@Nullable
                                                        LoadErrorHandlingPolicy loadErrorHandlingPolicy)

      Sets an optional `LoadErrorHandlingPolicy`.
      Parameters:
        `loadErrorHandlingPolicy` - A `LoadErrorHandlingPolicy`, or `null` to use the `DefaultLoadErrorHandlingPolicy`.
      Returns:
        This factory, for convenience.

    - #### getSupportedTypes

          @ContentType
          int[] getSupportedTypes()

      Returns the `content types` supported by media sources created by this factory.

    - #### createMediaSource

          MediaSource createMediaSource​(MediaItem mediaItem)

      Creates a new `MediaSource` with the specified `MediaItem`.
      Parameters:
        `mediaItem` - The media item to play.
      Returns:
        The new `media source`.

    - #### createMediaSource

          @Deprecated
          default MediaSource createMediaSource​(Uri uri)

      Deprecated.
      Use `createMediaSource(MediaItem)` instead.