2
我正在研究一個項目,我正在嘗試使用音頻上下文生成音調。這是我到目前爲止:如何在兩個函數之間來回
$("#btn").click(function(){
var context = new (window.AudioContext || window.webkitAudioContext)();
var osc = context.createOscillator(); // instantiate an oscillator
osc.type = 'sine'; // this is the default - also square, sawtooth, triangle
osc.frequency.value = 440; // Hz
osc.connect(context.destination); // connect it to the destination
osc.start(); // start the oscillator
osc.stop(context.currentTime + 1);
})
我從stackoverflow得到的解決方案。它完美地使我尋找的基調。但是,它僅適用於少於六次激活。換句話說,當我點擊按鈕(帶有id ===「btn」)六次以上時,它就不再發出提示音了。
這裏是jsFiddle.net鏈接具有相同的語法如上click here
你能幫我解決這個問題?
https://stackoverflow.com/questions/43511096/uncaught-domexception-failed-to -construct-audiocontext-the-number-of-hardwar和https://stackoverflow.com/questions/25046470/failed-to-construct-audiocontext-number-of-hardware-contexts-reached-maximum –