开发者

How to control sound in a pure DHTML game

I am looking into writing web based games using just Javascript, HTML, and CSS. It seems like there are large classes of games开发者_如何学Go could be done using these technologies, except for one thing. I can't really find a good way of controlling sound, the only thing I see that it works is to embedding a control of some sort into the page. Is their a way to do fine grained sound effects in DHTML?

Lets say I had a pool game and wanted to have the sounds of the balls hitting each other, is there a way to do this without using some sort of plugin?


You can use SoundManager 2 for this; SoundManager 2 is a JavaScript library for controlling sound on webpages with a nice API. Have a look at this demo page, some nice examples there, particularly A Noisy Page and Smashable Christmas Lights. Google around for other examples of SoundManager 2 usages.

Some interesting answers here: Cross-platform, cross-browser way to play sound from Javascript?. Notable links from that thread:

  • Scriptaculous Sound library
  • jQuery.sound plugin
  • Easy Musicplayer for Flash
  • MooSound: MooTools API for Flash-enabled sound management


You could write a flash application without interface which you'd only have to write once and then you can communicate to it with javascript to make it play songs. It'd basically be your "sound player controlled by DHTML".

See this link: Javascript<>Flash communication explained

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