AndroidAudioFocus enum

There are four focus request types. A successful focus request with each will yield different behaviors by the system and the other application that previously held audio focus. See https://developer.android.com/reference/android/media/AudioFocusRequest

Inheritance

Constructors

AndroidAudioFocus(int value)
const
AndroidAudioFocus.fromInt(int value)
factory

Values

none → const AndroidAudioFocus

AudioManager#AUDIOFOCUS_NONE expresses that your app requests no audio focus. NOTE: Here it is used as replacement for an AudioFocus set to null, to make it more convenient to unset the focus again. Despite to the docs, AUDIOFOCUS_NONE is already present at API level 19. https://developer.android.com/reference/android/media/AudioManager#AUDIOFOCUS_NONE

const AndroidAudioFocus(0)
gain → const AndroidAudioFocus

AudioManager#AUDIOFOCUS_GAIN expresses the fact that your application is now the sole source of audio that the user is listening to. The duration of the audio playback is unknown, and is possibly very long: after the user finishes interacting with your application, (s)he doesn't expect another audio stream to resume. Examples of uses of this focus gain are for music playback, for a game or a video player.

const AndroidAudioFocus(1)
gainTransient → const AndroidAudioFocus

AudioManager#AUDIOFOCUS_GAIN_TRANSIENT is for a situation when you know your application is temporarily grabbing focus from the current owner, but the user expects playback to go back to where it was once your application no longer requires audio focus. An example is for playing an alarm, or during a VoIP call. The playback is known to be finite: the alarm will time-out or be dismissed, the VoIP call has a beginning and an end. When any of those events ends, and if the user was listening to music when it started, the user expects music to resume, but didn't wish to listen to both at the same time.

const AndroidAudioFocus(2)
gainTransientMayDuck → const AndroidAudioFocus

AudioManager#AUDIOFOCUS_GAIN_TRANSIENT_MAY_DUCK: this focus request type is similar to AUDIOFOCUS_GAIN_TRANSIENT for the temporary aspect of the focus request, but it also expresses the fact during the time you own focus, you allow another application to keep playing at a reduced volume, "ducked". Examples are when playing driving directions or notifications, it's ok for music to keep playing, but not loud enough that it would prevent the directions to be hard to understand. A typical attenuation by the "ducked" application is a factor of 0.2f (or -14dB), that can for instance be applied with MediaPlayer.setVolume(0.2f) when using this class for playback.

const AndroidAudioFocus(3)
gainTransientExclusive → const AndroidAudioFocus

AudioManager#AUDIOFOCUS_GAIN_TRANSIENT_EXCLUSIVE is also for a temporary request, but also expresses that your application expects the device to not play anything else. This is typically used if you are doing audio recording or speech recognition, and don't want for examples notifications to be played by the system during that time.

const AndroidAudioFocus(4)

Properties

hashCode int
The hash code for this object.
no setterinherited
index int
A numeric identifier for the enumerated value.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
value int
final

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Constants

values → const List<AndroidAudioFocus>
A constant List of the values in this enum, in order of their declaration.