playLocalFile method
Plays a local audio file from the assets directory.
Implementation
Future<void> playLocalFile(String filePath) async {
if (_isDisposed) {
_playback = _playbackFactory();
_isDisposed = false;
}
final playGeneration = ++_playGeneration;
final playback = _playback;
// Ensure the file path is correct and accessible from the web directory
await playback.setAsset(filePath);
if (!_isCurrentPlay(playGeneration, playback)) return;
await playback.setLoopMode(LoopMode.all);
if (!_isCurrentPlay(playGeneration, playback)) return;
await playback.play();
}