Android Dev Summit, October 23-24: two days of technical content, directly from the Android team. Sign-up for livestream updates.

Builder

class Builder
kotlin.Any
   ↳ androidx.media2.player.PlaybackParams.Builder

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

Summary

Public constructors

Default constructor

<init>(@NonNull playbackParams: PlaybackParams)

Constructs a new PlaybackParams builder using data from playbackParams.

Public methods

PlaybackParams

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

PlaybackParams.Builder
setAudioFallbackMode(audioFallbackMode: Int)

Sets the audio fallback mode.

PlaybackParams.Builder
setPitch(pitch: Float)

Sets the pitch factor.

PlaybackParams.Builder
setSpeed(speed: Float)

Sets the speed factor.

Public constructors

<init>

Builder()

Default constructor

<init>

Builder(@NonNull playbackParams: PlaybackParams)

Constructs a new PlaybackParams builder using data from playbackParams.

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

Public methods

build

@NonNull fun build(): PlaybackParams

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

Return
PlaybackParams: PlaybackParams object with values from the Builder.

setAudioFallbackMode

@NonNull fun setAudioFallbackMode(audioFallbackMode: Int): PlaybackParams.Builder

Sets the audio fallback mode.

Return
PlaybackParams.Builder: this Builder instance.

setPitch

@NonNull fun setPitch(pitch: Float): PlaybackParams.Builder

Sets the pitch factor.

Return
PlaybackParams.Builder: this Builder instance.
Exceptions
IllegalArgumentException if the pitch is negative or zero.

setSpeed

@NonNull fun setSpeed(speed: Float): PlaybackParams.Builder

Sets the speed factor.

Return
PlaybackParams.Builder: this Builder instance.
Exceptions
IllegalArgumentException if the speed is negative or zero.