playSoundEffect method

void playSoundEffect(
  1. String assetPath
)

播放普通音效(复用音频池1)

assetPath 音效资源文件路径,如 'assets/sounds/win_sound.mp3'

示例:

EffectUtil().playSoundEffect('assets/sounds/win_sound.mp3');

返回结果:Future

Implementation

void playSoundEffect(String assetPath) async {
  Logger.log('Playing sound from: $assetPath');
  try {
    await _audioPool[1].play(assetPath.replaceAll('assets/', ''));
  } catch (e) {
    Logger.log('Error playing sound: $e');
  }
}