soundpool 2.1.0
soundpool: ^2.1.0 copied to clipboard

A Flutter Sound Pool for playing short audio files. Sound tracks are cached in memory and played directly from cache.

soundpool #

A Flutter Sound Pool for playing short media files.

Sound Pool caches audio tracks in memory. This can be useful in following scenarios:

  • lower latency between play signal and actual playing of the sound (audio does not need to be read from disc/web),
  • the same sound may be used multiple times.

Inspired by Android SoundPool API. This also means that multiple optional features are supported on Android only.

Example:

    import 'package:soundpool/soundpool.dart';

    Soundpool pool = Soundpool(streamType: StreamType.notification);

    int soundId = await rootBundle.load("sounds/dices.m4a").then((ByteData soundData) {
                  return pool.load(soundData);
                });
    int streamId = await pool.play(soundId);

DOs and DON'Ts #

  • DO NOT create the Soundpool instance multiple times; DO create a Soundpool for logically connected sounds (ex. sounds for level, sounds with the same streamType),
  • DO NOT load the same file multiple times; DO load it once (ideally while the application is starting), store sound id and use play(soundId),
  • DO NOT leave sounds loaded in memory when no longer used; DO call release() or dispose() when sounds are no longer useful,
  • DO NOT play music files; DO use plugin that is intended for that.
73
likes
120
pub points
94%
popularity

Publisher

ukaszapps.pl

A Flutter Sound Pool for playing short audio files. Sound tracks are cached in memory and played directly from cache.

Homepage
Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

flutter, soundpool_macos, soundpool_platform_interface, soundpool_web

More

Packages that depend on soundpool