1

Assuming that I've merged several audio files into a single audio file (thus using only a single HTTP request), can I split them up into several HTML5 audio objects on the client side with JavaScript and, if so, how? Also, if it is possible, would this have any advantages over multiple requests?

2 Answers 2

1

https://developer.mozilla.org/en-US/docs/Using_HTML5_audio_and_video hints that you can do this under "Specifying playback range".

When specifying the uri you can add a #start,stop to specify the start end end time of the clip.

I have not tried this and so I don't know how this will affect buffering (i.e. will this cause the multiple requests you tried to avoid from the start or will the source be requested only once and then buffered?) but it might be worth playing around with

1
  • This is a good start, but I would really like to be able to play more than just one sound effect at once. If I keep it as one audio object, I'm thinking I'm going to run into that as a limitation...
    – BCDeWitt
    Aug 16, 2012 at 6:18
0

So far, this is what I've found out...HTML5 Audio isn't built for that. Numerous other problems arise with Safari too (see this question and its answers) However, the Web Audio API seems like it might do the trick. While it's not fully supported yet, there are polyfills on github and support for the API is quickly becoming a reality. Games have already been made that utilize this API (see Field Runners)

I've also found some nice tutorials on how to use it - primarily at creativejs and html5rocks.

Lastly, I've found an excellent example of the API in use. (The sound in the example is very quiet, though. You might need to turn up your volume to hear it)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.