patrickroberts / synth-js

JavaScript MIDI-to-WAV synthesizer

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

plugin doesn't work with Firefox

Anwarvic opened this issue · comments

Now, I'm working on a project where the backend sends a byte-stream of audio to the frontend. In the frontend, I'm reading the byte-stream into Float32Array and then convert it to WAV object using your synth-js plugin. Then, I'm using this WAV object to create a blob and URL and pass it to an HTML5 audio object and play it.

let buff = new Float32Array(snd_obj["audio"]);
let wav = new synth.WAV(1, snd_obj["sample_rate"], 32, true, buff);
// convert wav to blob
let blob = wav.toBlob();
// get url to be saved in the conversation
let url = URL.createObjectURL(blob);
// create HTML5 audio object
let snd = new Audio(url);
// play it
snd.autoplay=true;

These steps seem to work for chrome, opera, but doesn't work on firefox. Do you have any idea why??

woooooow

I found out the problem... the problem wasn't in your plugin, it was at Firefox as it disables the autoplay by default. So, when I used snd.play() instead of snd.autoplay=true, it worked perfectly

I will close this issue now!!