Back to Exoplayer

DefaultAudioSink.Builder (ExoPlayer library)

docs/doc/reference/com/google/android/exoplayer2/audio/DefaultAudioSink.Builder.html

latest10.8 KB
Original Source

Package com.google.android.exoplayer2.audio

Class DefaultAudioSink.Builder


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

A builder to create DefaultAudioSink instances.

Constructor Summary

Constructors | Constructor | Description | | --- | --- | | Builder() | Deprecated. Use Builder(Context) instead.

| | Builder​(Context context) | Creates a new builder. |

Method Summary

All Methods Instance Methods Concrete Methods Deprecated Methods | Modifier and Type | Method | Description | | --- | --- | --- | | DefaultAudioSink | build() | Builds the DefaultAudioSink. | | DefaultAudioSink.Builder | setAudioCapabilities​(AudioCapabilities audioCapabilities) | Deprecated. These audio capabilities are only used in the absence of a context.

| | DefaultAudioSink.Builder | setAudioProcessorChain​(AudioProcessorChain audioProcessorChain) | Sets the AudioProcessorChain to process audio before playback. | | DefaultAudioSink.Builder | setAudioProcessors​(AudioProcessor[] audioProcessors) | Sets an array of AudioProcessorss that will process PCM audio before output. | | DefaultAudioSink.Builder | setAudioTrackBufferSizeProvider​(DefaultAudioSink.AudioTrackBufferSizeProvider audioTrackBufferSizeProvider) | Sets an DefaultAudioSink.AudioTrackBufferSizeProvider to compute the buffer size when DefaultAudioSink.configure(com.google.android.exoplayer2.Format, int, int[]) is called with specifiedBufferSize == 0. | | DefaultAudioSink.Builder | setEnableAudioTrackPlaybackParams​(boolean enableAudioTrackPlaybackParams) | Sets whether to control the playback speed using the platform implementation (see AudioTrack.setPlaybackParams(PlaybackParams)), if supported. | | DefaultAudioSink.Builder | setEnableFloatOutput​(boolean enableFloatOutput) | Sets whether to enable 32-bit float output or integer output. | | DefaultAudioSink.Builder | setExperimentalAudioOffloadListener​(ExoPlayer.AudioOffloadListener audioOffloadListener) | Sets an optional ExoPlayer.AudioOffloadListener to receive events relevant to offloaded playback. | | DefaultAudioSink.Builder | setOffloadMode​(@com.google.android.exoplayer2.audio.DefaultAudioSink.OffloadMode int offloadMode) | Sets the offload mode. |

- 

Methods inherited from class java.lang.Object

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

Constructor Detail

- 

Builder

