ScarletsFiction/SFMediaStream

Correct implementation to play audio received

Closed this issue · 0 comments

I have done the following to get microphone audio and stream it.
I use socket.io to send the data (streamAudio) and then listen for streamedAudio which is received arrayBuffer data.

let presenterMedia = new MediaPresenter({
            audio:{
                channelCount:1,
                echoCancellation: false
            },
        }, 1000); // 1sec

        presenterMedia.onRecordingReady = (packet) => {
            console.log("Recording started!");
            console.log("Header size: " + packet.data.size + "bytes");
        };

        presenterMedia.onBufferProcess = (packet) => {
            console.log("Buffer sent: " + packet);
            this.socket.emit('streamAudio', packet);
        };

        const streamer = new AudioStreamer();
        this.socket.on('audioStreamed', (data) => {
            console.log('audioStreamed', data]); //arrayBuffer
            streamer.realtimeBufferPlay(data);
        });

        presenterMedia.startRecording();

Now I would expect sounds from my microphone to be played back to me in realtime but I hear nothing. Does anyone know why?