JSFiddle - React, Tailwind, and code Playground

JavaScript

var a = new Audio();
a.src = "http://webaudioapi.com/samples/audio-tag/chrono.mp3";
a.controls = true;
a.loop = true;
a.autoplay = true;
document.body.appendChild(a);

var ctx = new AudioContext();


// PROBLEM HERE
var shouldBreak = true;
var src;
if (shouldBreak) {
    // this one stops playback
    // it should redirect output from audio element to the MediaElementAudioSourceNode
    // but src.connect(ctx.destination) does not fix it
    src = ctx.createMediaElementSource(a);
    src.connect(ctx.destination);
}