The Android Developer Challenge is back! Submit your idea before December 2.

PlaybackParams.Builder

public static final class PlaybackParams.Builder
extends Object

java.lang.Object
   ↳ androidx.media2.player.PlaybackParams.Builder


The builder class that makes it easy to chain setters to create a PlaybackParams object.

Summary

Public constructors

PlaybackParams.Builder()

Default constructor

PlaybackParams.Builder(PlaybackParams playbackParams)

Constructs a new PlaybackParams builder using data from playbackParams.

Public methods

PlaybackParams build()

Takes the values of the Builder object and creates a PlaybackParams object.

PlaybackParams.Builder setAudioFallbackMode(int audioFallbackMode)

Sets the audio fallback mode.

PlaybackParams.Builder setPitch(float pitch)

Sets the pitch factor.

PlaybackParams.Builder setSpeed(float speed)

Sets the speed factor.

Inherited methods

Public constructors

PlaybackParams.Builder

public PlaybackParams.Builder ()

Default constructor

PlaybackParams.Builder

public PlaybackParams.Builder (PlaybackParams playbackParams)

Constructs a new PlaybackParams builder using data from playbackParams.

Parameters
playbackParams PlaybackParams: the non-null instance to initialize from.

Public methods

build

public PlaybackParams build ()

Takes the values of the Builder object and creates a PlaybackParams object.

Returns
PlaybackParams PlaybackParams object with values from the Builder.

setAudioFallbackMode

public PlaybackParams.Builder setAudioFallbackMode (int audioFallbackMode)

Sets the audio fallback mode.

Parameters
audioFallbackMode int

Returns
PlaybackParams.Builder this Builder instance.

setPitch

public PlaybackParams.Builder setPitch (float pitch)

Sets the pitch factor.

Parameters
pitch float

Value is between 0.0 and 3.4028234663852886E38 inclusive.

Returns
PlaybackParams.Builder this Builder instance.

Throws
IllegalArgumentException if the pitch is negative or zero.

setSpeed

public PlaybackParams.Builder setSpeed (float speed)

Sets the speed factor.

Parameters
speed float

Value is between 0.0 and 3.4028234663852886E38 inclusive.

Returns
PlaybackParams.Builder this Builder instance.

Throws
IllegalArgumentException if the speed is negative or zero.