question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

"onstop" event not firing

See original GitHub issue

Hello!

I see a new release just went up an hour ago, so I’m not sure if this is related. The onstop event listener doesn’t seem to fire for me.

(I’m using Vue.js)

import { MediaRecorder, register } from "extendable-media-recorder";
import { connect } from "extendable-media-recorder-wav-encoder";
export default {
  name: "Recorder",
  data() {
    return {
      mediaRecorder: null,
      chunks: [],
      urls: []
    };
  },
  methods: {
    record() {
      this.mediaRecorder.start();
    },
    stop() {
      this.mediaRecorder.stop();
    },
    handleData(e) {
      console.log(e);
      this.chunks.push(e.data);
    },
    handleStop() {
      var blob = new Blob(this.chunks, { type: "audio/wav" });
      this.chunks = [];

      this.urls.push(URL.createObjectURL(blob));
    }
  },

  async mounted() {
    await register(await connect());

    const stream = await navigator.mediaDevices.getUserMedia({
      audio: {
        echoCancellation: false
      }
    });
    this.mediaRecorder = new MediaRecorder(stream, { mimeType: "audio/wav" });
    this.mediaRecorder.ondataavailable = this.handleData;
    this.mediaRecorder.onstop = this.handleStop;
  }
};

ondataavailable fires without any issues. If I remove the extendable-media-recorderimports and default to the standard recorder, it fires correctly.

I tried using addEventListener('stop', ...) too, but no luck…

It’s happening in the latest version of Chrome & Firefox. Let me know if there’s anything else I can do to help debug the issue.

Thanks! Ger

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
chrisguttandincommented, Mar 10, 2021

Okay, great.

At least in theory it should perform a bit better. I think RecorderJS always uses the ScriptProcessorNode since that was the only option back then. extendable-media-recorder only uses that when used in Safari. And even that should not be necessary for much longer since Safari gets AudioWorklet support as well. I tried to explain the inner workings in the readme.

Feel free to create another issue if you run into any problems.

1reaction
chrisguttandincommented, Mar 10, 2021

Hi @NoClipDigital, you’re absolutely right. The stop event is not yet implemented. But as far as I remember there was no particular reason, despite of the usual too-many-things-not-enough-time problem.

Did you find a workaround for your use case?

It’s for example possible to check the state of the MediaRecorder whenever the dataavailable event fires. If the state is 'inactive' it’s safe to assume that the recording is done.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Windows Service Does Not Fire OnStart Event - Stack Overflow
OnStart is firing, your timer is not. You must either do timer1.Start() or timer1.Enabled = true in OnStart for the timer to start...
Read more >
Windows service onstop() event not fired when someone kills ...
I am trying to send mail when someone stops my service. But when someone kills the process then OnStop event not fired. It...
Read more >
Events not firing when using Seek; works without ... - GitHub
If i use the seek as shown above, the onend events do not fire. If I play without using the seek, then the...
Read more >
Windows Services OnShutDown() event is not firing - C# Corner
I want to create a service which note the time of OS in OnStart event and save that start time and end time...
Read more >
onstop event | stop event JavaScript - Dottoro Web Reference
Occurs when the user aborts the loading of the document. If an onstop event occurs, the onload event is not fired on the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found