once method
- AudioSource sound
Plays the provided sound
once.
Implementation
Future<void> once(AudioSource sound) async {
ensureInitialized();
if (PlatformUtils.isWeb) {
final String url = switch (sound.kind) {
AudioSourceKind.asset => (sound as AssetAudioSource).asset,
AudioSourceKind.file => '',
AudioSourceKind.url => (sound as UrlAudioSource).url,
};
if (url.isNotEmpty) {
await WebUtils.play(url);
}
} else if (_isMobile) {
await _jaPlayer?.setAudioSource(sound.source);
await _jaPlayer?.play();
} else {
await _player?.open(sound.media);
}
}