Package com.google.android.exoplayer2.testutil

## Class TestExoPlayerBuilder

- java.lang.Object
- - com.google.android.exoplayer2.testutil.TestExoPlayerBuilder

-     public class TestExoPlayerBuilder
      extends Object

  A builder of `ExoPlayer` instances for testing.

- - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `TestExoPlayerBuilder​(Context context)` |

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `ExoPlayer` | `build()` | Builds an `ExoPlayer` using the provided values or their defaults.
    `BandwidthMeter` | `getBandwidthMeter()` | Returns the bandwidth meter used by the player.
    `Clock` | `getClock()` | Returns the clock used by the player.
    `LoadControl` | `getLoadControl()` | Returns the `LoadControl` that will be used by the player.
    `Looper` | `getLooper()` | Returns the `Looper` that will be used by the player, or null if no `Looper` has been set yet and no default is available.
    `MediaSource.Factory` | `getMediaSourceFactory()` | Returns the `MediaSource.Factory` that will be used by the player, or null if no `MediaSource.Factory` has been set yet and no default is available.
    `Renderer[]` | `getRenderers()` | Returns the `Renderers` that have been set with `setRenderers(com.google.android.exoplayer2.Renderer...)` or null if no `Renderers` have been explicitly set.
    `RenderersFactory` | `getRenderersFactory()` | Returns the `RenderersFactory` that has been set with `setRenderersFactory(com.google.android.exoplayer2.RenderersFactory)` or null if no factory has been explicitly set.
    `long` | `getSeekBackIncrementMs()` | Returns the seek back increment used by the player.
    `long` | `getSeekForwardIncrementMs()` | Returns the seek forward increment used by the player.
    `DefaultTrackSelector` | `getTrackSelector()` | Returns the track selector used by the player.
    `boolean` | `getUseLazyPreparation()` | Returns whether the player will use lazy preparation.
    `TestExoPlayerBuilder` | `setBandwidthMeter​(BandwidthMeter bandwidthMeter)` | Sets the `BandwidthMeter`.
    `TestExoPlayerBuilder` | `setClock​(Clock clock)` | Sets the `Clock` to be used by the player.
    `TestExoPlayerBuilder` | `setLoadControl​(LoadControl loadControl)` | Sets a `LoadControl` to be used by the player.
    `TestExoPlayerBuilder` | `setLooper​(Looper looper)` | Sets the `Looper` to be used by the player.
    `TestExoPlayerBuilder` | `setMediaSourceFactory​(MediaSource.Factory mediaSourceFactory)` | Sets the `MediaSource.Factory` to be used by the player.
    `TestExoPlayerBuilder` | `setRenderers​(Renderer... renderers)` | Sets the `Renderer`s.
    `TestExoPlayerBuilder` | `setRenderersFactory​(RenderersFactory renderersFactory)` | Sets the `RenderersFactory`.
    `TestExoPlayerBuilder` | `setSeekBackIncrementMs​(long seekBackIncrementMs)` | Sets the seek back increment to be used by the player.
    `TestExoPlayerBuilder` | `setSeekForwardIncrementMs​(long seekForwardIncrementMs)` | Sets the seek forward increment to be used by the player.
    `TestExoPlayerBuilder` | `setTrackSelector​(DefaultTrackSelector trackSelector)` | Sets a `DefaultTrackSelector`.
    `TestExoPlayerBuilder` | `setUseLazyPreparation​(boolean useLazyPreparation)` | Sets whether to use lazy preparation.

    - ### Methods inherited from class java.lang.Object

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

