-
-
Notifications
You must be signed in to change notification settings - Fork 312
Closed
Labels
Description
Description
Users improperly using videojs-record with external triggers(user defined buttons) might call
player.record().getDevice();
multiple times before trying to use stopDevice()
.
In this case multiple media streams would get created but only the last one would be freed when calling stopDevice()
The implication would be that the webcam would remain on even after stopDevice()
is called.
When would this situation be encountered?
Eg: let's say the user creates an external button "start webcam" which calls getDevice,
but doesn't handle thoroughly the state of the system to see if it is actually ok to call getDevice.
Someone visiting the website might press that button multiple times
(maybe he doesn't notice the the request for video/audio permissions) after the first press.
Potential way to add an extra safeguard
Before
//videojs.record.js
value: function onDeviceReady(stream) {
....
// At this point this.stream could already be initialized,
// if the user didn't properly dispose of it the resource would never be released.
// ( the webcam would remain on after player.record().stopDevice() ).
this.stream = stream;
With a safeguard things could look something like:
//videojs.record.js
value: function onDeviceReady(stream) {
....
if stream_is_initialized(this) {
this.stream.getTracks().forEach(track => track.stop());
}
this.stream = stream;