java.lang.Object | |
↳ | com.h6ah4i.android.media.compat.AudioAttributes.Builder |
Builder class for AudioAttributes
objects.
Here is an example where Builder
is used to define the
AudioAttributes
to be used by a new AudioTrack
instance:
AudioTrack myTrack = new AudioTrack( new AudioAttributes.Builder() .setUsage(AudioAttributes.USAGE_MEDIA) .setContentType(AudioAttributes.CONTENT_TYPE_MUSIC) .build(), myFormat, myBuffSize, AudioTrack.MODE_STREAM, mySession);
By default all types of information (usage, content type, flags) conveyed
by an AudioAttributes
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 MediaPlayer will use a default
usage of USAGE_MEDIA
.
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Builder()
Constructs a new Builder with the defaults.
| |||||||||||
Builder(AudioAttributes aa)
Constructs a new Builder from a given AudioAttributes
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
AudioAttributes |
build()
Combines all of the attributes that have been set and return a new
AudioAttributes object. | ||||||||||
AudioAttributes.Builder |
setContentType(int contentType)
Sets the attribute describing the content type of the audio signal,
such as speech, or music.
| ||||||||||
AudioAttributes.Builder |
setFlags(int flags)
Sets the combination of flags.
| ||||||||||
AudioAttributes.Builder |
setLegacyStreamType(int streamType)
Sets attributes as inferred from the legacy stream types.
| ||||||||||
AudioAttributes.Builder |
setUsage(int usage)
Sets the attribute describing what is the intended use of the the
audio signal, such as alarm or ringtone.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
|
Constructs a new Builder with the defaults. By default, usage and
content type are respectively USAGE_UNKNOWN
and CONTENT_TYPE_UNKNOWN
, 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.
Constructs a new Builder from a given AudioAttributes
aa | the AudioAttributes object whose data will be reused in the new Builder. |
---|
Combines all of the attributes that have been set and return a new
AudioAttributes
object.
AudioAttributes
object
Sets the attribute describing the content type of the audio signal, such as speech, or music.
contentType | the content type values, one of
CONTENT_TYPE_MOVIE ,
CONTENT_TYPE_MUSIC ,
CONTENT_TYPE_SONIFICATION ,
CONTENT_TYPE_SPEECH ,
CONTENT_TYPE_UNKNOWN . |
---|
Sets the combination of flags.
flags | the FLAG_AUDIBILITY_ENFORCED
flag. |
---|
Sets attributes as inferred from the legacy stream types. Use this
method when building an AudioAttributes
instance to
initialize some of the attributes by information derived from a
legacy stream type.
streamType | one of STREAM_VOICE_CALL ,
STREAM_SYSTEM ,
STREAM_RING ,
STREAM_MUSIC ,
STREAM_ALARM , or
STREAM_NOTIFICATION . |
---|
Sets the attribute describing what is the intended use of the the audio signal, such as alarm or ringtone.