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.

Turning off the device between recordings

See original GitHub issue

I 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:closed
  • Created 6 years ago
  • Comments:11 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
thijstriemstracommented, Oct 5, 2017

@alsar you can do this:

  • after stop record is pressed: player.record().stopStream() to stop the devices
  • set processing to true: player.record()._processing = true; (this will block the start button)
  • listen for record btn click once: player.recordToggle.one(['tap', 'click'],
  • and in that callback handler you call getDevice and set _processing back to false (after deviceReady event fired) so start button works again

Does 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):

// user clicked the stop record button
player.on('stopRecord', function() {

        // user completed recording and stream is available
	player.one('finishRecord', function() {

	    console.log('stopped recording, turning off devices...');

	    // stop device stream only
	    player.record().stopStream();

	    player.recordToggle.one(['click', 'tap'], function() {
	        // start device and recording
	        player.record().getDevice();
	    });
	});

});

And adding this functionality behind a new plugin option shouldn’t be too difficult, but what’s a good name…

0reactions
thijstriemstracommented, Jul 18, 2019

please open a new ticket with some code that reproduces the problem.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to stop your phone and other devices from listening to ...
To listen to your Google recordings, log in to the “My Activity” page, filter by “Date & Product,” choose “Voice & Audio” and...
Read more >
How to stop all your smart devices from listening to you
Tap Device Settings followed by Video Settings. Tap on the Audio Streaming and Recording toggle to turn off the mic. Your smart TV....
Read more >
How to Turn Off the Listening Settings on Your Smart Devices
Then either check or uncheck the box next to the "include voice and audio activity" setting to turn it on or off. "When...
Read more >
How to Stop Google From Listening - MakeUseOf
Turn Off Microphone Access for the Google App · Open Settings on your phone and select Apps & notifications (on Android 12, this...
Read more >
How To Make Sure Your Phone Isn't Keeping Recordings of ...
We may earn a commission from links on this page. ... You can turn off audio recordings in your Google activity history. Screenshot:...
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