Package com.google.android.exoplayer2.source

## Class SingleSampleMediaSource.Factory

- java.lang.Object
- - com.google.android.exoplayer2.source.SingleSampleMediaSource.Factory

- Enclosing class:
    SingleSampleMediaSource

      public static final class SingleSampleMediaSource.Factory
      extends Object

  Factory for `SingleSampleMediaSource`.

- - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `Factory​(DataSource.Factory dataSourceFactory)` | Creates a factory for `SingleSampleMediaSource`s.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods Deprecated Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `SingleSampleMediaSource` | `createMediaSource​(Uri uri, Format format, long durationUs)` | Deprecated. Use `createMediaSource(MediaItem.Subtitle, long)` instead.
    `SingleSampleMediaSource` | `createMediaSource​(MediaItem.Subtitle subtitle, long durationUs)` | Returns a new `SingleSampleMediaSource` using the current parameters.
    `SingleSampleMediaSource.Factory` | `setLoadErrorHandlingPolicy​(LoadErrorHandlingPolicy loadErrorHandlingPolicy)` | Sets the `LoadErrorHandlingPolicy`.
    `SingleSampleMediaSource.Factory` | `setTag​(Object tag)` | Sets a tag for the media source which will be published in the `Timeline` of the source as `Window#mediaItem.playbackProperties.tag`.
    `SingleSampleMediaSource.Factory` | `setTrackId​(String trackId)` | Sets an optional track id to be used.
    `SingleSampleMediaSource.Factory` | `setTreatLoadErrorsAsEndOfStream​(boolean treatLoadErrorsAsEndOfStream)` | Sets whether load errors will be treated as end-of-stream signal (load errors will not be propagated).

    - ### 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 factory for `SingleSampleMediaSource`s.
      Parameters:
        `dataSourceFactory` - The factory from which the `DataSource` to read the media will be obtained.

  - ### Method Detail

    - #### setTag

          public SingleSampleMediaSource.Factory setTag​(@Nullable
                                                        Object tag)

      Sets a tag for the media source which will be published in the `Timeline` of the source as `Window#mediaItem.playbackProperties.tag`.
      Parameters:
        `tag` - A tag for the media source.
      Returns:
        This factory, for convenience.

    - #### setTrackId

          public SingleSampleMediaSource.Factory setTrackId​(@Nullable
                                                            String trackId)

      Sets an optional track id to be used.
      Parameters:
        `trackId` - An optional track id.
      Returns:
        This factory, for convenience.

    - #### setLoadErrorHandlingPolicy

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

      Sets the `LoadErrorHandlingPolicy`. The default value is created by calling `DefaultLoadErrorHandlingPolicy()`.
      Parameters:
        `loadErrorHandlingPolicy` - A `LoadErrorHandlingPolicy`.
      Returns:
        This factory, for convenience.

    - #### setTreatLoadErrorsAsEndOfStream

          public SingleSampleMediaSource.Factory setTreatLoadErrorsAsEndOfStream​(boolean treatLoadErrorsAsEndOfStream)

      Sets whether load errors will be treated as end-of-stream signal (load errors will not be propagated). The default value is true.
      Parameters:
        `treatLoadErrorsAsEndOfStream` - If true, load errors will not be propagated by sample streams, treating them as ended instead. If false, load errors will be propagated normally by `SampleStream.maybeThrowError()`.
      Returns:
        This factory, for convenience.

    - #### createMediaSource

          public SingleSampleMediaSource createMediaSource​(MediaItem.Subtitle subtitle,
                                                           long durationUs)

      Returns a new `SingleSampleMediaSource` using the current parameters.
      Parameters:
        `subtitle` - The `MediaItem.Subtitle`.
        `durationUs` - The duration of the media stream in microseconds.
      Returns:
        The new `SingleSampleMediaSource`.

    - #### createMediaSource

          @Deprecated
          public SingleSampleMediaSource createMediaSource​(Uri uri,
                                                           Format format,
                                                           long durationUs)

      Deprecated.
      Use `createMediaSource(MediaItem.Subtitle, long)` instead.