AudioSession class Null safety

Manages a single audio session to be used across different audio plugins in your app. AudioSession will configure your app by describing to the operating system the nature of the audio that your app intends to play.

You obtain the singleton instance of this class, configure it during your app's startup, and then use other plugins to play or record audio. An app will typically not call setActive directly since individual audio plugins will call this before they play or record audio.

Properties

androidAudioAttributes AndroidAudioAttributes?
The configured AndroidAudioAttributes.
read-only
androidAudioFocusGainType AndroidAudioFocusGainType?
The configured AndroidAudioFocusGainType.
read-only
becomingNoisyEventStream Stream<void>
A stream of events that occur when audio becomes noisy (e.g. due to unplugging the headphones).
read-only
configuration AudioSessionConfiguration?
The current configuration.
read-only
configurationStream Stream<AudioSessionConfiguration>
A stream broadcasting the current configuration.
read-only
devicesChangedEventStream Stream<AudioDevicesChangedEvent>
A stream emitting events whenever devices are added or removed to the set of available devices.
read-only
devicesStream Stream<Set<AudioDevice>>
A stream emitting the set of connected devices whenever there is a change.
read-only
hashCode int
The hash code for this object. [...]
read-only, inherited
interruptionEventStream Stream<AudioInterruptionEvent>
A stream of AudioInterruptionEvents.
read-only
isConfigured bool
Whether the audio session is configured.
read-only
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited

Methods

configure(AudioSessionConfiguration configuration) Future<void>
Configures the audio session. It is useful to call this method during your app's initialisation before you start playing or recording any audio. However, you may also call this method afterwards to change the current configuration at any time.
getDevices({bool includeInputs = true, bool includeOutputs = true}) Future<Set<AudioDevice>>
Completes with a list of available audio devices.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
inherited
setActive(bool active, {AVAudioSessionSetActiveOptions? avAudioSessionSetActiveOptions, AndroidAudioFocusGainType? androidAudioFocusGainType, AndroidAudioAttributes? androidAudioAttributes, bool? androidWillPauseWhenDucked, AudioSessionConfiguration fallbackConfiguration = const AudioSessionConfiguration.music()}) Future<bool>
Activates or deactivates this audio session. Typically an audio plugin should call this method when it begins playing audio. If the audio session is not yet configured at the time this is called, the fallbackConfiguration will be set. If any of avAudioSessionSetActiveOptions, androidAudioFocusGainType, androidAudioAttributesttributes and androidWillPauseWhenDucked are speficied, they will override the configuration.
toString() String
A string representation of this object. [...]
inherited

Operators

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

Static Properties

instance Future<AudioSession>
The singleton instance across all Flutter engines.
read-only