I have a web audio network that consists of a (live mic) source connected to a script node, connected to the destination. If I include a button element with no "onclick" script, the script node (which just does a "console.log") keeps functioning. If I include an onclick script, after executing the script the script node never gets called again, even though the onclick script just sends a message to the console. If there's no onclick script, it works; if the button calls an onclick script, the script node is no longer called. Here is the FireBug console with no onclick script:
144 scriptNode.onaudioprocess bug.html (line 35)
(the count continues to grow)
Here is the output with the onclick script called:
36 scriptNode.onaudioprocess bug.html (line 35) hello bug.html (line 62)
(no further output)
Here's the entire code. Can anyone tell me where I've gone wrong? Bug
<link rel="stylesheet" type="text/css" href="jwm.css">
</head>
<body>
<button onclick="sayHello()">Click me</button><br>
<!-- <button>Click me</button><br> -->
<script>
// Encapsulate the client code in this single function.
//
function runClient(sock,beatsPerCycle,beatsPerMinute) {
// Do necessary fallbacks to get the user media.
navigator.getUserMedia = (navigator.getUserMedia ||
navigator.webkitGetUserMedia ||
navigator.mozGetUserMedia ||
navigator.msGetUserMedia);
// Set up the context.
var audioContext = new AudioContext();
// Set up the script node that does all the work.
var scriptNode = audioContext.createScriptProcessor(0, 2, 2);
scriptNode.onaudioprocess = function(audioProcessingEvent) {
console.log("scriptNode.onaudioprocess");
};
if (navigator.getUserMedia) {
navigator.getUserMedia(
{
audio: true
},
function (stream) {
var source = audioContext.createMediaStreamSource(stream);
// Next line courtesy of
// http://ift.tt/1M7IIdG
window.horrible_hack_for_mozilla = source;
source.connect(scriptNode);
scriptNode.connect(audioContext.destination);
},
function(err) {
console.log("The following getUserMedia error occured: " + err);
throw("");
}
);
} else {
console.log("browser does not have getUserMedia.");
}
}
function sayHello() {
console.log("hello");
}
runClient()
</script>
</body>
</html>
Aucun commentaire:
Enregistrer un commentaire