Load sound (XMLHttpRequest) and show play controls (html5 audio player)

I need to add html5 web audio player (with controls on html page) for loaded mp3 song to browser.
How a can do it?

 function loadSound(url) {
        var request = new XMLHttpRequest();
        request.open('GET', url, true);
        request.responseType = 'arraybuffer';

        // When loaded decode the data
        request.onload = function() {

            // decode the data
            context.decodeAudioData(request.response, function(buffer) {
                // when the audio is decoded play the sound
                if (request.response) {
            }, onError);


    function playSound(buffer) {
        sourceNode.buffer = buffer;

Source: html5

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.