This part works and has been tested, the problem is at the receiving of data:
I first tried loading all the audioblobs and putting them together like this (it worked)
socket.onmessage = (message) => {
audioChunks.push(message.data);
const audioBlob = new Blob(audioChunks, { type: 'audio/webm' });
audioElement.src = blobUrl;
};
But when I tried to load the individual parts to instantly play them.
socket.onmessage = (message) => {
blob = message.data.slice(0, message.data.size, "audio/webm;")
const blobUrl = URL.createObjectURL(blob);
audioElement.onerror = function() {
console.error('Failed to load audio:', audio.error);
};
audioElement.src = blobUrl;
audioElement.play();
};
I kept getting an error:
listen:41 Failed to load audio: MediaErrorย {code: 4, message: 'DEMUXER_ERROR_COULD_NOT_OPEN: FFmpegDemuxer: open context failed'}
audioElement.onerror @ listen:41
error (asynchroon)
socket.onmessage @ listen:40
listen:1 Uncaught (in promise) DOMException: Failed to load because no supported source was found.
I dont know what to do with this error and was hoping someone could find an oversight.