BCDeWitt
BCDeWitt

Reputation: 4773

Splitting an HTML5 Audio Object into Multiple Audio Objects

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?

Upvotes: 1

Views: 3247

Answers (2)

BCDeWitt
BCDeWitt

Reputation: 4773

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)

Upvotes: 0

matrixsmurfen
matrixsmurfen

Reputation: 151

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

Upvotes: 1

Related Questions