[@Deprecated](https://developer.android.com/reference/java/lang/Deprecated.html "class or interface in java.lang")public Builder()

Deprecated. Use Builder(Context) instead.

- 

Builder

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

Creates a new builder. Parameters:context - The Context.

Method Detail

- 

setAudioCapabilities

[@Deprecated](https://developer.android.com/reference/java/lang/Deprecated.html "class or interface in java.lang")@CanIgnoreReturnValue
public[DefaultAudioSink.Builder](DefaultAudioSink.Builder.html "class in com.google.android.exoplayer2.audio")setAudioCapabilities​([AudioCapabilities](AudioCapabilities.html "class in com.google.android.exoplayer2.audio")audioCapabilities)

Deprecated. These audio capabilities are only used in the absence of a context. In the case when the Context is null and the audioCapabilities is not set to the Builder, the default capabilities (no encoded audio passthrough support) should be assumed.

- 

setAudioProcessors

@CanIgnoreReturnValue
public[DefaultAudioSink.Builder](DefaultAudioSink.Builder.html "class in com.google.android.exoplayer2.audio")setAudioProcessors​([AudioProcessor](AudioProcessor.html "interface in com.google.android.exoplayer2.audio")[] audioProcessors)

Sets an array of AudioProcessorss that will process PCM audio before output. May be empty. Equivalent of setAudioProcessorChain(new DefaultAudioProcessorChain(audioProcessors).

The default value is an empty array.

- 

setAudioProcessorChain

@CanIgnoreReturnValue
public[DefaultAudioSink.Builder](DefaultAudioSink.Builder.html "class in com.google.android.exoplayer2.audio")setAudioProcessorChain​([AudioProcessorChain](AudioProcessorChain.html "interface in com.google.android.exoplayer2.audio")audioProcessorChain)

Sets the AudioProcessorChain to process audio before playback. The instance passed in must not be reused in other sinks. Processing chains are only supported for PCM playback (not passthrough or offload).

By default, no processing will be applied.

- 

setEnableFloatOutput

@CanIgnoreReturnValue
public[DefaultAudioSink.Builder](DefaultAudioSink.Builder.html "class in com.google.android.exoplayer2.audio")setEnableFloatOutput​(boolean enableFloatOutput)

Sets whether to enable 32-bit float output or integer output. Where possible, 32-bit float output will be used if the input is 32-bit float, and also if the input is high resolution (24-bit or 32-bit) integer PCM. Float output is supported from API level 21. Audio processing (for example, speed adjustment) will not be available when float output is in use.

The default value is false.

- 

setEnableAudioTrackPlaybackParams

@CanIgnoreReturnValue
public[DefaultAudioSink.Builder](DefaultAudioSink.Builder.html "class in com.google.android.exoplayer2.audio")setEnableAudioTrackPlaybackParams​(boolean enableAudioTrackPlaybackParams)

Sets whether to control the playback speed using the platform implementation (see AudioTrack.setPlaybackParams(PlaybackParams)), if supported. If set to false, speed up/down of the audio will be done by ExoPlayer (see SonicAudioProcessor). Platform speed adjustment is lower latency, but less reliable.

The default value is false.

- 

setOffloadMode

@CanIgnoreReturnValue
public[DefaultAudioSink.Builder](DefaultAudioSink.Builder.html "class in com.google.android.exoplayer2.audio")setOffloadMode​(@com.google.android.exoplayer2.audio.DefaultAudioSink.OffloadMode int offloadMode)

Sets the offload mode. If an audio format can be both played with offload and encoded audio passthrough, it will be played in offload. Audio offload is supported from API level 29. Most Android devices can only support one offload AudioTrack at a time and can invalidate it at any time. Thus an app can never be guaranteed that it will be able to play in offload. Audio processing (for example, speed adjustment) will not be available when offload is in use.

The default value is DefaultAudioSink.OFFLOAD_MODE_DISABLED.

- 

setAudioTrackBufferSizeProvider

@CanIgnoreReturnValue
public[DefaultAudioSink.Builder](DefaultAudioSink.Builder.html "class in com.google.android.exoplayer2.audio")setAudioTrackBufferSizeProvider​([DefaultAudioSink.AudioTrackBufferSizeProvider](DefaultAudioSink.AudioTrackBufferSizeProvider.html "interface in com.google.android.exoplayer2.audio")audioTrackBufferSizeProvider)

Sets an DefaultAudioSink.AudioTrackBufferSizeProvider to compute the buffer size when DefaultAudioSink.configure(com.google.android.exoplayer2.Format, int, int[]) is called with specifiedBufferSize == 0.

The default value is DefaultAudioSink.AudioTrackBufferSizeProvider.DEFAULT.

- 

setExperimentalAudioOffloadListener

@CanIgnoreReturnValue
public[DefaultAudioSink.Builder](DefaultAudioSink.Builder.html "class in com.google.android.exoplayer2.audio")setExperimentalAudioOffloadListener​(@Nullable[ExoPlayer.AudioOffloadListener](../ExoPlayer.AudioOffloadListener.html "interface in com.google.android.exoplayer2")audioOffloadListener)

Sets an optional ExoPlayer.AudioOffloadListener to receive events relevant to offloaded playback.

The default value is null.

- 

build

public[DefaultAudioSink](DefaultAudioSink.html "class in com.google.android.exoplayer2.audio")build()

Builds the DefaultAudioSink. Must only be called once per Builder instance.