tapSoundEffect method
播放点击音效(复用音频池0)
assetPath 音效资源文件路径,如 'assets/sounds/win_sound.mp3'
示例:
EffectUtil().tapSoundEffect('assets/sounds/win_sound.mp3');
返回结果:Future
Implementation
void tapSoundEffect(String assetPath) async {
Logger.log('Playing sound from: $assetPath');
try {
// audioplayers的AssetSource参数不需要'assets/'前缀
await _audioPool[0].play(assetPath.replaceAll('assets/', ''));
} catch (e) {
Logger.log('Error playing sound: $e');
}
}