相关疑难解决方法(0)

AudioWorklet错误:DOMException:用户中止了请求

我已经成功地在React中实例化了一个简单的AudioWorklet,并希望像谷歌的例子那样启动一个简单的振荡器.为了测试运行它,我正在渲染一个按钮,其onClick事件调用以下内容:

SRC/App.jsx:

userGesture(){
  //create a new AudioContext
  this.context = new AudioContext();

  //Add our Processor module to the AudioWorklet
  this.context.audioWorklet.addModule('worklet/processor.js').then(() => {

  //Create an oscillator and run it through the processor
  let oscillator = new OscillatorNode(this.context);
  let bypasser = new MyWorkletNode(this.context, 'my-worklet-processor');

  //Connect to the context's destination and start
  oscillator.connect(bypasser).connect(this.context.destination);
  oscillator.start();
  })
  .catch((e => console.log(e)))
}
Run Code Online (Sandbox Code Playgroud)

问题是,每次单击时,addModule方法都会返回以下错误:

DOMException: The user aborted a request.
Run Code Online (Sandbox Code Playgroud)

我在Ubuntu v16.0.4上运行Chrome v66.

SRC/worklet/worklet-的node.js:

 export default class MyWorkletNode extends window.AudioWorkletNode {
        constructor(context) {
          super(context, 'my-worklet-processor');
        }
      }
Run Code Online (Sandbox Code Playgroud)

SRC/worklet/processor.js …

webrtc reactjs scriptprocessor web-audio-api

6
推荐指数
3
解决办法
1374
查看次数

标签 统计

reactjs ×1

scriptprocessor ×1

web-audio-api ×1

webrtc ×1