Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<html>
<head>
<title></title>
</head>
<body>
<script>
var mySource;
var myAudioContext = new mozAudioContext();
function fetchSound() {
var request = new XMLHttpRequest();
request.open('GET', 'completed.wav', true);
request.responseType = 'arraybuffer';
request.addEventListener('load', bufferSound, false);
request.send();
}
function bufferSound(event) {
var request = event.target;
var source = myAudioContext.createBufferSource();
source.buffer = myAudioContext.createBuffer(request.response, false);
mySource = source;
}
fetchSound();
function playSound() {
mySource.connect(myAudioContext.destination);
mySource.noteOn(0);
}
</script>
<button onclick="playSound();">Play</button>
</body>
</html>
@automata

This comment has been minimized.

Copy link
Owner Author

commented Mar 16, 2013

[21:28:22.221] TypeError: Not enough arguments to mozAudioContext.createBuffer. @ http://localhost:8000/test_moz.html:23

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.