JSFiddle - React, Tailwind, and code Playground
by Andrés
JavaScript
async function test() {
const audioUrl = 'https://ssl.gstatic.com/chat/sounds/incoming_message_eb39ce414e3ffba41a8e173581dc7248.mp3';
const context = new AudioContext();
const response = await window.fetch(audioUrl);
const arrayBuffer = await response.arrayBuffer();
const audioBuffer = await context.decodeAudioData(arrayBuffer);
const bufferSource = context.createBufferSource();
bufferSource.buffer = audioBuffer;
bufferSource.connect(context.destination);
bufferSource.loop = true;
bufferSource.start(0, 0, 5);
}
test();