Throws this error on prod when audioCtx.decodeAudioData(buf) is executed
No erorr in localhost
Uncaught (in promise) DOMException: Failed to execute 'decodeAudioData' on 'BaseAudioContext': Unable to decode audio data
Promise.then (async)
getSongFromAPI @ source.js:36
toggleMusic @ source.js:47
onclick @ (index):27
audioCtx = new (window.AudioContext || window.webkitAudioContext)();
playSound = audioCtx.createBufferSource()
// TODO: get this song from API instead of local storage
const song_1980_dont_stop = '../media/audio/heart-change-brock-hewitt-stories-in-sound-main-version-04-28-13106.mp3'
fetch(song_1980_dont_stop)
.then(data => data.arrayBuffer())
.then(buf => audioCtx.decodeAudioData(buf)) // error here
.then(decodedAudio => {
playSound.buffer = decodedAudio;
playSound.connect(audioCtx.destination);
playSound.start(audioCtx.currentTime);
console.log(audioCtx);
});
Throws this error on prod when
audioCtx.decodeAudioData(buf)
is executed No erorr in localhost