Why can't I play sounds more than once using HTML5 audio tag?

前端 未结 4 1008
时光取名叫无心
时光取名叫无心 2021-02-01 17:19

This is how the sound is \"stored\":


In the actual game (whi

4条回答
  •  被撕碎了的回忆
    2021-02-01 17:52

    See this slide and the preceding three slides of Evan Wallace and Justin Ardini's presentation on html5 game dev.

    For all the resources to make some awesome games, part of their talk: http://madebyevan.com/gamedevclass/

    Audio still doesn't work consistently across all browsers, as of right now:

    • An element must be reloaded in Chrome or it will only play once
    • An element must not be reloaded in Firefox or there will be a delay
    function playSoundEvent() {
      if (window.chrome) elems[index].load()
      elems[index].play()
      index = (index + 1) % elems.length
    }
    

提交回复
热议问题