How to play audio?

前端 未结 20 3224
抹茶落季
抹茶落季 2020-11-21 13:37

I am making a game with HTML5 and JavaScript.

How could I play game audio via JavaScript?

20条回答
  •  栀梦
    栀梦 (楼主)
    2020-11-21 13:49

    I used this method to play a sound...

    var audioElement;
    if(!audioElement) {
      audioElement = document.createElement('audio');
      audioElement.innerHTML = ''
    }
    audioElement.play();
    

提交回复
热议问题