AudioAttributes


public final class AudioAttributes


Attributes for audio playback, which configure the underlying platform android.media.AudioTrack.

To set the audio attributes, create an instance using the Builder and either pass it to the player or send a message of type Renderer#MSG_SET_AUDIO_ATTRIBUTES to the audio renderers.

This class is based on android.media.AudioAttributes, but can be used on all supported API versions.

Summary

Nested types

This class is deprecated.

Use android.media.AudioAttributes.

public final class AudioAttributes.Builder

Builder for AudioAttributes.

Constants

static final AudioAttributes

The default audio attributes, where the content type is AUDIO_CONTENT_TYPE_UNKNOWN, usage is USAGE_MEDIA, capture policy is ALLOW_CAPTURE_BY_ALL and no flags are set.

Public methods

boolean
static AudioAttributes

Restores a AudioAttributes from a Bundle.

static AudioAttributes

Creates a new instance from the provided android.media.AudioAttributes.

AudioAttributes.AudioAttributesV21

This method is deprecated.

Use getPlatformAudioAttributes

AudioAttributes

Returns a android.media.AudioAttributes from this instance.

int

Returns the C.StreamType corresponding to these audio attributes.

int
Bundle

Constants

DEFAULT

public static final AudioAttributes DEFAULT

The default audio attributes, where the content type is AUDIO_CONTENT_TYPE_UNKNOWN, usage is USAGE_MEDIA, capture policy is ALLOW_CAPTURE_BY_ALL and no flags are set.

Public fields

allowedCapturePolicy

@C.AudioAllowedCapturePolicy
public final int allowedCapturePolicy

The C.AudioAllowedCapturePolicy.

contentType

@C.AudioContentType
public final int contentType

The C.AudioContentType.

flags

@C.AudioFlags
public final int flags

The C.AudioFlags.

isContentSpatialized

@UnstableApi
public final boolean isContentSpatialized

Whether the content is spatialized.

platformAudioAttributes

public @Nullable AudioAttributes platformAudioAttributes

spatializationBehavior

@C.SpatializationBehavior
public final int spatializationBehavior

The C.SpatializationBehavior.

usage

@C.AudioUsage
public final int usage

The C.AudioUsage.

Public methods

equals

public boolean equals(@Nullable Object obj)

fromBundle

@UnstableApi
public static AudioAttributes fromBundle(Bundle bundle)

Restores a AudioAttributes from a Bundle.

fromPlatformAudioAttributes

public static AudioAttributes fromPlatformAudioAttributes(AudioAttributes audioAttributes)

Creates a new instance from the provided android.media.AudioAttributes.

getAudioAttributesV21

public AudioAttributes.AudioAttributesV21 getAudioAttributesV21()

getPlatformAudioAttributes

public AudioAttributes getPlatformAudioAttributes()

Returns a android.media.AudioAttributes from this instance.

Some fields are ignored if the corresponding android.media.AudioAttributes.Builder setter is not available on the current API level.

getStreamType

@UnstableApi
@C.StreamType
public int getStreamType()

Returns the C.StreamType corresponding to these audio attributes.

hashCode

public int hashCode()

toBundle

@UnstableApi
public Bundle toBundle()