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

record-data-available never fires #3800

Open
kgrozdanovski opened this issue Jul 28, 2024 · 2 comments
Open

record-data-available never fires #3800

kgrozdanovski opened this issue Jul 28, 2024 · 2 comments
Labels

Comments

@kgrozdanovski
Copy link

Bug description

The Record plugin lists an event called 'record-data-available', which is supposed to continously fire during recording and contain
a blob. Instead this event is never triggered, despite confirming it should work according to the docs as well as the source code for the version I am using (everything looks OK, I am not sure what the bug is).

The plugin itself works as I can stop and download audio, visualize the waveform and the record-progress event is cleanly triggered, which I use to display a duration timer.

Environment

  • Browser: Chrome

Plain HTML file - scripts loaded as

<script src="https://unpkg.com/[email protected]"></script>
<script src="https://unpkg.com/[email protected]/dist/plugins/record.min.js"></script>

Actual application logic resides in a <script defer type="module"> block.

Minimal code snippet

           // Initialize the Record plugin
            record = wavesurfer.registerPlugin(RecordPlugin.create({
                scrollingWaveform: true,
                renderRecordedAudio: false
            }));

            record.on('record-data-available', (blob) => {
                console.log('test');
            });

            record.on('record-progress', (time) => {
                updateProgress(time);
            });

Expected result

A lot of 'test' messages in the console

Obtained result

Event never triggered, hence 0 messages in console log

@kgrozdanovski
Copy link
Author

Apparently, passing a mediaRecorderTimeslice option to the create method fixes this and it now works flawlessly.

This did waste a lot of my time though and I believe it should be prominently noted in the documentation, since one would expect there to be a default value as data is recorded regardless if we pass the mediaRecorderTimeslice property or not, yet the event is not triggered.

Updated code sample:

record = wavesurfer.registerPlugin(RecordPlugin.create({
    scrollingWaveform,
    renderRecordedAudio: false,
    mediaRecorderTimeslice: 1000
}));

Leaving this open as a documentation issue.

@katspaugh
Copy link
Owner

Thanks! That’s strange indeed. The event should be emitted regardless of this option, might be a bug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants