playPooled method

Future<StopFunction?> playPooled(
  1. String key,
  2. Source source, {
  3. double? volume,
})

Play using a pooled player (or fallback to the single channel player).

Returns a StopFunction when pooling is active; returns null when falling back to the single player.

  • key: pool identifier for this sound (defaults to path if you use playPooledPath). All plays with the same key share a pool.
  • source: any audioplayers Source (Asset/DeviceFile/Url/Bytes).
  • volume: defaults to the channel’s current volume.

Implementation

Future<StopFunction?> playPooled(
    String key,
    Source source, {
      double? volume,
    }) async {
  if (!_poolingEnabled) {
    await playFromSource(source);
    return null;
  }
  final pool = await _poolFor(key, source);
  return pool.start(volume: volume ?? this.volume);
}