AudioManagerCompat
class AudioManagerCompat
kotlin.Any | |
↳ | androidx.media.AudioManagerCompat |
Compatibility library for AudioManager
with fallbacks for older platforms.
Summary
Constants | |
---|---|
static Int |
Used to indicate a gain of audio focus, or a request of audio focus, of unknown duration. |
static Int |
Used to indicate a temporary gain or request of audio focus, anticipated to last a short amount of time. |
static Int |
Used to indicate a temporary request of audio focus, anticipated to last a short amount of time, during which no other applications, or system components, should play anything. |
static Int |
Used to indicate a temporary request of audio focus, anticipated to last a short amount of time, and where it is acceptable for other audio applications to keep playing after having lowered their output level (also referred to as "ducking"). |
Public methods | |
---|---|
static Int |
abandonAudioFocusRequest(@NonNull audioManager: AudioManager, @NonNull focusRequest: AudioFocusRequestCompat) Abandon audio focus. |
static Int |
getStreamMaxVolume(@NonNull audioManager: AudioManager, streamType: Int) Returns the maximum volume index for a particular stream. |
static Int |
getStreamMinVolume(@NonNull audioManager: AudioManager, streamType: Int) Returns the minimum volume index for a particular stream. |
static Int |
requestAudioFocus(@NonNull audioManager: AudioManager, @NonNull focusRequest: AudioFocusRequestCompat) Requests audio focus. |
Constants
AUDIOFOCUS_GAIN
static val AUDIOFOCUS_GAIN: Int
Used to indicate a gain of audio focus, or a request of audio focus, of unknown duration.
Value: AudioManager.AUDIOFOCUS_GAIN
AUDIOFOCUS_GAIN_TRANSIENT
static val AUDIOFOCUS_GAIN_TRANSIENT: Int
Used to indicate a temporary gain or request of audio focus, anticipated to last a short amount of time. Examples of temporary changes are the playback of driving directions, or an event notification.
Value: AudioManager.AUDIOFOCUS_GAIN_TRANSIENT
AUDIOFOCUS_GAIN_TRANSIENT_EXCLUSIVE
static val AUDIOFOCUS_GAIN_TRANSIENT_EXCLUSIVE: Int
Used to indicate a temporary request of audio focus, anticipated to last a short amount of time, during which no other applications, or system components, should play anything. Examples of exclusive and transient audio focus requests are voice memo recording and speech recognition, during which the system shouldn't play any notifications, and media playback should have paused.
Value: AudioManager.AUDIOFOCUS_GAIN_TRANSIENT_EXCLUSIVE
AUDIOFOCUS_GAIN_TRANSIENT_MAY_DUCK
static val AUDIOFOCUS_GAIN_TRANSIENT_MAY_DUCK: Int
Used to indicate a temporary request of audio focus, anticipated to last a short amount of time, and where it is acceptable for other audio applications to keep playing after having lowered their output level (also referred to as "ducking"). Examples of temporary changes are the playback of driving directions where playback of music in the background is acceptable.
Value: AudioManager.AUDIOFOCUS_GAIN_TRANSIENT_MAY_DUCK
Public methods
abandonAudioFocusRequest
static fun abandonAudioFocusRequest(
@NonNull audioManager: AudioManager,
@NonNull focusRequest: AudioFocusRequestCompat
): Int
Abandon audio focus. Causes the previous focus owner, if any, to receive focus.
Parameters | |
---|---|
focusRequest |
AudioFocusRequestCompat: the AudioFocusRequestCompat that was used when requesting focus with requestAudioFocus(AudioManager, AudioFocusRequestCompat) . |
Return | |
---|---|
Int |
AudioManager#AUDIOFOCUS_REQUEST_FAILED or |
Exceptions | |
---|---|
IllegalArgumentException |
if passed a null argument |
getStreamMaxVolume
@IntRange(0) static fun getStreamMaxVolume(
@NonNull audioManager: AudioManager,
streamType: Int
): Int
Returns the maximum volume index for a particular stream.
Parameters | |
---|---|
streamType |
Int: The stream type whose maximum volume index is returned. |
Return | |
---|---|
Int |
The maximum valid volume index for the stream. |
getStreamMinVolume
@IntRange(0) static fun getStreamMinVolume(
@NonNull audioManager: AudioManager,
streamType: Int
): Int
Returns the minimum volume index for a particular stream.
Parameters | |
---|---|
streamType |
Int: The stream type whose minimum volume index is returned. |
Return | |
---|---|
Int |
The minimum valid volume index for the stream. |
requestAudioFocus
static fun requestAudioFocus(
@NonNull audioManager: AudioManager,
@NonNull