mozmorris/react-webcam

Question: Is it possible to update `facingMode` without re-rendering Webcam?

bfaulk96 opened this issue · 2 comments

Please follow the general troubleshooting steps first:

Question

This is more a general inquiry, not a bug (and perhaps depending on the answer, a feature request?).

I have react-webcam set up in my app and working on multiple browsers and devices. I also have a mechanism set up to switch between user and environment cameras (after checking that both exist) prior to recording, by updating videoConstraints={{ ...videoConstraints, facingMode }}. Unfortunately, while this works great prior to recording, changing this setting mid-recording causes the Webcam component to re-render, which stops the recording.

This brings me to two questions

  1. Is it possible to use the underlying media recorder ref or webcam ref to update facingMode on the fly, without re-rendering the component? I've tried several things and cannot seem to get that to happen.
  2. Is this a feature that could be built into this library? I.e. instead of re-rendering, just updating the props of the media recording potentially?

Thank you for your work on this library, and for reading my questions! 😄

@bfaulk96 did you ever find a solution to this?

Nope, unfortunately not. My solution was to show a loading symbol while the camera re-initializes, and disable facing mode switching once you'd already started recording (since switching ended the video)