1

using the WebAudio API AudioContext. its working fine in the chrome and playing sounds. but its not playing sound in the firefox, showing icon in the bar of playing audio.

// 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");
}
Manmeet Khurana
  • 367
  • 2
  • 13
  • Can you recreate a simple sample in stackblitz? – wannadream Sep 12 '19 at 17:56
  • @wannadream currently using the token for the authentication,url made from the raw files pcm file. and converted the arraybuffer to the audio buffer by using this code . this is creating issue in firefox for not playing sound const myArrayBuffer = audioCtx.createBuffer(2, audioCtx.sampleRate * 2, audioCtx.sampleRate); myArrayBuffer.copyToChannel(buffer, 0,1); – Manmeet Khurana Sep 13 '19 at 14:47
  • From the doc, https://developer.mozilla.org/en-US/docs/Web/API/BaseAudioContext/createBuffer, your code should work as it is designated. If there is an issue, you may need to report an bug to Mozilla, I think. – wannadream Sep 14 '19 at 15:23

0 Answers0