import { useAudioMange } from '@/hooks/index'

const audioMange = useAudioMange()

export class AudioController {

  static wrongUrl = `https://res-game.luojigou.vip/wrong.mp3`

  static correntUrl = 'https://res-game.luojigou.vip/coin-light.mp3' 

  static coinLight = 'https://res-game.luojigou.vip/correct.mp3'

  static pass = 'https://res-game.luojigou.vip/pass.MP3'

  static fail = 'https://res-game.luojigou.vip/fail.MP3'

  static playCorrect () {
    audioMange.play(AudioController.correntUrl)
  }

  static playWrong () {
    audioMange.play(AudioController.wrongUrl)

  }

  static playCoinLight () {
    audioMange.play(AudioController.coinLight)
  }

  static playPass () {
    audioMange.play(AudioController.pass)
    return new Promise( (resolve) => {
      audioMange.onplayend(() => {
        resolve(true)
      })
    })
   
  }

  static playFail () {
    audioMange.play(AudioController.fail) 
    return new Promise( (resolve) => {
      audioMange.onplayend(() => {
        resolve(true)
      })
    })
  }

}