JSFiddle - React, Tailwind, and code Playground
HTML
<div id='result'>waiting</div>
JavaScript
var audio = document.createElement('audio');
audio.src = 'http://upload.wikimedia.org/wikipedia/en/4/45/ACDC_-_Back_In_Black-sample.ogg';
BUFFER_SIZE = 4096;
ctx = typeof AudioContext !== 'undefined' ? new AudioContext() : new webkitAudioContext();
var processor = ctx.createScriptProcessor(BUFFER_SIZE);
processor.connect(ctx.destination);
var gotData = false;
processor.onaudioprocess = function (e) {
if (gotData) return;
document.getElementById('result').innerHTML = 'processing';
data = e.inputBuffer.getChannelData(0);
for (var i = 0; i < data.length; i++) {
if (data[i] > 0) {
document.getElementById('result').innerHTML = 'gotData';
gotData = true;
}
}
};
src = ctx.createMediaElementSource(audio);
src.connect(processor);
audio.play();