Back to Exoplayer

ExoPlayer.Builder (ExoPlayer library)

docs/doc/reference/com/google/android/exoplayer2/ExoPlayer.Builder.html

latest42.5 KB
Original Source

Package com.google.android.exoplayer2

Class ExoPlayer.Builder


public static final classExoPlayer.Builderextends[Object](https://developer.android.com/reference/java/lang/Object.html "class or interface in java.lang")

A builder for ExoPlayer instances.

See Builder(Context) for the list of default values.

Constructor Summary

Constructors | Constructor | Description | | --- | --- | | Builder​(Context context) | Creates a builder. | | Builder​(Context context, RenderersFactory renderersFactory) | Creates a builder with a custom RenderersFactory. | | Builder​(Context context, RenderersFactory renderersFactory, MediaSource.Factory mediaSourceFactory) | Creates a builder with a custom RenderersFactory and MediaSource.Factory. | | Builder​(Context context, RenderersFactory renderersFactory, MediaSource.Factory mediaSourceFactory, TrackSelector trackSelector, LoadControl loadControl, BandwidthMeter bandwidthMeter, AnalyticsCollector analyticsCollector) | Creates a builder with the specified custom components. | | Builder​(Context context, MediaSource.Factory mediaSourceFactory) | Creates a builder with a custom MediaSource.Factory. |

Method Summary

All Methods Instance Methods Concrete Methods | Modifier and Type | Method | Description | | --- | --- | --- | | ExoPlayer | build() | Builds an ExoPlayer instance. | | ExoPlayer.Builder | experimentalSetForegroundModeTimeoutMs​(long timeoutMs) | Sets a limit on the time a call to ExoPlayer.setForegroundMode(boolean) can spend. | | ExoPlayer.Builder | setAnalyticsCollector​(AnalyticsCollector analyticsCollector) | Sets the AnalyticsCollector that will collect and forward all player events. | | ExoPlayer.Builder | setAudioAttributes​(AudioAttributes audioAttributes, boolean handleAudioFocus) | Sets AudioAttributes that will be used by the player and whether to handle audio focus. | | ExoPlayer.Builder | setBandwidthMeter​(BandwidthMeter bandwidthMeter) | Sets the BandwidthMeter that will be used by the player. | | ExoPlayer.Builder | setClock​(Clock clock) | Sets the Clock that will be used by the player. | | ExoPlayer.Builder | setDetachSurfaceTimeoutMs​(long detachSurfaceTimeoutMs) | Sets a timeout for detaching a surface from the player. | | ExoPlayer.Builder | setDeviceVolumeControlEnabled​(boolean deviceVolumeControlEnabled) | Sets whether the player is allowed to set, increase, decrease or mute device volume. | | ExoPlayer.Builder | setHandleAudioBecomingNoisy​(boolean handleAudioBecomingNoisy) | Sets whether the player should pause automatically when audio is rerouted from a headset to device speakers. | | ExoPlayer.Builder | setLivePlaybackSpeedControl​(LivePlaybackSpeedControl livePlaybackSpeedControl) | Sets the LivePlaybackSpeedControl that will control the playback speed when playing live streams, in order to maintain a steady target offset from the live stream edge. | | ExoPlayer.Builder | setLoadControl​(LoadControl loadControl) | Sets the LoadControl that will be used by the player. | | ExoPlayer.Builder | setLooper​(Looper looper) | Sets the Looper that must be used for all calls to the player and that is used to call listeners on. | | ExoPlayer.Builder | setMediaSourceFactory​(MediaSource.Factory mediaSourceFactory) | Sets the MediaSource.Factory that will be used by the player. | | ExoPlayer.Builder | setPauseAtEndOfMediaItems​(boolean pauseAtEndOfMediaItems) | Sets whether to pause playback at the end of each media item. | | ExoPlayer.Builder | setPlaybackLooper​(Looper playbackLooper) | Sets the Looper that will be used for playback. | | ExoPlayer.Builder | setPriorityTaskManager​(PriorityTaskManager priorityTaskManager) | Sets an PriorityTaskManager that will be used by the player. | | ExoPlayer.Builder | setReleaseTimeoutMs​(long releaseTimeoutMs) | Sets a timeout for calls to Player.release() and ExoPlayer.setForegroundMode(boolean). | | ExoPlayer.Builder | setRenderersFactory​(RenderersFactory renderersFactory) | Sets the RenderersFactory that will be used by the player. | | ExoPlayer.Builder | setSeekBackIncrementMs​(long seekBackIncrementMs) | Sets the Player.seekBack() increment. | | ExoPlayer.Builder | setSeekForwardIncrementMs​(long seekForwardIncrementMs) | Sets the Player.seekForward() increment. | | ExoPlayer.Builder | setSeekParameters​(SeekParameters seekParameters) | Sets the parameters that control how seek operations are performed. | | ExoPlayer.Builder | setSkipSilenceEnabled​(boolean skipSilenceEnabled) | Sets whether silences silences in the audio stream is enabled. | | ExoPlayer.Builder | setTrackSelector​(TrackSelector trackSelector) | Sets the TrackSelector that will be used by the player. | | ExoPlayer.Builder | setUseLazyPreparation​(boolean useLazyPreparation) | Sets whether media sources should be initialized lazily. | | ExoPlayer.Builder | setUsePlatformDiagnostics​(boolean usePlatformDiagnostics) | Sets whether the player reports diagnostics data to the Android platform. | | ExoPlayer.Builder | setVideoChangeFrameRateStrategy​(@com.google.android.exoplayer2.C.VideoChangeFrameRateStrategy int videoChangeFrameRateStrategy) | Sets a C.VideoChangeFrameRateStrategy that will be used by the player when provided with a video output Surface. | | ExoPlayer.Builder | setVideoScalingMode​(@com.google.android.exoplayer2.C.VideoScalingMode int videoScalingMode) | Sets the C.VideoScalingMode that will be used by the player. | | ExoPlayer.Builder | setWakeMode​(@com.google.android.exoplayer2.C.WakeMode int wakeMode) | Sets the C.WakeMode that will be used by the player. |

- 

Methods inherited from class java.lang.Object

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

Constructor Detail

- 

Builder

public Builder​([Context](https://developer.android.com/reference/android/content/Context.html "class or interface in android.content")context)

Creates a builder.

Use Builder(Context, RenderersFactory), Builder(Context, MediaSource.Factory) or Builder(Context, RenderersFactory, MediaSource.Factory) instead, if you intend to provide a custom RenderersFactory, ExtractorsFactory or DefaultMediaSourceFactory. This is to ensure that ProGuard or R8 can remove ExoPlayer's DefaultRenderersFactory, DefaultExtractorsFactory and DefaultMediaSourceFactory from the APK.

The builder uses the following default values:

  - [`RenderersFactory`](RenderersFactory.html "interface in com.google.android.exoplayer2"): [`DefaultRenderersFactory`](DefaultRenderersFactory.html "class in com.google.android.exoplayer2")
  - [`TrackSelector`](trackselection/TrackSelector.html "class in com.google.android.exoplayer2.trackselection"): [`DefaultTrackSelector`](trackselection/DefaultTrackSelector.html "class in com.google.android.exoplayer2.trackselection")
  - [`MediaSource.Factory`](source/MediaSource.Factory.html "interface in com.google.android.exoplayer2.source"): [`DefaultMediaSourceFactory`](source/DefaultMediaSourceFactory.html "class in com.google.android.exoplayer2.source")
  - [`LoadControl`](LoadControl.html "interface in com.google.android.exoplayer2"): [`DefaultLoadControl`](DefaultLoadControl.html "class in com.google.android.exoplayer2")
  - [`BandwidthMeter`](upstream/BandwidthMeter.html "interface in com.google.android.exoplayer2.upstream"): [`DefaultBandwidthMeter.getSingletonInstance(Context)`](upstream/DefaultBandwidthMeter.html#getSingletonInstance(android.content.Context))
  - [`LivePlaybackSpeedControl`](LivePlaybackSpeedControl.html "interface in com.google.android.exoplayer2"): [`DefaultLivePlaybackSpeedControl`](DefaultLivePlaybackSpeedControl.html "class in com.google.android.exoplayer2")
  - [`Looper`](https://developer.android.com/reference/android/os/Looper.html "class or interface in android.os"): The [`Looper`](https://developer.android.com/reference/android/os/Looper.html?is-external=true "class or interface in android.os") associated with the current thread, or the [`Looper`](https://developer.android.com/reference/android/os/Looper.html?is-external=true "class or interface in android.os") of the application's main thread if the current thread doesn't have a [`Looper`](https://developer.android.com/reference/android/os/Looper.html?is-external=true "class or interface in android.os")
  - [`AnalyticsCollector`](analytics/AnalyticsCollector.html "interface in com.google.android.exoplayer2.analytics"): [`AnalyticsCollector`](analytics/AnalyticsCollector.html "interface in com.google.android.exoplayer2.analytics") with [`Clock.DEFAULT`](util/Clock.html#DEFAULT)
  - [`PriorityTaskManager`](util/PriorityTaskManager.html "class in com.google.android.exoplayer2.util"): `null` (not used) 
  - [`AudioAttributes`](audio/AudioAttributes.html "class in com.google.android.exoplayer2.audio"): [`AudioAttributes.DEFAULT`](audio/AudioAttributes.html#DEFAULT), not handling audio focus 
  - [`C.WakeMode`](C.WakeMode.html "annotation in com.google.android.exoplayer2"): [`C.WAKE_MODE_NONE`](C.html#WAKE_MODE_NONE)
  - `handleAudioBecomingNoisy`: `false`
  - `skipSilenceEnabled`: `false`
  - [`C.VideoScalingMode`](C.VideoScalingMode.html "annotation in com.google.android.exoplayer2"): [`C.VIDEO_SCALING_MODE_DEFAULT`](C.html#VIDEO_SCALING_MODE_DEFAULT)
  - [`C.VideoChangeFrameRateStrategy`](C.VideoChangeFrameRateStrategy.html "annotation in com.google.android.exoplayer2"): [`C.VIDEO_CHANGE_FRAME_RATE_STRATEGY_ONLY_IF_SEAMLESS`](C.html#VIDEO_CHANGE_FRAME_RATE_STRATEGY_ONLY_IF_SEAMLESS)
  - `useLazyPreparation`: `true`
  - [`SeekParameters`](SeekParameters.html "class in com.google.android.exoplayer2"): [`SeekParameters.DEFAULT`](SeekParameters.html#DEFAULT)
  - `seekBackIncrementMs`: [`C.DEFAULT_SEEK_BACK_INCREMENT_MS`](C.html#DEFAULT_SEEK_BACK_INCREMENT_MS)
  - `seekForwardIncrementMs`: [`C.DEFAULT_SEEK_FORWARD_INCREMENT_MS`](C.html#DEFAULT_SEEK_FORWARD_INCREMENT_MS)
  - `releaseTimeoutMs`: [`ExoPlayer.DEFAULT_RELEASE_TIMEOUT_MS`](ExoPlayer.html#DEFAULT_RELEASE_TIMEOUT_MS)
  - `detachSurfaceTimeoutMs`: [`ExoPlayer.DEFAULT_DETACH_SURFACE_TIMEOUT_MS`](ExoPlayer.html#DEFAULT_DETACH_SURFACE_TIMEOUT_MS)
  - `pauseAtEndOfMediaItems`: `false`
  - `usePlatformDiagnostics`: `true`
  - [`Clock`](util/Clock.html "interface in com.google.android.exoplayer2.util"): [`Clock.DEFAULT`](util/Clock.html#DEFAULT)
  - `playbackLooper`: `null` (create new thread) 

Parameters:context - A Context.

- 

Builder

public Builder​([Context](https://developer.android.com/reference/android/content/Context.html "class or interface in android.content")context,[RenderersFactory](RenderersFactory.html "interface in com.google.android.exoplayer2")renderersFactory)

Creates a builder with a custom RenderersFactory.

See Builder(Context) for a list of default values.

Note that this constructor is only useful to try and ensure that ExoPlayer's DefaultRenderersFactory can be removed by ProGuard or R8.

Parameters:context - A Context.renderersFactory - A factory for creating Renderers to be used by the player.

- 

Builder

public Builder​([Context](https://developer.android.com/reference/android/content/Context.html "class or interface in android.content")context,[MediaSource.Factory](source/MediaSource.Factory.html "interface in com.google.android.exoplayer2.source")mediaSourceFactory)

Creates a builder with a custom MediaSource.Factory.

See Builder(Context) for a list of default values.

Note that this constructor is only useful to try and ensure that ExoPlayer's DefaultMediaSourceFactory (and therefore DefaultExtractorsFactory) can be removed by ProGuard or R8.

Parameters:context - A Context.mediaSourceFactory - A factory for creating a MediaSource from a MediaItem.

- 

Builder

public Builder​([Context](https://developer.android.com/reference/android/content/Context.html "class or interface in android.content")context,[RenderersFactory](RenderersFactory.html "interface in com.google.android.exoplayer2")renderersFactory,[MediaSource.Factory](source/MediaSource.Factory.html "interface in com.google.android.exoplayer2.source")mediaSourceFactory)

Creates a builder with a custom RenderersFactory and MediaSource.Factory.

See Builder(Context) for a list of default values.

Note that this constructor is only useful to try and ensure that ExoPlayer's DefaultRenderersFactory, DefaultMediaSourceFactory (and therefore DefaultExtractorsFactory) can be removed by ProGuard or R8.

Parameters:context - A Context.renderersFactory - A factory for creating Renderers to be used by the player.mediaSourceFactory - A factory for creating a MediaSource from a MediaItem.

- 

Builder

public Builder​([Context](https://developer.android.com/reference/android/content/Context.html "class or interface in android.content")context,[RenderersFactory](RenderersFactory.html "interface in com.google.android.exoplayer2")renderersFactory,[MediaSource.Factory](source/MediaSource.Factory.html "interface in com.google.android.exoplayer2.source")mediaSourceFactory,[TrackSelector](trackselection/TrackSelector.html "class in com.google.android.exoplayer2.trackselection")trackSelector,[LoadControl](LoadControl.html "interface in com.google.android.exoplayer2")loadControl,[BandwidthMeter](upstream/BandwidthMeter.html "interface in com.google.android.exoplayer2.upstream")bandwidthMeter,[AnalyticsCollector](analytics/AnalyticsCollector.html "interface in com.google.android.exoplayer2.analytics")analyticsCollector)

Creates a builder with the specified custom components.

Note that this constructor is only useful to try and ensure that ExoPlayer's default components can be removed by ProGuard or R8.

Parameters:context - A Context.renderersFactory - A factory for creating Renderers to be used by the player.mediaSourceFactory - A MediaSource.Factory.trackSelector - A TrackSelector.loadControl - A LoadControl.bandwidthMeter - A BandwidthMeter.analyticsCollector - An AnalyticsCollector.

Method Detail

- 

experimentalSetForegroundModeTimeoutMs

@CanIgnoreReturnValue
public[ExoPlayer.Builder](ExoPlayer.Builder.html "class in com.google.android.exoplayer2")experimentalSetForegroundModeTimeoutMs​(long timeoutMs)

Sets a limit on the time a call to ExoPlayer.setForegroundMode(boolean) can spend. If a call to ExoPlayer.setForegroundMode(boolean) takes more than timeoutMs milliseconds to complete, the player will raise an error via Player.Listener.onPlayerError(com.google.android.exoplayer2.PlaybackException).

This method is experimental, and will be renamed or removed in a future release.

Parameters:timeoutMs - The time limit in milliseconds.

- 

setRenderersFactory

@CanIgnoreReturnValue
public[ExoPlayer.Builder](ExoPlayer.Builder.html "class in com.google.android.exoplayer2")setRenderersFactory​([RenderersFactory](RenderersFactory.html "interface in com.google.android.exoplayer2")renderersFactory)

Sets the RenderersFactory that will be used by the player. Parameters:renderersFactory - A RenderersFactory.Returns:This builder.Throws:IllegalStateException - If build() has already been called.

- 

setMediaSourceFactory

@CanIgnoreReturnValue
public[ExoPlayer.Builder](ExoPlayer.Builder.html "class in com.google.android.exoplayer2")setMediaSourceFactory​([MediaSource.Factory](source/MediaSource.Factory.html "interface in com.google.android.exoplayer2.source")mediaSourceFactory)

Sets the MediaSource.Factory that will be used by the player. Parameters:mediaSourceFactory - A MediaSource.Factory.Returns:This builder.Throws:IllegalStateException - If build() has already been called.

- 

setTrackSelector

@CanIgnoreReturnValue
public[ExoPlayer.Builder](ExoPlayer.Builder.html "class in com.google.android.exoplayer2")setTrackSelector​([TrackSelector](trackselection/TrackSelector.html "class in com.google.android.exoplayer2.trackselection")trackSelector)

Sets the TrackSelector that will be used by the player. Parameters:trackSelector - A TrackSelector.Returns:This builder.Throws:IllegalStateException - If build() has already been called.

- 

setLoadControl

@CanIgnoreReturnValue
public[ExoPlayer.Builder](ExoPlayer.Builder.html "class in com.google.android.exoplayer2")setLoadControl​([LoadControl](LoadControl.html "interface in com.google.android.exoplayer2")loadControl)

Sets the LoadControl that will be used by the player. Parameters:loadControl - A LoadControl.Returns:This builder.Throws:IllegalStateException - If build() has already been called.

- 

setBandwidthMeter

@CanIgnoreReturnValue
public[ExoPlayer.Builder](ExoPlayer.Builder.html "class in com.google.android.exoplayer2")setBandwidthMeter​([BandwidthMeter](upstream/BandwidthMeter.html "interface in com.google.android.exoplayer2.upstream")bandwidthMeter)

Sets the BandwidthMeter that will be used by the player. Parameters:bandwidthMeter - A BandwidthMeter.Returns:This builder.Throws:IllegalStateException - If build() has already been called.

- 

setLooper

@CanIgnoreReturnValue
public[ExoPlayer.Builder](ExoPlayer.Builder.html "class in com.google.android.exoplayer2")setLooper​([Looper](https://developer.android.com/reference/android/os/Looper.html "class or interface in android.os")looper)

Sets the Looper that must be used for all calls to the player and that is used to call listeners on. Parameters:looper - A Looper.Returns:This builder.Throws:IllegalStateException - If build() has already been called.

- 

setAnalyticsCollector

@CanIgnoreReturnValue
public[ExoPlayer.Builder](ExoPlayer.Builder.html "class in com.google.android.exoplayer2")setAnalyticsCollector​([AnalyticsCollector](analytics/AnalyticsCollector.html "interface in com.google.android.exoplayer2.analytics")analyticsCollector)

Sets the AnalyticsCollector that will collect and forward all player events. Parameters:analyticsCollector - An AnalyticsCollector.Returns:This builder.Throws:IllegalStateException - If build() has already been called.

- 

setPriorityTaskManager

@CanIgnoreReturnValue
public[ExoPlayer.Builder](ExoPlayer.Builder.html "class in com.google.android.exoplayer2")setPriorityTaskManager​(@Nullable[PriorityTaskManager](util/PriorityTaskManager.html "class in com.google.android.exoplayer2.util")priorityTaskManager)

Sets an PriorityTaskManager that will be used by the player.

The priority C.PRIORITY_PLAYBACK will be set while the player is loading.

Parameters:priorityTaskManager - A PriorityTaskManager, or null to not use one.Returns:This builder.Throws:IllegalStateException - If build() has already been called.

- 

setAudioAttributes

@CanIgnoreReturnValue
public[ExoPlayer.Builder](ExoPlayer.Builder.html "class in com.google.android.exoplayer2")setAudioAttributes​([AudioAttributes](audio/AudioAttributes.html "class in com.google.android.exoplayer2.audio")audioAttributes,
                                            boolean handleAudioFocus)

Sets AudioAttributes that will be used by the player and whether to handle audio focus.

If audio focus should be handled, the AudioAttributes.usage must be C.USAGE_MEDIA or C.USAGE_GAME. Other usages will throw an IllegalArgumentException.

Parameters:audioAttributes - AudioAttributes.handleAudioFocus - Whether the player should handle audio focus.Returns:This builder.Throws:IllegalStateException - If build() has already been called.

- 

setWakeMode

@CanIgnoreReturnValue
public[ExoPlayer.Builder](ExoPlayer.Builder.html "class in com.google.android.exoplayer2")setWakeMode​([@WakeMode](C.WakeMode.html "annotation in com.google.android.exoplayer2")@com.google.android.exoplayer2.C.WakeMode int wakeMode)

Sets the C.WakeMode that will be used by the player.

Enabling this feature requires the Manifest.permission.WAKE_LOCK permission. It should be used together with a foreground Service for use cases where playback occurs and the screen is off (e.g. background audio playback). It is not useful when the screen will be kept on during playback (e.g. foreground video playback).

When enabled, the locks (PowerManager.WakeLock / WifiManager.WifiLock) will be held whenever the player is in the Player.STATE_READY or Player.STATE_BUFFERING states with playWhenReady = true. The locks held depend on the specified C.WakeMode.

Parameters:wakeMode - A C.WakeMode.Returns:This builder.Throws:IllegalStateException - If build() has already been called.

- 

setHandleAudioBecomingNoisy

@CanIgnoreReturnValue
public[ExoPlayer.Builder](ExoPlayer.Builder.html "class in com.google.android.exoplayer2")setHandleAudioBecomingNoisy​(boolean handleAudioBecomingNoisy)

Sets whether the player should pause automatically when audio is rerouted from a headset to device speakers. See the audio becoming noisy documentation for more information. Parameters:handleAudioBecomingNoisy - Whether the player should pause automatically when audio is rerouted from a headset to device speakers.Returns:This builder.Throws:IllegalStateException - If build() has already been called.

- 

setSkipSilenceEnabled

@CanIgnoreReturnValue
public[ExoPlayer.Builder](ExoPlayer.Builder.html "class in com.google.android.exoplayer2")setSkipSilenceEnabled​(boolean skipSilenceEnabled)

Sets whether silences silences in the audio stream is enabled. Parameters:skipSilenceEnabled - Whether skipping silences is enabled.Returns:This builder.Throws:IllegalStateException - If build() has already been called.

- 

setDeviceVolumeControlEnabled

@CanIgnoreReturnValue
public[ExoPlayer.Builder](ExoPlayer.Builder.html "class in com.google.android.exoplayer2")setDeviceVolumeControlEnabled​(boolean deviceVolumeControlEnabled)

Sets whether the player is allowed to set, increase, decrease or mute device volume. Parameters:deviceVolumeControlEnabled - Whether controlling device volume is enabled.Returns:This builder.Throws:IllegalStateException - If build() has already been called.

- 

setVideoScalingMode

@CanIgnoreReturnValue
public[ExoPlayer.Builder](ExoPlayer.Builder.html "class in com.google.android.exoplayer2")setVideoScalingMode​([@VideoScalingMode](C.VideoScalingMode.html "annotation in com.google.android.exoplayer2")@com.google.android.exoplayer2.C.VideoScalingMode int videoScalingMode)

Sets the C.VideoScalingMode that will be used by the player.

The scaling mode only applies if a MediaCodec-based video Renderer is enabled and if the output surface is owned by a SurfaceView.

Parameters:videoScalingMode - A C.VideoScalingMode.Returns:This builder.Throws:IllegalStateException - If build() has already been called.

- 

setVideoChangeFrameRateStrategy

@CanIgnoreReturnValue
public[ExoPlayer.Builder](ExoPlayer.Builder.html "class in com.google.android.exoplayer2")setVideoChangeFrameRateStrategy​([@VideoChangeFrameRateStrategy](C.VideoChangeFrameRateStrategy.html "annotation in com.google.android.exoplayer2")@com.google.android.exoplayer2.C.VideoChangeFrameRateStrategy int videoChangeFrameRateStrategy)

Sets a C.VideoChangeFrameRateStrategy that will be used by the player when provided with a video output Surface.

The strategy only applies if a MediaCodec-based video Renderer is enabled. Applications wishing to use Surface.CHANGE_FRAME_RATE_ALWAYS should set the mode to C.VIDEO_CHANGE_FRAME_RATE_STRATEGY_OFF to disable calls to Surface.setFrameRate(float, int, int) from ExoPlayer, and should then call Surface.setFrameRate(float, int, int) directly from application code.

Parameters:videoChangeFrameRateStrategy - A C.VideoChangeFrameRateStrategy.Returns:This builder.Throws:IllegalStateException - If build() has already been called.

- 

setUseLazyPreparation

@CanIgnoreReturnValue
public[ExoPlayer.Builder](ExoPlayer.Builder.html "class in com.google.android.exoplayer2")setUseLazyPreparation​(boolean useLazyPreparation)

Sets whether media sources should be initialized lazily.

If false, all initial preparation steps (e.g., manifest loads) happen immediately. If true, these initial preparations are triggered only when the player starts buffering the media.

Parameters:useLazyPreparation - Whether to use lazy preparation.Returns:This builder.Throws:IllegalStateException - If build() has already been called.

- 

setSeekParameters

@CanIgnoreReturnValue
public[ExoPlayer.Builder](ExoPlayer.Builder.html "class in com.google.android.exoplayer2")setSeekParameters​([SeekParameters](SeekParameters.html "class in com.google.android.exoplayer2")seekParameters)

Sets the parameters that control how seek operations are performed. Parameters:seekParameters - The SeekParameters.Returns:This builder.Throws:IllegalStateException - If build() has already been called.

- 

setSeekBackIncrementMs

@CanIgnoreReturnValue
public[ExoPlayer.Builder](ExoPlayer.Builder.html "class in com.google.android.exoplayer2")setSeekBackIncrementMs​(@IntRange(from=1L)
                                                long seekBackIncrementMs)

Sets the Player.seekBack() increment. Parameters:seekBackIncrementMs - The seek back increment, in milliseconds.Returns:This builder.Throws:IllegalArgumentException - If seekBackIncrementMs is non-positive.IllegalStateException - If build() has already been called.

- 

setSeekForwardIncrementMs

@CanIgnoreReturnValue
public[ExoPlayer.Builder](ExoPlayer.Builder.html "class in com.google.android.exoplayer2")setSeekForwardIncrementMs​(@IntRange(from=1L)
                                                   long seekForwardIncrementMs)

Sets the Player.seekForward() increment. Parameters:seekForwardIncrementMs - The seek forward increment, in milliseconds.Returns:This builder.Throws:IllegalArgumentException - If seekForwardIncrementMs is non-positive.IllegalStateException - If build() has already been called.

- 

setReleaseTimeoutMs

@CanIgnoreReturnValue
public[ExoPlayer.Builder](ExoPlayer.Builder.html "class in com.google.android.exoplayer2")setReleaseTimeoutMs​(long releaseTimeoutMs)

Sets a timeout for calls to Player.release() and ExoPlayer.setForegroundMode(boolean).

If a call to Player.release() or ExoPlayer.setForegroundMode(boolean) takes more than timeoutMs to complete, the player will report an error via Player.Listener.onPlayerError(com.google.android.exoplayer2.PlaybackException).

Parameters:releaseTimeoutMs - The release timeout, in milliseconds.Returns:This builder.Throws:IllegalStateException - If build() has already been called.

- 

setDetachSurfaceTimeoutMs

@CanIgnoreReturnValue
public[ExoPlayer.Builder](ExoPlayer.Builder.html "class in com.google.android.exoplayer2")setDetachSurfaceTimeoutMs​(long detachSurfaceTimeoutMs)

Sets a timeout for detaching a surface from the player.

If detaching a surface or replacing a surface takes more than detachSurfaceTimeoutMs to complete, the player will report an error via Player.Listener.onPlayerError(com.google.android.exoplayer2.PlaybackException).

Parameters:detachSurfaceTimeoutMs - The timeout for detaching a surface, in milliseconds.Returns:This builder.Throws:IllegalStateException - If build() has already been called.

- 

setPauseAtEndOfMediaItems

@CanIgnoreReturnValue
public[ExoPlayer.Builder](ExoPlayer.Builder.html "class in com.google.android.exoplayer2")setPauseAtEndOfMediaItems​(boolean pauseAtEndOfMediaItems)

Sets whether to pause playback at the end of each media item.

This means the player will pause at the end of each window in the current timeline. Listeners will be informed by a call to Player.Listener.onPlayWhenReadyChanged(boolean, int) with the reason Player.PLAY_WHEN_READY_CHANGE_REASON_END_OF_MEDIA_ITEM when this happens.

Parameters:pauseAtEndOfMediaItems - Whether to pause playback at the end of each media item.Returns:This builder.Throws:IllegalStateException - If build() has already been called.

- 

setLivePlaybackSpeedControl

@CanIgnoreReturnValue
public[ExoPlayer.Builder](ExoPlayer.Builder.html "class in com.google.android.exoplayer2")setLivePlaybackSpeedControl​([LivePlaybackSpeedControl](LivePlaybackSpeedControl.html "interface in com.google.android.exoplayer2")livePlaybackSpeedControl)

Sets the LivePlaybackSpeedControl that will control the playback speed when playing live streams, in order to maintain a steady target offset from the live stream edge. Parameters:livePlaybackSpeedControl - The LivePlaybackSpeedControl.Returns:This builder.Throws:IllegalStateException - If build() has already been called.

- 

setUsePlatformDiagnostics

@CanIgnoreReturnValue
public[ExoPlayer.Builder](ExoPlayer.Builder.html "class in com.google.android.exoplayer2")setUsePlatformDiagnostics​(boolean usePlatformDiagnostics)

Sets whether the player reports diagnostics data to the Android platform.

If enabled, the player will use the MediaMetricsManager to create a PlaybackSession and forward playback events and performance data to this session. This helps to provide system performance and debugging information for media playback on the device. This data may also be collected by Google if sharing usage and diagnostics data is enabled by the user of the device.

Parameters:usePlatformDiagnostics - Whether the player reports diagnostics data to the Android platform.Returns:This builder.Throws:IllegalStateException - If build() has already been called.

- 

setClock

@CanIgnoreReturnValue
public[ExoPlayer.Builder](ExoPlayer.Builder.html "class in com.google.android.exoplayer2")setClock​([Clock](util/Clock.html "interface in com.google.android.exoplayer2.util")clock)

Sets the Clock that will be used by the player. Should only be set for testing purposes. Parameters:clock - A Clock.Returns:This builder.Throws:IllegalStateException - If build() has already been called.

- 

setPlaybackLooper

@CanIgnoreReturnValue
public[ExoPlayer.Builder](ExoPlayer.Builder.html "class in com.google.android.exoplayer2")setPlaybackLooper​([Looper](https://developer.android.com/reference/android/os/Looper.html "class or interface in android.os")playbackLooper)

Sets the Looper that will be used for playback.

The backing thread should run with priority Process.THREAD_PRIORITY_AUDIO and should handle messages within 10ms.

Parameters:playbackLooper - A Looper.Returns:This builder.Throws:IllegalStateException - If build() has already been called.

- 

build

public[ExoPlayer](ExoPlayer.html "interface in com.google.android.exoplayer2")build()

Builds an ExoPlayer instance. Throws:IllegalStateException - If this method has already been called.