Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Way to detect a stream has finished? #14

Closed
Kequc opened this issue May 9, 2015 · 6 comments
Closed

Way to detect a stream has finished? #14

Kequc opened this issue May 9, 2015 · 6 comments

Comments

@Kequc
Copy link

Kequc commented May 9, 2015

I'm currently using opus streaming.

new Recorder
  recordOpus:
    stream: true

On dataAvailable I'm piping information to the server, but I haven't found a way to detect that all pages are finished and the stream should be closed. After the existing stop event there are still one and sometimes two dataAvailable events that occur.

It would be really helpful if there were a dataFinished event or similar but I wasn't able to pinpoint a good place to put it.

@chris-rudmin
Copy link
Owner

Good point. Do you think it would be better to wait until all dataAvailable events are completed before publishing 'stop' or adding another event would be more appropriate? My feeling is to push the stop event until all dataAvailable events are completed.
Another possibility is If the server is reading the ogg stream, the last page will contain a final page header indicator, and the stream could be terminated from the server side.

@Kequc
Copy link
Author

Kequc commented May 11, 2015

Could wait to publish 'stop'. My feeling is since it gets published pretty much immediately, it's not so useful currently. My implementation necessitates changing the blobs emitted by recorderjs into base64 and back into a buffer on the server. The header solution might work well, for me, as long as base64 stuff doesn't interfere with it.

@chris-rudmin
Copy link
Owner

Check out my branch stop-event with commit 282bcdd and tell me if it does the job.

@Kequc
Copy link
Author

Kequc commented May 11, 2015

That works perfectly from what I can tell. My problem is now off topic, there isn't any way to synchronously convert Blob to base64 so I'll need to finagle with the stop event and what my program does after it is triggered. I hadn't taken that into account.

@chris-rudmin
Copy link
Owner

If you do recorder.worker.addEventLisener("message", function(typedArray){...}) you will get the raw array buffer instead of a blob. You can then convert easily to base64.
http://stackoverflow.com/questions/9267899/arraybuffer-to-base64-encoded-string

@chris-rudmin
Copy link
Owner

Merged fix.

chris-rudmin added a commit that referenced this issue Jul 15, 2020
Update docs about using with webpack
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants