Download MP3 Stream Via AJAX Then Load To HTML5 Audio

There may be cases where you want to download the whole audio file before loading it into the HTML5 Audio widget.

In my case, while it is easy to just set the URL to the source of the HTML5 Audio widget, it does not work if the URL is cross-domain.

Downloading the whole binary was the only solution that I came up with.

This can be done using plain Javascript. With JQuery however, there seems to be no way to do this because AJAX calls return a response type of string. Using traditional Javascript is no problem anyway.

See following code:

That’s it!

Related Posts Plugin for WordPress, Blogger...

Leave a Reply

Your email address will not be published. Required fields are marked *