Google 致力于为黑人社区推动种族平等。查看具体举措

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

Builder()

Default constructor

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

Builder

public Builder ()

Default constructor

Builder

public 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.