AudioPool class

An AudioPool is a provider of AudioPlayers that are pre-loaded with an asset to minimize delays.

All AudioPlayers are loaded with the same audio source. If you want multiple sounds use multiple AudioPools.

Use this class if you for example have extremely quick firing, repetitive or simultaneous sounds.

Properties

audioCache AudioCache
Instance of AudioCache to be used by all players.
final
availablePlayers List<AudioPlayer>
final
currentPlayers Map<String, AudioPlayer>
final
hashCode int
The hash code for this object.
no setterinherited
maxPlayers int
The maximum number of players to be kept in the pool.
final
minPlayers int
The minimum numbers of players, this is the amount of players that the pool is initialized with.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
source Source
The source of the sound for this pool.
final

Methods

dispose() Future<void>
Disposes the audio pool. Then it cannot be used anymore.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
start({double volume = 1.0}) Future<StopFunction>
Starts playing the audio, returns a function that can stop the audio.
toString() String
A string representation of this object.
inherited

Operators

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

Static Methods

create({required Source source, required int maxPlayers, AudioCache? audioCache, int minPlayers = 1}) Future<AudioPool>
Creates an AudioPool instance with the given parameters.
createFromAsset({required String path, required int maxPlayers, AudioCache? audioCache, int minPlayers = 1}) Future<AudioPool>
Creates an AudioPool instance with the asset from the given path.