Confirmed users
656
edits
Line 167: | Line 167: | ||
<pre> | <pre> | ||
<audio id="a1" | |||
src="song.ogg" | |||
onloadedmetadata="loadedMetadata(event);" | |||
onaudiowritten="audioWritten(event);" | |||
controls="controls"> | |||
</audio> | |||
<script> | |||
var a1 = document.getElementById('a1'), | |||
a2 = new Audio(), | |||
function | function loadedMetadata(event) { | ||
// Mute a1 audio. | |||
a1.volume = 0; | |||
// Setup a2 to be identical to a1, and play through there. | |||
a2.mozSetup(event.mozChannels, event.mozRate, 1); | |||
} | |||
function audioWritten(event) { | |||
// Write the current frame to a2 | |||
a2.mozWriteAudio(event.mozFrameBuffer); | |||
} | } | ||
</script> | |||
</pre> | </pre> | ||