Builder
open class Builder
kotlin.Any | |
↳ | androidx.media.AudioAttributesCompat.Builder |
Builder class for AudioAttributesCompat
objects.
example:
new AudioAttributes.Builder()
.setUsage(AudioAttributes.USAGE_MEDIA)
.setContentType(AudioAttributes.CONTENT_TYPE_MUSIC)
.build();
By default all types of information (usage, content type, flags) conveyed by an AudioAttributesCompat
instance are set to "unknown". Unknown information will be interpreted as a default value that is dependent on the context of use, for instance a will use a default usage of AudioAttributesCompat#USAGE_MEDIA
. See also AudioAttributes.Builder
.
Summary
Public constructors |
|
---|---|
<init>() Constructs a new Builder with the defaults. |
|
<init>(aa: AudioAttributesCompat!) Constructs a new Builder from a given AudioAttributes |
Public methods |
|
---|---|
open AudioAttributesCompat! |
build() Combines all of the attributes that have been set and return a new object. |
open AudioAttributesCompat.Builder! |
setContentType(contentType: Int) Sets the attribute describing the content type of the audio signal, such as speech, or music. |
open AudioAttributesCompat.Builder! |
Sets the combination of flags. |
open AudioAttributesCompat.Builder! |
setLegacyStreamType(streamType: Int) Create an |
open AudioAttributesCompat.Builder! |
Sets the attribute describing what is the intended use of the the audio signal, such as alarm or ringtone. |
Public constructors
<init>
Builder()
Constructs a new Builder with the defaults. By default, usage and content type are respectively AudioAttributesCompat#USAGE_UNKNOWN
and
, and flags are 0. It is recommended to configure the usage (with setUsage(int)
) or deriving attributes from a legacy stream type (with setLegacyStreamType(int)
) before calling build()
to override any default playback behavior in terms of routing and volume management.
<init>
Builder(aa: AudioAttributesCompat!)
Constructs a new Builder from a given AudioAttributes
Parameters | |
---|---|
aa |
AudioAttributesCompat!: the AudioAttributesCompat object whose data will be reused in the new Builder. |
Public methods
build
open fun build(): AudioAttributesCompat!
Combines all of the attributes that have been set and return a new object.
Return | |
---|---|
AudioAttributesCompat!: a new AudioAttributesCompat object |
setContentType
open fun setContentType(contentType: Int): AudioAttributesCompat.Builder!
Sets the attribute describing the content type of the audio signal, such as speech, or music.
Parameters | |
---|---|
contentType |
Int: the content type values, one of , , , , . |
Return | |
---|---|
AudioAttributesCompat.Builder!: the same Builder instance. |
setFlags
open fun setFlags(flags: Int): AudioAttributesCompat.Builder!
Sets the combination of flags.
This is a bitwise OR with the existing flags.
Parameters | |
---|---|
flags |
Int: a combination of AudioAttributesCompat#FLAG_AUDIBILITY_ENFORCED , AudioAttributesCompat#FLAG_HW_AV_SYNC . |
Return | |
---|---|
AudioAttributesCompat.Builder!: the same Builder instance. |
setLegacyStreamType
open fun setLegacyStreamType(streamType: Int): AudioAttributesCompat.Builder!
Create an AudioAttributesCompat
that best approximates the specified stream type constant.
Parameters | |
---|---|
streamType |
Int: one of AudioManager.STREAM_* |
Return | |
---|---|
AudioAttributesCompat.Builder!: this same Builder |
setUsage
open fun setUsage(usage: Int): AudioAttributesCompat.Builder!
Sets the attribute describing what is the intended use of the the audio signal, such as alarm or ringtone.
Parameters | |
---|---|
usage |
Int: one of AudioAttributesCompat#USAGE_UNKNOWN , , , , , AudioAttributesCompat#USAGE_NOTIFICATION , AudioAttributesCompat#USAGE_NOTIFICATION_RINGTONE , , , , , , , , , . |
Return | |
---|---|
AudioAttributesCompat.Builder!: the same Builder instance. |