How to play audio?

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

I am making a game with HTML5 and JavaScript.

How could I play game audio via JavaScript?

20条回答
  •  梦毁少年i
    2020-11-21 13:52

    http://www.schillmania.com/projects/soundmanager2/

    SoundManager 2 provides a easy to use API that allows sound to be played in any modern browser, including IE 6+. If the browser doesn't support HTML5, then it gets help from flash. If you want stricly HTML5 and no flash, there's a setting for that, preferFlash=false

    It supports 100% Flash-free audio on iPad, iPhone (iOS4) and other HTML5-enabled devices + browsers

    Use is as simple as:

    
    
    

    Here's a demo of it in action: http://www.schillmania.com/projects/soundmanager2/demo/christmas-lights/

提交回复
热议问题