Jump to content

Recent Blog Post About "Native" HTML 5 Audio and Howler.js


mwatt
 Share

Recommended Posts

Hi guys,

 

I recently posted an article about playing sound in the browser.  I think it is fairly accurate, but I have learned that there are extremely informed people frequenting this HMTL5 Game Dev site - and said people often add to my understanding and/or correct misperceptions I may have had.

 

If anyone would care to read it - either to learn something or teach me something, it can be found here:

 

http://uberiquity.com/blog/index.php/2013/12/coaxing-sound-out-of-the-browser/

Link to comment
Share on other sites

It looks like a good overview of the HTML5 audio tag. It doesn't seem to cover the Web Audio API much though, which is significant because it enables polyphonic playback on Safari iOS and Chrome for Android, where you otherwise can only play one sound at a time with HTML5 audio. This also makes audio sprites redundant, so there's no need to use them providing you have Web Audio support (which you indicate Howler does).

 

Also if you mention MP3, it should only be to say that you shouldn't touch it with a barge pole. If a game using MP3 gets over 5000 plays, you are liable for a $2500 license fee (see http://mp3licensing.com/royalty/games.html). I've emailed them and confirmed all this, and it doesn't matter if you don't make any money, you're still liable for the fee after 5000 uniques. I don't think anyone actually pays it, but there's really no point using it when AAC (.m4a) is a better quality codec, and has no fees for its use. AFAIK AAC is also supported wherever MP3 is, so there is no browser support advantage to using MP3. There should only be two formats necessary: Ogg Vorbis and AAC, and you should try to play the Ogg Vorbis first since the encoders are free.

Link to comment
Share on other sites

Thank you very much AshleyScirra for your time and thoughtful comments.  I have amended the article to back off to a significant degree from my earlier mp3 stance.  You are quite correct in your observation that little of actual substance is covered on the Web Audio API, but this is intentional.  My recommendation is to go with Howler, which will use that API if possible, but otherwise will fall back to HTML5 Audio.  I think this is the right way to go until Web Audio support is more widespread.  The audio sprite recommendation I made to work around mobile Safari issues.

 

Thanks again for your input. :)

Link to comment
Share on other sites

Web Audio support is growing fast though, mobile safari has had it since iOS 6, and Chrome and (I think) now firefox both have it on Android. Its mostly the crappy Android stock browser in which HTML5 audio is needed. And Windows phone devices too I suppose.

Link to comment
Share on other sites

Sure, it does totally depend on your target audience as to which features you can choose to support / ignore. I thought it was only iPad1 that was restricted to iOS 5 though? Doesn't iPad2 support iOS6 and hence also web audio? I can't be sure since I don't have access to one myself, so I'm just guessing if I'm honest ;)

Link to comment
Share on other sites

There are legitimate uses for HTML5 Audio even when Web Audio is supported. For example, you wouldn't want to play a large audio file (such as background music) with Web Audio since it has to first download the full audio source and then decode it in the browser. We ran into significant issues with this on CasinoRPG and found that using Web Audio for sound effects only was the way to go.

 

Web Audio also doesn't render sound sprites worthless either. Just because images are supported in all browsers doesn't mean image sprites are pointless. Same goes for audio, you can significantly decrease HTTP requests by using audio sprites.

Link to comment
Share on other sites

@alex_h,

 

I don't own an iPad either. :)

 

From what I can gather - and this was surprisingly hard to do via web research - the iPad 2 was initially released with Safari 5.1.  It appears that some later revisions of iPad 2 were released with Safari 6... but like you, I am not 100% certain.  I am also unsure of what upgrades are allowed on the iPad 2.

Link to comment
Share on other sites

There are legitimate uses for HTML5 Audio even when Web Audio is supported. For example, you wouldn't want to play a large audio file (such as background music) with Web Audio since it has to first download the full audio source and then decode it in the browser. We ran into significant issues with this on CasinoRPG and found that using Web Audio for sound effects only was the way to go.

 

Web Audio also doesn't render sound sprites worthless either. Just because images are supported in all browsers doesn't mean image sprites are pointless. Same goes for audio, you can significantly decrease HTTP requests by using audio sprites.

 

Using HTML5 audio as well as Web Audio is an interesting idea, I hadn't thought of that before.

As for the audio sprite question I've previously held off from using an audio sprite for my web audio sounds because I wasn't sure how well it would handle looping. I had noticed that howler does use them though, so have been meaning to look into the idea for a while. Presumably looping web audio sounds from within an audio sprite works ok then?

Link to comment
Share on other sites

Nice to see Goldfire drop by.  Thanks for the input and thanks for Howler of course.

 

That picture looks a lot like the caricature of James Simpson himself, on the Goldfire site.  That you James? :)

 

Haha yes this is James, our artist is quite good at characters!

 

@alex_h: We've been using looping within sprites quite extensively and haven't run into any issues.

Link to comment
Share on other sites

@alex_h: We've been using looping within sprites quite extensively and haven't run into any issues.

 

Thanks James, that's really useful to know. I guess I ought to bite the bullet and make the switch to using audio sprites for my Web Audio manager at some point now!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...