- - ### Constructor Detail

    - #### TestExoPlayerBuilder

          public TestExoPlayerBuilder​(Context context)

  - ### Method Detail

    - #### setUseLazyPreparation

          @CanIgnoreReturnValue
          public TestExoPlayerBuilder setUseLazyPreparation​(boolean useLazyPreparation)

      Sets whether to use lazy preparation.
      Parameters:
        `useLazyPreparation` - Whether to use lazy preparation.
      Returns:
        This builder.

    - #### getUseLazyPreparation

          public boolean getUseLazyPreparation()

      Returns whether the player will use lazy preparation.

    - #### setTrackSelector

          @CanIgnoreReturnValue
          public TestExoPlayerBuilder setTrackSelector​(DefaultTrackSelector trackSelector)

      Sets a `DefaultTrackSelector`. The default value is a `DefaultTrackSelector` in its initial configuration.
      Parameters:
        `trackSelector` - The `DefaultTrackSelector` to be used by the player.
      Returns:
        This builder.

    - #### getTrackSelector

          public DefaultTrackSelector getTrackSelector()

      Returns the track selector used by the player.

    - #### setLoadControl

          @CanIgnoreReturnValue
          public TestExoPlayerBuilder setLoadControl​(LoadControl loadControl)

      Sets a `LoadControl` to be used by the player. The default value is a `DefaultLoadControl`.
      Parameters:
        `loadControl` - The `LoadControl` to be used by the player.
      Returns:
        This builder.

    - #### getLoadControl

          public LoadControl getLoadControl()

      Returns the `LoadControl` that will be used by the player.

    - #### setBandwidthMeter

          @CanIgnoreReturnValue
          public TestExoPlayerBuilder setBandwidthMeter​(BandwidthMeter bandwidthMeter)

      Sets the `BandwidthMeter`. The default value is a `DefaultBandwidthMeter` in its default configuration.
      Parameters:
        `bandwidthMeter` - The `BandwidthMeter` to be used by the player.
      Returns:
        This builder.

    - #### getBandwidthMeter

          public BandwidthMeter getBandwidthMeter()

      Returns the bandwidth meter used by the player.

    - #### setRenderers

          @CanIgnoreReturnValue
          public TestExoPlayerBuilder setRenderers​(Renderer... renderers)

      Sets the `Renderer`s. If not set, the player will use a `FakeVideoRenderer` and a `FakeAudioRenderer`. Setting the renderers is not allowed after a call to `setRenderersFactory(RenderersFactory)`.
      Parameters:
        `renderers` - A list of `Renderer`s to be used by the player.
      Returns:
        This builder.

    - #### getRenderers

          @Nullable
          public Renderer[] getRenderers()

      Returns the `Renderers` that have been set with `setRenderers(com.google.android.exoplayer2.Renderer...)` or null if no `Renderers` have been explicitly set. Note that these renderers may not be the ones used by the built player, for example if a `Renderer factory` has been set.

    - #### setRenderersFactory

          @CanIgnoreReturnValue
          public TestExoPlayerBuilder setRenderersFactory​(RenderersFactory renderersFactory)

      Sets the `RenderersFactory`. The default factory creates all renderers set by `setRenderers(Renderer...)`. Setting the renderer factory is not allowed after a call to `setRenderers(Renderer...)`.
      Parameters:
        `renderersFactory` - A `RenderersFactory` to be used by the player.
      Returns:
        This builder.

    - #### getRenderersFactory

          @Nullable
          public RenderersFactory getRenderersFactory()

      Returns the `RenderersFactory` that has been set with `setRenderersFactory(com.google.android.exoplayer2.RenderersFactory)` or null if no factory has been explicitly set.

    - #### setClock

          @CanIgnoreReturnValue
          public TestExoPlayerBuilder setClock​(Clock clock)

      Sets the `Clock` to be used by the player. The default value is an auto-advancing `FakeClock`.
      Parameters:
        `clock` - A `Clock` to be used by the player.
      Returns:
        This builder.

    - #### getClock

          public Clock getClock()

      Returns the clock used by the player.

    - #### setLooper

          @CanIgnoreReturnValue
          public TestExoPlayerBuilder setLooper​(Looper looper)

      Sets the `Looper` to be used by the player.
      Parameters:
        `looper` - The `Looper` to be used by the player.
      Returns:
        This builder.

    - #### getLooper

          @Nullable
          public Looper getLooper()

      Returns the `Looper` that will be used by the player, or null if no `Looper` has been set yet and no default is available.

    - #### getMediaSourceFactory

          @Nullable
          public MediaSource.Factory getMediaSourceFactory()

      Returns the `MediaSource.Factory` that will be used by the player, or null if no `MediaSource.Factory` has been set yet and no default is available.

    - #### setMediaSourceFactory

          @CanIgnoreReturnValue
          public TestExoPlayerBuilder setMediaSourceFactory​(MediaSource.Factory mediaSourceFactory)

      Sets the `MediaSource.Factory` to be used by the player.
      Parameters:
        `mediaSourceFactory` - The `MediaSource.Factory` to be used by the player.
      Returns:
        This builder.

    - #### setSeekBackIncrementMs

          @CanIgnoreReturnValue
          public TestExoPlayerBuilder setSeekBackIncrementMs​(long seekBackIncrementMs)

      Sets the seek back increment to be used by the player.
      Parameters:
        `seekBackIncrementMs` - The seek back increment to be used by the player.
      Returns:
        This builder.

    - #### getSeekBackIncrementMs

          public long getSeekBackIncrementMs()

      Returns the seek back increment used by the player.

    - #### setSeekForwardIncrementMs

          @CanIgnoreReturnValue
          public TestExoPlayerBuilder setSeekForwardIncrementMs​(long seekForwardIncrementMs)

      Sets the seek forward increment to be used by the player.
      Parameters:
        `seekForwardIncrementMs` - The seek forward increment to be used by the player.
      Returns:
        This builder.

    - #### getSeekForwardIncrementMs

          public long getSeekForwardIncrementMs()

      Returns the seek forward increment used by the player.

    - #### build

          public ExoPlayer build()

      Builds an `ExoPlayer` using the provided values or their defaults.