AudioManager class

A singleton service to manage audio playback across the app.

Ensures only one audio player can play at a time by pausing the previous player when a new one starts.

Usage:

await AudioManager().setCurrentPlayer(audioPlayer);
AudioManager().clearCurrentPlayer(audioPlayer);
await AudioManager().pauseAll();

Constructors

AudioManager()
Returns the singleton AudioManager instance.
factory

Properties

currentPlayer → AudioPlayer?
Get the current active player.
no setter
hashCode → int
The hash code for this object.
no setterinherited
isPlaying → bool
Check if any audio is currently playing.
no setter
onPlayerChanged → Stream<void>
Stream that emits when the current player changes.
no setter
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

clearCurrentPlayer(AudioPlayer player) → void
Clear the current player.
dispose() → void
Dispose the audio manager.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
pauseAll() → Future<void>
Pause all audio.
setCurrentPlayer(AudioPlayer newPlayer) → Future<void>
Set a new current player and pause others.
stopAll() → Future<void>
Stop all audio and reset position.
toString() → String
A string representation of this object.
inherited

Operators

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