import soundColorDone from "/assets/sound/section_done.mp3?url";
import soundAllDone from "/assets/sound/color_done_02.mp3?url";
import soundHint from "/assets/sound/sound_hint.mp3?url";

export enum AudioType {
  ColorDone,
  AllDone,
  Hint,
}

export default class AudioPlayer {
  audioColorDone: HTMLAudioElement;
  audioAllDone: HTMLAudioElement;
  audioHint: HTMLAudioElement;

  constructor() {
    this.audioColorDone = new Audio(soundColorDone);
    this.audioAllDone = new Audio(soundAllDone);
    this.audioHint = new Audio(soundHint);
  }

  /**
   * 播放提示音
   */
  playAudio(id: AudioType) {
    console.log(`play sound ${id}`);
    switch (id) {
      case AudioType.ColorDone:
        this.audioColorDone.play();
        break;
      case AudioType.AllDone:
        this.audioAllDone.play();
        break;
      case AudioType.Hint:
        this.audioHint.play();
        break;
      default:
        break;
    }
  }
}
