I want to play a "beep" sound from flutter. I did try to use SystemSound.play but it doesn't seem to work. Please help!.thank in advance.
Future<void> play(SystemSoundType type) async {
await SystemChannels.platform.invokeMethod<void>(
"SystemSound.play",
type.toString(),
);
}
void main() {
play(SystemSoundType.click);
}
> 1.use this
soundpool: ^0.5.3 lib in pubspec.yaml
> 2.import this
import 'package:soundpool/soundpool.dart';
> 3.example
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);