Turning off the device between recordings
See original GitHub issueI want to be able to turn off the camera when the user has pressed the stop button (for privacy reasons).
I know, there is a stopDevice method and it works as advertised. It turns off the recording device. So I can call this method after the user clicks the stop button.
But the problem is that if I stop the device and the user clicks record again the recorder stops working. I get an error: DOMException [InvalidStateError: "An attempt was made to use an object that is not, or is no longer, usable" code: 11 nsresult: 0x8053000b
I understand that the MediaRecorder gets destroyed after the device is turned off. But is it possible to reinitialize the recorder somehow?
I also tried manually calling getDevice but it results in all kinds of strange behaviors (not being able to stop the new recording, no play button…).
So is it possible turn the device off and on again somehow between recordings?
Issue Analytics
- State:
- Created 6 years ago
- Comments:11 (8 by maintainers)

Top Related StackOverflow Question
@alsar you can do this:
player.record().stopStream()to stop the devicesplayer.record()._processing = true;(this will block the start button)player.recordToggle.one(['tap', 'click'],getDeviceand set_processingback tofalse(afterdeviceReadyevent fired) so start button works againDoes that work for you? Perhaps it can be a new option,
turnOffDeviceAfterRecord(with a better name of course).Update
this works for me (with v2.0.0):
And adding this functionality behind a new plugin option shouldn’t be too difficult, but what’s a good name…
please open a new ticket with some code that reproduces the problem.