ScarletsFiction/SFMediaStream

Uncaught RangeError: offset is out of bounds

Closed this issue · 6 comments

Hello!
Why am I keep getting this Error?
Everything works just fine but I am still getting this error..
error
.

Hi!
Can I know which browser that you're using?
And also how long it running until the error appear (or maybe step to reproduce)

Maybe you can use .receiveBuffer instead of .realtimeBufferPlay so the media data will be handled by the browser itself.
https://github.com/ScarletsFiction/SFMediaStream#example-1

The browser I am using is chrome the last and most updated version.

When trying to use receiveBuffer(), I don't hear anything on the second tab.
So I ended up using realtimeBufferPlay() again.

When I press the record button it starts to record and send the audio throw the socket..
In the other tab it receives the audio and play it.
The error occurs when I press the record again It send the buffers and after a second or two I get an error between the buffers.
The error is not effecting the sound or something else, just wanted to know why is this happening.

It seems like I need to restart the recorder or empty it or do something...

Thanks for the details.

Sadly I'm unable to reproduce the error on library version v1.3.1 🤔
Even I have stopped and started again the recorder on presenter many times.

Hmm, by the way...
Did you have stopped the record from the presenter before start recording again with .stopRecording() ?


The .realtimeBufferPlay usually also give some sound gap tho, and .receiveBuffer is more recommended to fix that.
And also don't forget to trigger streamerInstance.playStream(); before receiving any buffer.

Yes, I did stop the record from the presenter before start recording again with .stopRecording()

  • The problem with the .receiveBuffer is that I get the buffers from the socket but for some reason I don't hear a thing...
    It seems like only the .realtimeBufferPlay is working from me...

  • How do I trigger the streamerInstance.playStream(); ?

How do I trigger the streamerInstance.playStream(); ?

It can be triggered after creating ScarletsAudioStreamer

var audioStreamer = new ScarletsAudioStreamer(1000); // 1sec
audioStreamer.playStream();

The problem with the .receiveBuffer is that I get the buffers from the socket but for some reason I don't hear a thing...
It seems like only the .realtimeBufferPlay is working from me...

Yep, I just making sure if playStream already triggered/called. If it's already been called, maybe the browser's autoplay has been blocked that makes .receiveBuffer not working. This usually can happen on Brave browser, and user need to click/interact with the page to trigger the media play (or ask user to enable and not block the autoplay). AFAIK, mobile browser also has this permission issue.

I'm not sure it may be working or not on your side, but can you try modify your code to something like this?

var audioStreamer = new ScarletsAudioStreamer(1000); // 1sec
audioStreamer.playStream();

// Wait for user interaction with the page
// Maybe like add a popup that asking the presenter's ID
// And after that, you can start request the "bufferHeader" to the presenter then receive the other buffer

// The implementation below can be different depend on how you configure your server

// Start the header/data request, after user interact with the page
// and we already create the instance before user interaction
socket.emit('headerRequest', {
    targetID: presenterID
});

socket.on('header', function(data){
    audioStreamer.setBufferHeader(data.packet);
})

socket.on('stream', function(data){
    audioStreamer.receiveBuffer(data.packet);
})

Didn't Worked...
I think I need to find a way to reset the audioStreamer after sending the data