Triggering stop recording in webcam

I’m using Uppy with Webcam plugin in my Vue project and was wondering if there is a way to automatically stop recording after some time.

It isn’t build-in but you could try adding a event listener to the button and then do something like this:

function onStartRecording() {
  setTimeout(() => uppy.getPlugin('Webcam').stopRecording(), 5000)
}

Alternatively, fork the plugin and add the functionality yourself.

Thank you very much! That looks very easy and straightforward.

As a follow up - is there a way to hook into start recording event or something like that or do I need to overwrite startRecording method of Webcam to add setTimeout?

We don’t expose the events from webcam unfortunately. So you would have to do a querySelector to get the button and add the event listener to it. If you are forking the webcam plugin, you could change the startRecording function to your liking.

1 Like