[英]JavaScript - Uncaught TypeError: Cannot set property of undefined
I keep getting Uncaught TypeError: Cannot set property 'onaudioprocess' of undefined at (index):144.我不断收到 Uncaught TypeError: Cannot set property 'onaudioprocess' of undefined at (index):144。 Every time when I use the setTimeout I get the error.
每次使用 setTimeout 时都会出现错误。
setTimeout(function(){
setupAudioNodes();
loadSound("lecture10.mp3");
}, 3000);
javascriptNode.onaudioprocess = function() {
//get input as web param.
var param = window.location.search.substring(1);
//console.log(param);
var res = param.split("%20");
// get the average for the first channel
var array = new Uint8Array(analyser.frequencyBinCount);
analyser.getByteFrequencyData(array);
var average = getAverageVolume(array);
if(average < 25.0){
if(n > res.length-1){return;}
console.log("First Channel : " + average);
console.log(context.currentTime);
//document.write(parseInt(context.currentTime));
document.write(res[n++] + " ");
//document.getElementById('title').innerHTML = "ssss " ;
}
}
我认为您可能在 setupAudioNodes() 中定义了 javascriptNode [意味着该节点仅在超时时间 3 秒后可用,直到该时间节点未定义],如果是这样,在 setupAudioNodes() 中移动以下行应该可以解决问题。
javascriptNode.onaudioprocess = function() { //... }
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.