ExoPlayer.Builder
class ExoPlayer.Builder
A builder for ExoPlayer instances.
See Builder for the list of default values.
Summary
Constants |
|
|---|---|
const Long |
The default timeout for detaching a surface from the player, in milliseconds. |
const Long |
The default timeout for calls to |
const Int |
The default timeout for detecting whether playback is stuck buffering, in milliseconds. |
const Int |
The default timeout for detecting whether playback is stuck playing, in milliseconds. |
const Int |
The default timeout for detecting whether playback is stuck playing but not ending, in milliseconds. |
const Int |
The default timeout for detecting whether playback is stuck in a suppressed state, in milliseconds. |
Public constructors |
|---|
|
Creates a builder. |
@UnstableApiCreates a builder with a custom |
@UnstableApiCreates a builder with a custom |
@UnstableApiCreates a builder with a custom |
@UnstableApiCreates a builder with the specified custom components. |
Public functions |
|
|---|---|
ExoPlayer! |
build()Builds an |
ExoPlayer.Builder! |
@CanIgnoreReturnValueSets whether ExoPlayer can advance its media processing on a per-stream basis. |
ExoPlayer.Builder! |
@CanIgnoreReturnValueSets whether dynamic scheduling is enabled. |
ExoPlayer.Builder! |
@CanIgnoreReturnValueSets a limit on the time a call to |
ExoPlayer.Builder! |
@CanIgnoreReturnValueSets the |
ExoPlayer.Builder! |
@CanIgnoreReturnValueSets |
ExoPlayer.Builder! |
@CanIgnoreReturnValueSets the |
ExoPlayer.Builder! |
@CanIgnoreReturnValueSets the |
ExoPlayer.Builder! |
Sets the |
ExoPlayer.Builder! |
@CanIgnoreReturnValueSets a timeout for detaching a surface from the player. |
ExoPlayer.Builder! |
@CanIgnoreReturnValueSets whether the player is allowed to set, increase, decrease or mute device volume. |
ExoPlayer.Builder! |
@CanIgnoreReturnValueSets whether to enforce ad playback when the timeline is refreshed by a source update. |
ExoPlayer.Builder! |
@CanIgnoreReturnValueSets whether the player should pause automatically when audio is rerouted from a headset to device speakers. |
ExoPlayer.Builder! |
@CanIgnoreReturnValueSets the |
ExoPlayer.Builder! |
@CanIgnoreReturnValueSets the |
ExoPlayer.Builder! |
@CanIgnoreReturnValueSets the |
ExoPlayer.Builder! |
@CanIgnoreReturnValueSets the maximum position for which |
ExoPlayer.Builder! |
@CanIgnoreReturnValueSets the |
ExoPlayer.Builder! |
@CanIgnoreReturnValueSets the player name that is included in the |
ExoPlayer.Builder! |
@CanIgnoreReturnValueSets whether to pause playback at the end of each media item. |
ExoPlayer.Builder! |
@CanIgnoreReturnValueSets the |
ExoPlayer.Builder! |
@CanIgnoreReturnValueSets the |
ExoPlayer.Builder! |
@CanIgnoreReturnValueSets an |
ExoPlayer.Builder! |
@CanIgnoreReturnValueSets a timeout for calls to |
ExoPlayer.Builder! |
@CanIgnoreReturnValueSets the |
ExoPlayer.Builder! |
@CanIgnoreReturnValueSets the parameters that control the behavior in |
ExoPlayer.Builder! |
@CanIgnoreReturnValueSets the |
ExoPlayer.Builder! |
@CanIgnoreReturnValueSets the |
ExoPlayer.Builder! |
@CanIgnoreReturnValueSets the parameters that control how seek operations are performed. |
ExoPlayer.Builder! |
@CanIgnoreReturnValueSets whether silences silences in the audio stream is enabled. |
ExoPlayer.Builder! |
@CanIgnoreReturnValueSets the timeout after which the player is assumed stuck buffering if it's in |
ExoPlayer.Builder! |
@CanIgnoreReturnValueSets the timeout after which the player is assumed stuck playing if it's in |
ExoPlayer.Builder! |
@CanIgnoreReturnValueSets the timeout after which the player is assumed stuck playing if it's in |
ExoPlayer.Builder! |
@CanIgnoreReturnValueSets the timeout after which the player is assumed stuck in a suppressed state if it has a |
ExoPlayer.Builder! |
@CanIgnoreReturnValueSets whether the player should suppress playback that is attempted on an unsuitable output. |
ExoPlayer.Builder! |
@CanIgnoreReturnValueSets the |
ExoPlayer.Builder! |
@CanIgnoreReturnValueSets whether media sources should be initialized lazily. |
ExoPlayer.Builder! |
@CanIgnoreReturnValueSets whether the player reports diagnostics data to the Android platform. |
ExoPlayer.Builder! |
@CanIgnoreReturnValueSets a |
ExoPlayer.Builder! |
@CanIgnoreReturnValueSets the |
ExoPlayer.Builder! |
@CanIgnoreReturnValueSets the |
Public properties |
|
|---|---|
java-static Boolean |
Static override to allow stuck playing detection. |
Constants
DEFAULT_DETACH_SURFACE_TIMEOUT_MS
@UnstableApi
const val DEFAULT_DETACH_SURFACE_TIMEOUT_MS = 2000: Long
The default timeout for detaching a surface from the player, in milliseconds.
DEFAULT_RELEASE_TIMEOUT_MS
@UnstableApi
const val DEFAULT_RELEASE_TIMEOUT_MS = 500: Long
The default timeout for calls to release and setForegroundMode, in milliseconds.
DEFAULT_STUCK_BUFFERING_DETECTION_TIMEOUT_MS
@UnstableApi
const val DEFAULT_STUCK_BUFFERING_DETECTION_TIMEOUT_MS = 600000: Int
The default timeout for detecting whether playback is stuck buffering, in milliseconds.
DEFAULT_STUCK_PLAYING_DETECTION_TIMEOUT_MS
@UnstableApi
const val DEFAULT_STUCK_PLAYING_DETECTION_TIMEOUT_MS: Int
The default timeout for detecting whether playback is stuck playing, in milliseconds.
DEFAULT_STUCK_PLAYING_NOT_ENDING_TIMEOUT_MS
@UnstableApi
const val DEFAULT_STUCK_PLAYING_NOT_ENDING_TIMEOUT_MS = 60000: Int
The default timeout for detecting whether playback is stuck playing but not ending, in milliseconds.
DEFAULT_STUCK_SUPPRESSED_DETECTION_TIMEOUT_MS
@UnstableApi
const val DEFAULT_STUCK_SUPPRESSED_DETECTION_TIMEOUT_MS = 600000: Int
The default timeout for detecting whether playback is stuck in a suppressed state, in milliseconds.
Public constructors
Builder
Builder(context: Context!)
Creates a builder.
Use Builder, Builder or Builder 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:DefaultRenderersFactoryTrackSelector:DefaultTrackSelectorMediaSource.Factory:DefaultMediaSourceFactoryLoadControl:DefaultLoadControlBandwidthMeter:getSingletonInstanceLivePlaybackSpeedControl:DefaultLivePlaybackSpeedControlLooper: TheLooperassociated with the current thread, or theLooperof the application's main thread if the current thread doesn't have aLooperAnalyticsCollector:AnalyticsCollectorwithDEFAULTAudioOutputProvider: TheAudioOutputProviderconfigured by theRenderersFactory.C.Priority:PRIORITY_PLAYBACKPriorityTaskManager:null(not used)AudioAttributes:DEFAULT, not handling audio focusC.WakeMode:WAKE_MODE_LOCAL, orWAKE_MODE_NONEif any of thestuck...DetectionTimeoutMsvalues are set toMAX_VALUE.handleAudioBecomingNoisy:falsesuppressPlaybackOnUnsuitableOutput:falseskipSilenceEnabled:falseC.VideoScalingMode:VIDEO_SCALING_MODE_DEFAULTC.VideoChangeFrameRateStrategy:VIDEO_CHANGE_FRAME_RATE_STRATEGY_ONLY_IF_SEAMLESSuseLazyPreparation:trueSeekParameters:DEFAULTseekBackIncrementMs:DEFAULT_SEEK_BACK_INCREMENT_MSseekForwardIncrementMs:DEFAULT_SEEK_FORWARD_INCREMENT_MSmaxSeekToPreviousPositionMs:DEFAULT_MAX_SEEK_TO_PREVIOUS_POSITION_MSreleaseTimeoutMs:DEFAULT_RELEASE_TIMEOUT_MSdetachSurfaceTimeoutMs:DEFAULT_DETACH_SURFACE_TIMEOUT_MSstuckBufferingDetectionTimeoutMs:DEFAULT_STUCK_BUFFERING_DETECTION_TIMEOUT_MSstuckPlayingDetectionTimeoutMs:DEFAULT_STUCK_PLAYING_DETECTION_TIMEOUT_MSstuckPlayingNotEndingTimeoutMs:DEFAULT_STUCK_PLAYING_NOT_ENDING_TIMEOUT_MSstuckSuppressedDetectionTimeoutMs:DEFAULT_STUCK_SUPPRESSED_DETECTION_TIMEOUT_MSpauseAtEndOfMediaItems:falseusePlatformDiagnostics:trueClock:DEFAULTplaybackLooper:null(create new thread)dynamicSchedulingEnabled:true
Builder
@UnstableApi
Builder(context: Context!, mediaSourceFactory: MediaSource.Factory!)
Creates a builder with a custom MediaSource.Factory.
See Builder 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: Context! |
A |
mediaSourceFactory: MediaSource.Factory! |
A factory for creating a |
Builder
@UnstableApi
Builder(context: Context!, renderersFactory: RenderersFactory!)
Creates a builder with a custom RenderersFactory.
See Builder 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: Context! |
A |
renderersFactory: RenderersFactory! |
A factory for creating |
Builder
@UnstableApi
Builder(
context: Context!,
renderersFactory: RenderersFactory!,
mediaSourceFactory: MediaSource.Factory!
)
Creates a builder with a custom RenderersFactory and MediaSource.Factory.
See Builder 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: Context! |
A |
renderersFactory: RenderersFactory! |
A factory for creating |
mediaSourceFactory: MediaSource.Factory! |
A factory for creating a |
Builder
@UnstableApi
Builder(
context: Context!,
renderersFactory: RenderersFactory!,
mediaSourceFactory: MediaSource.Factory!,
trackSelector: TrackSelector!,
loadControl: LoadControl!,
bandwidthMeter: BandwidthMeter!,
analyticsCollector: 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: Context! |
A |
renderersFactory: RenderersFactory! |
A factory for creating |
mediaSourceFactory: MediaSource.Factory! |
|
trackSelector: TrackSelector! |
|
loadControl: LoadControl! |
A |
bandwidthMeter: BandwidthMeter! |
|
analyticsCollector: AnalyticsCollector! |
Public functions
build
fun build(): ExoPlayer!
Builds an ExoPlayer instance.
| Throws | |
|---|---|
java.lang.IllegalStateException |
If this method has already been called. |
enablePerStreamMediaProgression
@CanIgnoreReturnValue
@ExperimentalApi
fun enablePerStreamMediaProgression(
perStreamMediaProgressionEnabled: Boolean
): ExoPlayer.Builder!
Sets whether ExoPlayer can advance its media processing on a per-stream basis.
The default is false.
If false then ExoPlayer will not start processing the next item in the playlist until it has finished with the current item. If true then ExoPlayer may enable renderers on subsequent playlist items as each finishes processing media. Enabling this feature can reduce startup latency between media items.
This method is experimental, and will be renamed or removed in a future release.
| Parameters | |
|---|---|
perStreamMediaProgressionEnabled: Boolean |
Whether to enable media progression per stream. |
experimentalSetDynamicSchedulingEnabled
@CanIgnoreReturnValue
@ExperimentalApi
fun experimentalSetDynamicSchedulingEnabled(
dynamicSchedulingEnabled: Boolean
): ExoPlayer.Builder!
Sets whether dynamic scheduling is enabled.
If enabled, ExoPlayer's playback loop will run as rarely as possible by scheduling work for when Renderer progress can be made.
If a custom AudioSink is used then it must correctly implement getAudioTrackBufferSizeUs to enable dynamic scheduling for audio playback.
Enabled by default (value is true).
This method is experimental, and will be renamed or removed in a future release.
| Parameters | |
|---|---|
dynamicSchedulingEnabled: Boolean |
Whether to enable dynamic scheduling. |
experimentalSetForegroundModeTimeoutMs
@CanIgnoreReturnValue
@UnstableApi
@ExperimentalApi
fun experimentalSetForegroundModeTimeoutMs(timeoutMs: Long): ExoPlayer.Builder!
Sets a limit on the time a call to setForegroundMode can spend. If a call to setForegroundMode takes more than timeoutMs milliseconds to complete, the player will raise an error via onPlayerError.
This method is experimental, and will be renamed or removed in a future release.
| Parameters | |
|---|---|
timeoutMs: Long |
The time limit in milliseconds. |
setAnalyticsCollector
@CanIgnoreReturnValue
@UnstableApi
fun setAnalyticsCollector(analyticsCollector: AnalyticsCollector!): ExoPlayer.Builder!
Sets the AnalyticsCollector that will collect and forward all player events.
| Parameters | |
|---|---|
analyticsCollector: AnalyticsCollector! |
| Returns | |
|---|---|
ExoPlayer.Builder! |
This builder. |
| Throws | |
|---|---|
java.lang.IllegalStateException |
If |
setAudioAttributes
@CanIgnoreReturnValue
fun setAudioAttributes(
audioAttributes: AudioAttributes!,
handleAudioFocus: Boolean
): ExoPlayer.Builder!
Sets AudioAttributes that will be used by the player and whether to handle audio focus.
If audio focus should be handled, the usage must be USAGE_MEDIA or USAGE_GAME. Other usages will throw an IllegalArgumentException.
| Parameters | |
|---|---|
audioAttributes: AudioAttributes! |
|
handleAudioFocus: Boolean |
Whether the player should handle audio focus. |
| Returns | |
|---|---|
ExoPlayer.Builder! |
This builder. |
| Throws | |
|---|---|
java.lang.IllegalStateException |
If |
setAudioOutputProvider
@CanIgnoreReturnValue
fun setAudioOutputProvider(audioOutputProvider: AudioOutputProvider!): ExoPlayer.Builder!
Sets the AudioOutputProvider that will be used to play out audio data.
| Parameters | |
|---|---|
audioOutputProvider: AudioOutputProvider! |
| Returns | |
|---|---|
ExoPlayer.Builder! |
This builder. |
| Throws | |
|---|---|
java.lang.IllegalStateException |
If |
setBandwidthMeter
@CanIgnoreReturnValue
@UnstableApi
fun setBandwidthMeter(bandwidthMeter: BandwidthMeter!): ExoPlayer.Builder!
Sets the BandwidthMeter that will be used by the player.
| Parameters | |
|---|---|
bandwidthMeter: BandwidthMeter! |
| Returns | |
|---|---|
ExoPlayer.Builder! |
This builder. |
| Throws | |
|---|---|
java.lang.IllegalStateException |
If |
java.lang.IllegalArgumentException |
If |
setClock
@CanIgnoreReturnValue
@UnstableApi
@VisibleForTesting
fun setClock(clock: Clock!): ExoPlayer.Builder!
Sets the Clock that will be used by the player. Should only be set for testing purposes.
| Returns | |
|---|---|
ExoPlayer.Builder! |
This builder. |
| Throws | |
|---|---|
java.lang.IllegalStateException |
If |
setDetachSurfaceTimeoutMs
@CanIgnoreReturnValue
@UnstableApi
fun setDetachSurfaceTimeoutMs(detachSurfaceTimeoutMs: Long): ExoPlayer.Builder!
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 onPlayerError.
| Parameters | |
|---|---|
detachSurfaceTimeoutMs: Long |
The timeout for detaching a surface, in milliseconds. |
| Returns | |
|---|---|
ExoPlayer.Builder! |
This builder. |
| Throws | |
|---|---|
java.lang.IllegalStateException |
If |
setDeviceVolumeControlEnabled
@CanIgnoreReturnValue
@UnstableApi
fun setDeviceVolumeControlEnabled(deviceVolumeControlEnabled: Boolean): ExoPlayer.Builder!
Sets whether the player is allowed to set, increase, decrease or mute device volume.
| Parameters | |
|---|---|
deviceVolumeControlEnabled: Boolean |
Whether controlling device volume is enabled. |
| Returns | |
|---|---|
ExoPlayer.Builder! |
This builder. |
| Throws | |
|---|---|
java.lang.IllegalStateException |
If |
setEnforceAdPlaybackOnTimelineRefresh
@CanIgnoreReturnValue
@UnstableApi
fun setEnforceAdPlaybackOnTimelineRefresh(
enforceAdPlaybackOnTimelineRefresh: Boolean
): ExoPlayer.Builder!
Sets whether to enforce ad playback when the timeline is refreshed by a source update.
If true, then an ad group resolved at or before the current playback position during a timeline refresh will be played. If false, then the resolved ad group will not play.
The default is true.
| Parameters | |
|---|---|
enforceAdPlaybackOnTimelineRefresh: Boolean |
Whether to enforce ad playback on timeline refresh. |
| Returns | |
|---|---|
ExoPlayer.Builder! |
This builder. |
| Throws | |
|---|---|
java.lang.IllegalStateException |
If |
setHandleAudioBecomingNoisy
@CanIgnoreReturnValue
fun setHandleAudioBecomingNoisy(handleAudioBecomingNoisy: Boolean): ExoPlayer.Builder!
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: Boolean |
Whether the player should pause automatically when audio is rerouted from a headset to device speakers. |
| Returns | |
|---|---|
ExoPlayer.Builder! |
This builder. |
| Throws | |
|---|---|
java.lang.IllegalStateException |
If |
setLivePlaybackSpeedControl
@CanIgnoreReturnValue
@UnstableApi
fun setLivePlaybackSpeedControl(
livePlaybackSpeedControl: LivePlaybackSpeedControl!
): ExoPlayer.Builder!
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: LivePlaybackSpeedControl! |
| Returns | |
|---|---|
ExoPlayer.Builder! |
This builder. |
| Throws | |
|---|---|
java.lang.IllegalStateException |
If |
setLoadControl
@CanIgnoreReturnValue
@UnstableApi
fun setLoadControl(loadControl: LoadControl!): ExoPlayer.Builder!
Sets the LoadControl that will be used by the player.
| Parameters | |
|---|---|
loadControl: LoadControl! |
A |
| Returns | |
|---|---|
ExoPlayer.Builder! |
This builder. |
| Throws | |
|---|---|
java.lang.IllegalStateException |
If |
setLooper
@CanIgnoreReturnValue
@UnstableApi
fun setLooper(looper: Looper!): ExoPlayer.Builder!
Sets the Looper that must be used for all calls to the player and that is used to call listeners on.
| Returns | |
|---|---|
ExoPlayer.Builder! |
This builder. |
| Throws | |
|---|---|
java.lang.IllegalStateException |
If |
setMaxSeekToPreviousPositionMs
@CanIgnoreReturnValue
@UnstableApi
fun setMaxSeekToPreviousPositionMs(
maxSeekToPreviousPositionMs: @IntRange(from = 0) Long
): ExoPlayer.Builder!
Sets the maximum position for which seekToPrevious seeks to the previous MediaItem.
| Parameters | |
|---|---|
maxSeekToPreviousPositionMs: @IntRange(from = 0) Long |
The maximum position, in milliseconds. |
| Returns | |
|---|---|
ExoPlayer.Builder! |
This builder. |
| Throws | |
|---|---|
java.lang.IllegalArgumentException |
If |
java.lang.IllegalStateException |
If |
setMediaSourceFactory
@CanIgnoreReturnValue
fun setMediaSourceFactory(mediaSourceFactory: MediaSource.Factory!): ExoPlayer.Builder!
Sets the MediaSource.Factory that will be used by the player.
| Parameters | |
|---|---|
mediaSourceFactory: MediaSource.Factory! |
| Returns | |
|---|---|
ExoPlayer.Builder! |
This builder. |
| Throws | |
|---|---|
java.lang.IllegalStateException |
If |
setName
@CanIgnoreReturnValue
@UnstableApi
fun setName(playerName: String!): ExoPlayer.Builder!
Sets the player name that is included in the PlayerId to recognize the player by its PlayerId.
This must not be equal to the name of PRELOAD ("preload").
The default is an empty string.
| Returns | |
|---|---|
ExoPlayer.Builder! |
This builder. |
| Throws | |
|---|---|
java.lang.IllegalStateException |
If |
java.lang.IllegalArgumentException |
If the passed |
setPauseAtEndOfMediaItems
@CanIgnoreReturnValue
@UnstableApi
fun setPauseAtEndOfMediaItems(pauseAtEndOfMediaItems: Boolean): ExoPlayer.Builder!
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 onPlayWhenReadyChanged with the reason PLAY_WHEN_READY_CHANGE_REASON_END_OF_MEDIA_ITEM when this happens.
| Parameters | |
|---|---|
pauseAtEndOfMediaItems: Boolean |
Whether to pause playback at the end of each media item. |
| Returns | |
|---|---|
ExoPlayer.Builder! |
This builder. |
| Throws | |
|---|---|
java.lang.IllegalStateException |
If |
setPlaybackLooper
@CanIgnoreReturnValue
@UnstableApi
fun setPlaybackLooper(playbackLooper: Looper!): ExoPlayer.Builder!
Sets the Looper that will be used for playback.
The backing thread should run with priority THREAD_PRIORITY_AUDIO and should handle messages within 10ms.
| Returns | |
|---|---|
ExoPlayer.Builder! |
This builder. |
| Throws | |
|---|---|
java.lang.IllegalStateException |
If |
setPriority
@CanIgnoreReturnValue
@UnstableApi
fun setPriority(@C.Priority priority: Int): ExoPlayer.Builder!
Sets the C.Priority for this player.
The priority may influence resource allocation between multiple players or other components running in the same app.
This priority is used for the PriorityTaskManager, if set.
| Parameters | |
|---|---|
@C.Priority priority: Int |
The |
setPriorityTaskManager
@CanIgnoreReturnValue
@UnstableApi
fun setPriorityTaskManager(priorityTaskManager: PriorityTaskManager?): ExoPlayer.Builder!
Sets an PriorityTaskManager that will be used by the player.
The priority set via setPriority (or by default) will be set while the player is loading.
| Parameters | |
|---|---|
priorityTaskManager: PriorityTaskManager? |
A |
| Returns | |
|---|---|
ExoPlayer.Builder! |
This builder. |
| Throws | |
|---|---|
java.lang.IllegalStateException |
If |
setReleaseTimeoutMs
@CanIgnoreReturnValue
@UnstableApi
fun setReleaseTimeoutMs(releaseTimeoutMs: Long): ExoPlayer.Builder!
Sets a timeout for calls to release and setForegroundMode.
If a call to release or setForegroundMode takes more than
timeoutMs to complete, the player will report an error via onPlayerError.
| Parameters | |
|---|---|
releaseTimeoutMs: Long |
The release timeout, in milliseconds. |
| Returns | |
|---|---|
ExoPlayer.Builder! |
This builder. |
| Throws | |
|---|---|
java.lang.IllegalStateException |
If |
setRenderersFactory
@CanIgnoreReturnValue
@UnstableApi
fun setRenderersFactory(renderersFactory: RenderersFactory!): ExoPlayer.Builder!
Sets the RenderersFactory that will be used by the player.
| Parameters | |
|---|---|
renderersFactory: RenderersFactory! |
| Returns | |
|---|---|
ExoPlayer.Builder! |
This builder. |
| Throws | |
|---|---|
java.lang.IllegalStateException |
If |
setScrubbingModeParameters
@CanIgnoreReturnValue
@UnstableApi
fun setScrubbingModeParameters(
scrubbingModeParameters: ScrubbingModeParameters!
): ExoPlayer.Builder!
Sets the parameters that control the behavior in scrubbing mode.
| Parameters | |
|---|---|
scrubbingModeParameters: ScrubbingModeParameters! |
| Returns | |
|---|---|
ExoPlayer.Builder! |
This builder. |
| Throws | |
|---|---|
java.lang.IllegalStateException |
If |
setSeekBackIncrementMs
@CanIgnoreReturnValue
fun setSeekBackIncrementMs(seekBackIncrementMs: @IntRange(from = 1) Long): ExoPlayer.Builder!
Sets the seekBack increment.
| Returns | |
|---|---|
ExoPlayer.Builder! |
This builder. |
| Throws | |
|---|---|
java.lang.IllegalArgumentException |
If |
java.lang.IllegalStateException |
If |
setSeekForwardIncrementMs
@CanIgnoreReturnValue
fun setSeekForwardIncrementMs(seekForwardIncrementMs: @IntRange(from = 1) Long): ExoPlayer.Builder!
Sets the seekForward increment.
| Parameters | |
|---|---|
seekForwardIncrementMs: @IntRange(from = 1) Long |
The seek forward increment, in milliseconds. |
| Returns | |
|---|---|
ExoPlayer.Builder! |
This builder. |
| Throws | |
|---|---|
java.lang.IllegalArgumentException |
If |
java.lang.IllegalStateException |
If |
setSeekParameters
@CanIgnoreReturnValue
@UnstableApi
fun setSeekParameters(seekParameters: SeekParameters!): ExoPlayer.Builder!
Sets the parameters that control how seek operations are performed.
| Parameters | |
|---|---|
seekParameters: SeekParameters! |
The |
| Returns | |
|---|---|
ExoPlayer.Builder! |
This builder. |
| Throws | |
|---|---|
java.lang.IllegalStateException |
If |
setSkipSilenceEnabled
@CanIgnoreReturnValue
@UnstableApi
fun setSkipSilenceEnabled(skipSilenceEnabled: Boolean): ExoPlayer.Builder!
Sets whether silences silences in the audio stream is enabled.
| Parameters | |
|---|---|
skipSilenceEnabled: Boolean |
Whether skipping silences is enabled. |
| Returns | |
|---|---|
ExoPlayer.Builder! |
This builder. |
| Throws | |
|---|---|
java.lang.IllegalStateException |
If |
setStuckBufferingDetectionTimeoutMs
@CanIgnoreReturnValue
@UnstableApi
fun setStuckBufferingDetectionTimeoutMs(
stuckBufferingDetectionTimeoutMs: Int
): ExoPlayer.Builder!
Sets the timeout after which the player is assumed stuck buffering if it's in STATE_BUFFERING and no loading progress is made, in milliseconds.
If this timeout is triggered, the player will transition to an error state with a StuckPlayerException using STUCK_BUFFERING_NO_PROGRESS.
| Parameters | |
|---|---|
stuckBufferingDetectionTimeoutMs: Int |
The timeout after which the player is assumed stuck buffering, in milliseconds. |
| Returns | |
|---|---|
ExoPlayer.Builder! |
This builder. |
| Throws | |
|---|---|
java.lang.IllegalStateException |
If |
setStuckPlayingDetectionTimeoutMs
@CanIgnoreReturnValue
@UnstableApi
fun setStuckPlayingDetectionTimeoutMs(stuckPlayingDetectionTimeoutMs: Int): ExoPlayer.Builder!
Sets the timeout after which the player is assumed stuck playing if it's in STATE_READY and no playback progress is made, in milliseconds.
If this timeout is triggered, the player will transition to an error state with a StuckPlayerException using STUCK_PLAYING_NO_PROGRESS.
| Parameters | |
|---|---|
stuckPlayingDetectionTimeoutMs: Int |
The timeout after which the player is assumed stuck playing, in milliseconds. |
| Returns | |
|---|---|
ExoPlayer.Builder! |
This builder. |
| Throws | |
|---|---|
java.lang.IllegalStateException |
If |
setStuckPlayingNotEndingTimeoutMs
@CanIgnoreReturnValue
@UnstableApi
fun setStuckPlayingNotEndingTimeoutMs(stuckPlayingNotEndingTimeoutMs: Int): ExoPlayer.Builder!
Sets the timeout after which the player is assumed stuck playing if it's in STATE_READY and the playback is not ending despite exceeding the declared duration, in milliseconds.
If this timeout is triggered, the player will transition to an error state with a StuckPlayerException using STUCK_PLAYING_NOT_ENDING.
| Parameters | |
|---|---|
stuckPlayingNotEndingTimeoutMs: Int |
The timeout after which the player is assumed stuck playing and not ending, in milliseconds. |
| Returns | |
|---|---|
ExoPlayer.Builder! |
This builder. |
| Throws | |
|---|---|
java.lang.IllegalStateException |
If |
setStuckSuppressedDetectionTimeoutMs
@CanIgnoreReturnValue
@UnstableApi
fun setStuckSuppressedDetectionTimeoutMs(
stuckSuppressedDetectionTimeoutMs: Int
): ExoPlayer.Builder!
Sets the timeout after which the player is assumed stuck in a suppressed state if it has a getPlaybackSuppressionReason other than PLAYBACK_SUPPRESSION_REASON_NONE or PLAYBACK_SUPPRESSION_REASON_TRANSIENT_AUDIO_FOCUS_LOSS, in milliseconds.
If this timeout is triggered, the player will transition to an error state with a StuckPlayerException using STUCK_SUPPRESSED.
| Parameters | |
|---|---|
stuckSuppressedDetectionTimeoutMs: Int |
The timeout after which the player is assumed stuck in a suppressed state, in milliseconds. |
| Returns | |
|---|---|
ExoPlayer.Builder! |
This builder. |
| Throws | |
|---|---|
java.lang.IllegalStateException |
If |
setSuppressPlaybackOnUnsuitableOutput
@CanIgnoreReturnValue
@UnstableApi
fun setSuppressPlaybackOnUnsuitableOutput(
suppressPlaybackOnUnsuitableOutput: Boolean
): ExoPlayer.Builder!
Sets whether the player should suppress playback that is attempted on an unsuitable output. An example of an unsuitable audio output is the built-in speaker on a Wear OS device (unless it is explicitly selected by the user).
If called with suppressPlaybackOnUnsuitableOutput = true, then a playback attempt on an unsuitable audio output will result in calls to onPlaybackSuppressionReasonChanged with the value PLAYBACK_SUPPRESSION_REASON_UNSUITABLE_AUDIO_OUTPUT.
Callers of this may also want to enable setHandleAudioBecomingNoisy to prevent playback from continuing on the built-in speaker when a headset is disconnected.
| Parameters | |
|---|---|
suppressPlaybackOnUnsuitableOutput: Boolean |
Whether the player should suppress the playback when it is attempted on an unsuitable output. |
| Returns | |
|---|---|
ExoPlayer.Builder! |
This builder. |
| Throws | |
|---|---|
java.lang.IllegalStateException |
If |
setTrackSelector
@CanIgnoreReturnValue
@UnstableApi
fun setTrackSelector(trackSelector: TrackSelector!): ExoPlayer.Builder!
Sets the TrackSelector that will be used by the player.
| Parameters | |
|---|---|
trackSelector: TrackSelector! |
| Returns | |
|---|---|
ExoPlayer.Builder! |
This builder. |
| Throws | |
|---|---|
java.lang.IllegalStateException |
If |
setUseLazyPreparation
@CanIgnoreReturnValue
@UnstableApi
fun setUseLazyPreparation(useLazyPreparation: Boolean): ExoPlayer.Builder!
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: Boolean |
Whether to use lazy preparation. |
| Returns | |
|---|---|
ExoPlayer.Builder! |
This builder. |
| Throws | |
|---|---|
java.lang.IllegalStateException |
If |
setUsePlatformDiagnostics
@CanIgnoreReturnValue
@UnstableApi
fun setUsePlatformDiagnostics(usePlatformDiagnostics: Boolean): ExoPlayer.Builder!
Sets whether the player reports diagnostics data to the Android platform.
If enabled, the player will use the android.media.metrics.MediaMetricsManager to create a android.media.metrics.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: Boolean |
Whether the player reports diagnostics data to the Android platform. |
| Returns | |
|---|---|
ExoPlayer.Builder! |
This builder. |
| Throws | |
|---|---|
java.lang.IllegalStateException |
If |
setVideoChangeFrameRateStrategy
@CanIgnoreReturnValue
@UnstableApi
fun setVideoChangeFrameRateStrategy(
@C.VideoChangeFrameRateStrategy videoChangeFrameRateStrategy: Int
): ExoPlayer.Builder!
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 CHANGE_FRAME_RATE_ALWAYS should set the mode to VIDEO_CHANGE_FRAME_RATE_STRATEGY_OFF to disable calls to setFrameRate from ExoPlayer, and should then call setFrameRate directly from application code.
| Parameters | |
|---|---|
@C.VideoChangeFrameRateStrategy videoChangeFrameRateStrategy: Int |
| Returns | |
|---|---|
ExoPlayer.Builder! |
This builder. |
| Throws | |
|---|---|
java.lang.IllegalStateException |
If |
setVideoScalingMode
@CanIgnoreReturnValue
@UnstableApi
fun setVideoScalingMode(@C.VideoScalingMode videoScalingMode: Int): ExoPlayer.Builder!
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 | |
|---|---|
@C.VideoScalingMode videoScalingMode: Int |
| Returns | |
|---|---|
ExoPlayer.Builder! |
This builder. |
| Throws | |
|---|---|
java.lang.IllegalStateException |
If |
setWakeMode
@CanIgnoreReturnValue
fun setWakeMode(@C.WakeMode wakeMode: Int): ExoPlayer.Builder!
Sets the C.WakeMode that will be used by the player.
WAKE_MODE_LOCAL should be used together with a foreground android.app.Service for use cases where playback occurs and the screen is off (e.g. background audio playback).
WAKE_MODE_NETWORK is only required for uses cases requiring low-latency Wifi access during screen on playback, or to work around some Wifi stability issues on older devices while the screen is off.
When enabled, the locks (android.os.PowerManager.WakeLock / android.net.wifi.WifiManager.WifiLock) will be held whenever the player is in the STATE_READY or STATE_BUFFERING states with playWhenReady = true. The locks held depend on the specified C.WakeMode.
| Parameters | |
|---|---|
@C.WakeMode wakeMode: Int |
A |
| Returns | |
|---|---|
ExoPlayer.Builder! |
This builder. |
| Throws | |
|---|---|
java.lang.IllegalStateException |
If |
Public properties
experimentalEnableStuckPlayingDetection
@ExperimentalApi
java-static val experimentalEnableStuckPlayingDetection: Boolean
Static override to allow stuck playing detection. If false, the provided timeouts default to MAX_VALUE instead of DEFAULT_STUCK_PLAYING_DETECTION_TIMEOUT_MS and DEFAULT_STUCK_PLAYING_NOT_ENDING_TIMEOUT_MS.
This value is experimental and will be removed in a future release.