mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2025-08-28 22:30:40 -04:00
Reduce indentation waterfall
This commit is contained in:
parent
f3a956af2b
commit
9cd5e4da2b
1 changed files with 20 additions and 14 deletions
|
@ -100,26 +100,32 @@ class Video {
|
||||||
*/
|
*/
|
||||||
disableVideo () {
|
disableVideo () {
|
||||||
this.enabled = false;
|
this.enabled = false;
|
||||||
// If we have begun a setup process, wait for it to complete
|
// If we have begun a setup process, call _teardown after it completes
|
||||||
if (this._singleSetup) {
|
if (this._singleSetup) {
|
||||||
this._singleSetup
|
this._singleSetup
|
||||||
.then(() => {
|
.then(this._teardown.bind(this))
|
||||||
// we might be asked to re-enable before setup completes
|
|
||||||
if (!this.enabled) {
|
|
||||||
this._disablePreview();
|
|
||||||
this._singleSetup = null;
|
|
||||||
// by clearing refs to video and track, we should lose our hold over the camera
|
|
||||||
this._video = null;
|
|
||||||
if (this._track) {
|
|
||||||
this._track.stop();
|
|
||||||
}
|
|
||||||
this._track = null;
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.catch(() => {});
|
.catch(() => {});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* async part of disableVideo
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
_teardown () {
|
||||||
|
// we might be asked to re-enable before _teardown is called, just ignore it.
|
||||||
|
if (this.enabled === false) {
|
||||||
|
this._disablePreview();
|
||||||
|
this._singleSetup = null;
|
||||||
|
// by clearing refs to video and track, we should lose our hold over the camera
|
||||||
|
this._video = null;
|
||||||
|
if (this._track) {
|
||||||
|
this._track.stop();
|
||||||
|
}
|
||||||
|
this._track = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return frame data from the video feed in a specified dimensions, format, and mirroring.
|
* Return frame data from the video feed in a specified dimensions, format, and mirroring.
|
||||||
* @return {ArrayBuffer|Canvas|string|null} Frame data in requested format, null when errors.
|
* @return {ArrayBuffer|Canvas|string|null} Frame data in requested format, null when errors.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue