Sign in to follow this  

[web] Game Music in HTML5

This topic is 2386 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I've been working on a small HTML5 game project for a while now. Everything has been going smoothly, except for audio. Currently, the usability of HTML5 for audio seems highly limited based on the admittedly limited googling I've done. There seems to be no universal sound format that browsers support, and even when the audio works in a specific browser, manipulating it (such as looping or resetting the sound) is difficult at best and seems to cause problems.

Oddly enough, Chrome seems to have the most problems of any modern browser (assuming that no version of IE is a modern browser). Firefox 4 has been the browser I've had luck with the most.

A bit of a description on the audio I am playing. For background music, I'm using midi that has been converted to base64 and is being passed as a URI. Yes, it is ugly and it uses the embed element (and so isn't even really HTML5) but as far as looping goes this is by far the most seamless method I've tried. For other sounds in the game, I'm using little .wav files with the HTML5 Audio API. Google Chrome is, sadly, not too compatible with .wav files just yet, and when I tested the embed element on my Mac last night, those didn't work either. Safari plays the .wav sounds but not the music in the embed elements. Again, Firefox 4 plays all of them flawlessly. I'd prefer to have more than one browser's support WITHOUT using Flash.

I've seen a couple of libraries, the most notable of which is SoundManager 2. It uses a flash fall-back if the browser does not support HTML5. But I'd like the expert opinion of the members on this forum. Are there any feasible ways to easily get cross platform sound?

Share this post


Link to post
Share on other sites
Do you want your game's audio working now for enlightened Firefox 4 users without further effort, soon for most users by getting your hands dirty with Flash, or for everyone in 1-2 years' time (when browsers will have improved) using only HTML 5?

I think the most reasonable course of action is ensuring the game works correctly, albeit silently, without embedded MIDI files, without HTML5 audio playback, and without both.

You might want to implement an invisible or unobtrusive Flash "bug" that plays music and sound effects as a fallback for the significant number of clients that have the Flash plugin but not a good browser, or leave them without sound (which seems, to me, more than acceptable; many users play games silently in any case because they have other music or a quiet office).

Share this post


Link to post
Share on other sites
[quote name='LorenzoGatti' timestamp='1306918789' post='4818213']
You might want to implement an invisible or unobtrusive Flash "bug" that plays music and sound effects as a fallback for the significant number of clients that have the Flash plugin but not a good browser, or leave them without sound (which seems, to me, more than acceptable; many users play games silently in any case because they have other music or a quiet office).
[/quote]

I'll take that sage advice. Any work I don't have to do is a plus for me! Currently Chrome doesn't play sound background music, and there is still a slight issue with anything Firefox below version 4, but other than that I think its good. Too bad HTML5 sound isn't as awesome as it could be just yet...

Share this post


Link to post
Share on other sites

This topic is 2386 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this