How to fix MediaElementAudioSource outputs zeroes due to CORS restrictions for access... (Web Audio API)?

let audio = new Audio();
audio.src = 'music.mp3';
audio.controls = true;
audio.loop = true;
audio.autoplay = true;

window.addEventListener("load", init, false);

function init(){
document.getElementById('audio_box').append(audio);
 audioCtx = new (window.AudioContext || window.webkitAudioContext); 

 source = audioCtx.createMediaElementSource(audio);
source.connect(audioCtx.destination);

}


The error appears due to:
source = audioCtx.createMediaElementSource(audio);

The solution from the Internet in the form of:
source.connect(audioCtx.destination);
and
audio.by adding crossorigin = "anonymous";
not help.
April 3rd 20 at 18:23
0 answer

Find more questions by tags JavaScript