A Flutter Sound Pool for playing short media files.
Sound Pool caches audio tracks in memory. This can be useful in following scenarios:
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);
Soundpool
instance multiple times; DO create a Soundpool
for logically connected sounds (ex. sounds for level, sounds with the same streamType
),play(soundId)
,release()
or dispose()
when sounds are no longer useful,Author: brotoo25
Source Code: https://github.com/brotoo25/flutter_soundpool
#flutter #dart #mobile-apps