AudioAttributesCompat
open class AudioAttributesCompat : VersionedParcelable
kotlin.Any | |
↳ | androidx.media.AudioAttributesCompat |
A class to encapsulate a collection of attributes describing information about an audio stream.
AudioAttributesCompat
supersede the notion of stream types (see for instance AudioManager#STREAM_MUSIC
or AudioManager#STREAM_ALARM
) for defining the behavior of audio playback. Attributes allow an application to specify more information than is conveyed in a stream type by allowing the application to define:
- usage: "why" you are playing a sound, what is this sound used for. This is achieved with the "usage" information. Examples of usage are
USAGE_MEDIA
andAudioAttributesCompat
and it is recommended to build any instance with this information supplied, seeAudioAttributesCompat.Builder
for exceptions. - content type: "what" you are playing. The content type expresses the general category of the content. This information is optional. But in case it is known (for instance
CONTENT_TYPE_MUSIC
for a music playback application) this information might be used by the audio framework to selectively configure some audio post-processing blocks. - flags: "how" is playback to be affected, see the flag definitions for the specific playback behaviors they control.
AudioAttributesCompat
instance is built through its builder, . Also see android.media.AudioAttributes
for the framework implementation of this class.
Summary
Nested classes | |
---|---|
open |
Builder class for |
Constants | |
---|---|
static Int |
Content type value to use when the content type is a soundtrack, typically accompanying a movie or TV program. |
static Int |
Content type value to use when the content type is music. |
static Int |
Content type value to use when the content type is a sound used to accompany a user action, such as a beep or sound effect expressing a key click, or event, such as the type of a sound for a bonus being received in a game. |
static Int |
Content type value to use when the content type is speech. |
static Int |
Content type value to use when the content type is unknown, or other than the ones defined. |
static Int |
Flag defining a behavior where the audibility of the sound will be ensured by the system. |
static Int |
Flag requesting the use of an output stream supporting hardware A/V synchronization. |
static Int |
Usage value to use when the usage is an alarm (e.g. wake-up alarm). |
static Int |
Usage value to use when the usage is for accessibility, such as with a screen reader. |
static Int |
Usage value to use when the usage is driving or navigation directions. |
static Int |
Usage value to use when the usage is sonification, such as with user interface sounds. |
static Int |
Usage value to use for audio responses to user queries, audio instructions or help utterances. |
static Int |
Usage value to use when the usage is for game audio. |
static Int |
Usage value to use when the usage is media, such as music, or movie soundtracks. |
static Int |
Usage value to use when the usage is notification. |
static Int |
Usage value to use when the usage is notification for a non-immediate type of communication such as e-mail. |
static Int |
Usage value to use when the usage is notification for an "instant" communication such as a chat, or SMS. |
static Int |
Usage value to use when the usage is a request to enter/end a communication, such as a VoIP communication or video-conference. |
static Int |
Usage value to use when the usage is to attract the user's attention, such as a reminder or low battery warning. |
static Int |
Usage value to use when the usage is telephony ringtone. |
static Int |
Usage value to use when the usage is unknown. |
static Int |
Usage value to use when the usage is voice communications, such as telephony or VoIP. |
static Int |
Usage value to use when the usage is in-call signalling, such as with a "busy" beep, or DTMF tones. |
Public methods | |
---|---|
open Boolean | |
open Int |
Returns the content type. |
open Int |
getFlags() Returns the flags. |
open Int |
Returns a stream type passed to |
open Int |
getUsage() Returns the usage. |
open Int |
Returns the stream type matching the given attributes for volume control. |
open Int |
hashCode() |
open String |
toString() |
open Any? |
unwrap() If the current SDK level is 21 or higher, return the |
open static AudioAttributesCompat? |
Creates an |
Constants
CONTENT_TYPE_MOVIE
static val CONTENT_TYPE_MOVIE: Int
Content type value to use when the content type is a soundtrack, typically accompanying a movie or TV program.
Value: AudioAttributes.CONTENT_TYPE_MOVIE
CONTENT_TYPE_MUSIC
static val CONTENT_TYPE_MUSIC: Int
Content type value to use when the content type is music.
Value: AudioAttributes.CONTENT_TYPE_MUSIC
CONTENT_TYPE_SONIFICATION
static val CONTENT_TYPE_SONIFICATION: Int
Content type value to use when the content type is a sound used to accompany a user action, such as a beep or sound effect expressing a key click, or event, such as the type of a sound for a bonus being received in a game. These sounds are mostly synthesized or short Foley sounds.
Value: AudioAttributes.CONTENT_TYPE_SONIFICATION
CONTENT_TYPE_SPEECH
static val CONTENT_TYPE_SPEECH: Int
Content type value to use when the content type is speech.
Value: AudioAttributes.CONTENT_TYPE_SPEECH
CONTENT_TYPE_UNKNOWN
static val CONTENT_TYPE_UNKNOWN: Int
Content type value to use when the content type is unknown, or other than the ones defined.
Value: AudioAttributes.CONTENT_TYPE_UNKNOWN
FLAG_AUDIBILITY_ENFORCED
static val FLAG_AUDIBILITY_ENFORCED: Int
Flag defining a behavior where the audibility of the sound will be ensured by the system.
Value: 0x1 << 0
FLAG_HW_AV_SYNC
static val FLAG_HW_AV_SYNC: Int
Flag requesting the use of an output stream supporting hardware A/V synchronization.
Value: 0x1 << 4
USAGE_ALARM
static val USAGE_ALARM: Int
Usage value to use when the usage is an alarm (e.g. wake-up alarm).
Value: AudioAttributes.USAGE_ALARM
USAGE_ASSISTANCE_ACCESSIBILITY
static val USAGE_ASSISTANCE_ACCESSIBILITY: Int
Usage value to use when the usage is for accessibility, such as with a screen reader.
Value: AudioAttributes.USAGE_ASSISTANCE_ACCESSIBILITY
USAGE_ASSISTANCE_NAVIGATION_GUIDANCE
static val USAGE_ASSISTANCE_NAVIGATION_GUIDANCE: Int
Usage value to use when the usage is driving or navigation directions.
Value: AudioAttributes.USAGE_ASSISTANCE_NAVIGATION_GUIDANCE
USAGE_ASSISTANCE_SONIFICATION
static val USAGE_ASSISTANCE_SONIFICATION: Int
Usage value to use when the usage is sonification, such as with user interface sounds.
Value: AudioAttributes.USAGE_ASSISTANCE_SONIFICATION
USAGE_ASSISTANT
static val USAGE_ASSISTANT: Int
Usage value to use for audio responses to user queries, audio instructions or help utterances.
Value: AudioAttributes.USAGE_ASSISTANT
USAGE_GAME
static val USAGE_GAME: Int
Usage value to use when the usage is for game audio.
Value: AudioAttributes.USAGE_GAME
USAGE_MEDIA
static val USAGE_MEDIA: Int
Usage value to use when the usage is media, such as music, or movie soundtracks.
Value: AudioAttributes.USAGE_MEDIA
USAGE_NOTIFICATION
static val USAGE_NOTIFICATION: Int
Usage value to use when the usage is notification. See other notification usages for more specialized uses.
Value: AudioAttributes.USAGE_NOTIFICATION
USAGE_NOTIFICATION_COMMUNICATION_DELAYED
static val USAGE_NOTIFICATION_COMMUNICATION_DELAYED: Int
Usage value to use when the usage is notification for a non-immediate type of communication such as e-mail.
Value: AudioAttributes.USAGE_NOTIFICATION_COMMUNICATION_DELAYED
USAGE_NOTIFICATION_COMMUNICATION_INSTANT
static val USAGE_NOTIFICATION_COMMUNICATION_INSTANT: Int
Usage value to use when the usage is notification for an "instant" communication such as a chat, or SMS.
Value: AudioAttributes.USAGE_NOTIFICATION_COMMUNICATION_INSTANT
USAGE_NOTIFICATION_COMMUNICATION_REQUEST
static val USAGE_NOTIFICATION_COMMUNICATION_REQUEST: Int
Usage value to use when the usage is a request to enter/end a communication, such as a VoIP communication or video-conference.
Value: AudioAttributes.USAGE_NOTIFICATION_COMMUNICATION_REQUEST
USAGE_NOTIFICATION_EVENT
static val USAGE_NOTIFICATION_EVENT: Int
Usage value to use when the usage is to attract the user's attention, such as a reminder or low battery warning.
Value: AudioAttributes.USAGE_NOTIFICATION_EVENT
USAGE_NOTIFICATION_RINGTONE
static val USAGE_NOTIFICATION_RINGTONE: Int
Usage value to use when the usage is telephony ringtone.
Value: AudioAttributes.USAGE_NOTIFICATION_RINGTONE
USAGE_UNKNOWN
static val USAGE_UNKNOWN: Int
Usage value to use when the usage is unknown.
Value: AudioAttributes.USAGE_UNKNOWN
USAGE_VOICE_COMMUNICATION
static val USAGE_VOICE_COMMUNICATION: Int
Usage value to use when the usage is voice communications, such as telephony or VoIP.
Value: AudioAttributes.USAGE_VOICE_COMMUNICATION
USAGE_VOICE_COMMUNICATION_SIGNALLING
static val USAGE_VOICE_COMMUNICATION_SIGNALLING: Int
Usage value to use when the usage is in-call signalling, such as with a "busy" beep, or DTMF tones.
Value: AudioAttributes.USAGE_VOICE_COMMUNICATION_SIGNALLING
Public methods
getContentType
open fun getContentType(): Int
Returns the content type.
Return | |
---|---|
Int |
one of the values that can be set in Builder#setContentType(int) |