4 ms·
I have very little knowledge in this domain, but why do so few of these demos ever have sound? Is there something lacking with canvas and sound/music?
by SeanDav 14y ago
I have very little knowledge in this domain, but why do so few of these demos ever have sound? Is there something lacking with canvas and sound/music?
- zacksjoden 14y agoI haven't followed html5 development too closely, but audio support in current browsers hasn't been uniform. I'm guessing the lack of one size fits all for audio in browsers is why. http://en.wikipedia.org/wiki/HTML5_Audio http://en.wikipedia.org/wiki/HTML5_Audio edit: I'd also guess because audio is hard and that it is probably easier to make graphics and gaming logic than making sounds/music properly.
- dmiladinov 14y agoProbably because that's harder or outside of the scope of a demo. The first search result for "html5 games sound music" was this case study: http://www.html5rocks.com/en/tutorials/webaudio/fieldrunners/ http://www.html5rocks.com/en/tutorials/webaudio/fieldrunners... From the first paragraph: "Fieldrunners is an award-winning tower-defense style game that was originally released for iPhone in 2008. Since then it has been ported to many other platforms. One of the most recent platforms was the Chrome browser in October 2011. One of the challenges of porting Fieldrunners to an HTML5 platform was how to play sound."
- jlongster 14y agoI discussed it briefly near the end of the article under "Adding Sounds". The main reason this article doesn't do it is because it's focusing on rendering with canvas, and there's already a lot of information for beginners to go through there. I plan on writing a followup to include sound, though, or possible extending this article. What the other comments say is true, also. It's not extremely straightforward. The state of APIs on the web is very mixed, but I think in a year or so the Web Audio API will in most places.
- tomjen3 14y agoCanvas doesn't have any kind of support for playing music, but there is a (flash) based sound manager that works everywhere and Chrome has some facility for playing sound too. However making music is an art not all programmers have mastered, so most would likely skip that step.
- city41 14y agoAll modern browsers support the HTML5 audio tag.
- tomjen3 14y agoYeah but that isn't really good enough to play sounds in (for a game).
- city41 14y agoI disagree, it's not the best, but it's decent enough for most games. Most HTML5 game engines use the audio tag. My game uses a good amount of sound effects and background music just fine with the audio tag: http://cityfortyone-mattgreer.dotcloud.com/dragonPlunder/ http://cityfortyone-mattgreer.dotcloud.com/dragonPlunder/