playSoundEffect method

void playSoundEffect(
  1. String assetPath
)

播放音效的方法 assetPath : 'assets/sounds/win_sound.mp3'

使用示例 void example() { EffectUtil().playSoundEffect('assets/sounds/win_sound.mp3'); }

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');
  }
}