Skip to content

lichess-org/flutter-sound-effect

Folders and files

NameName
Last commit message
Last commit date

Latest commit

0401b0b · Mar 11, 2025

History

21 Commits
Mar 11, 2025
Mar 11, 2025
Mar 11, 2025
Mar 11, 2025
Jul 24, 2024
Jul 24, 2024
Mar 11, 2025
Jul 24, 2024
Jul 26, 2024
Jul 24, 2024
Mar 10, 2025

sound_effect

A Flutter plugin for playing sound effects with a simple API and the lowest possible latency.

Getting Started

Initialize the plugin, before using any of the other methods:

import 'package:sound_effect/sound_effect.dart';

void main() async {
  final _soundEffect = SoundEffect();
  await _soundEffect.initialize();
}

Load a sound effect, using a unique identifier and the path to the sound file:

Future<void> loadSound(String soundId) async {
  await _soundEffect.load(soundId, 'assets/sound_effect.mp3');
}

Play the sound effect:

Future<void> playSound(String soundId) async {
  await _soundEffect.play(soundId);
}

You can also play the sound effect with a custom volume:

_soundEffect.play('effect', volume: 0.5);

Release the loaded sounds when they are no longer needed:

_soundEffect.release();