JSFiddle - React, Tailwind, and code Playground

JavaScript

function Sound(url, vol, autoplay, loop)
{
    var that = this;
    
    that.url = (url === undefined) ? "" : url;
    that.vol = (vol === undefined) ? 1.0 : vol;
    that.autoplay = (autoplay === undefined) ? true : autoplay;
    that.loop = (loop === undefined) ? false : loop;
    that.sample = null;
    
    if(that.url !== "")
    {
        that.sync = function(){
            that.sample.volume = that.vol;
            that.sample.loop = that.loop;
            that.sample.autoplay = that.autoplay;
            setTimeout(function(){ that.sync(); }, 60);
        };
        
        that.sample = document.createElement("audio");
        that.sample.src = that.url;
        that.sync();
        
        that.play = function(){
            if(that.sample)
            {
                that.sample.play();
            }
        };
    }
}

var test = new Sound("http://mad-hatter.fr/Assets/projects/FreedomWings/Assets/musiques/freedomwings.mp3");
test.play();