首页 > 解决方案 > 使用 AudioContext 未在 Firebox 中播放音频声音

问题描述

使用 WebAudio API AudioContext。它在 chrome 和播放声音中工作正常。但它没有在Firefox中播放声音,在播放音频栏中显示图标。

// console.log("this.audioContext.state", this.audioContext.state);

//create buffer source node which is used to play a sound one time
const bufferSourceNode = this.audioContext.createBufferSource();
// bufferSourceNode.channelCount = 1;
// bufferSourceNode.channelCountMode
console.log('Created buffer source node');
//set buffer to one of the loaded sounds;
bufferSourceNode.buffer = sound;
//connect to output
bufferSourceNode.connect(this.audioContext.destination);
//play the sound
bufferSourceNode.start();
//stop the sound
// bufferSourceNode.stop(this.audioContext.currentTime + 0.5);
//end  the sound
bufferSourceNode.onended = () => {
console.log("onended");
}

标签: angularaudiocontextwebkitaudiocontext

解决方案


推荐阅读