mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2024-12-24 06:52:40 -05:00
_singleSetup makes more sense
This commit is contained in:
parent
c10696f88c
commit
da05e673fa
1 changed files with 6 additions and 5 deletions
|
@ -126,8 +126,8 @@ class Video {
|
||||||
* @return {Promise} When video has been received, rejected if video is not received
|
* @return {Promise} When video has been received, rejected if video is not received
|
||||||
*/
|
*/
|
||||||
_setupVideo () {
|
_setupVideo () {
|
||||||
if (this._lastSetup) {
|
if (this._singleSetup) {
|
||||||
return this._lastSetup;
|
return this._singleSetup;
|
||||||
}
|
}
|
||||||
|
|
||||||
this._video = document.createElement('video');
|
this._video = document.createElement('video');
|
||||||
|
@ -149,17 +149,18 @@ class Video {
|
||||||
resolve(this._video);
|
resolve(this._video);
|
||||||
}, err => {
|
}, err => {
|
||||||
// There are probably some error types we could handle gracefully here.
|
// There are probably some error types we could handle gracefully here.
|
||||||
this._lastSetup = null;
|
this._singleSetup = null;
|
||||||
reject(err);
|
reject(err);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
return video.then(() => this._setupPreview());
|
this._singleSetup = video.then(() => this._setupPreview());
|
||||||
|
return this._singleSetup;
|
||||||
}
|
}
|
||||||
|
|
||||||
_disableVideo () {
|
_disableVideo () {
|
||||||
this._disablePreview();
|
this._disablePreview();
|
||||||
this._lastSetup = null;
|
this._singleSetup = null;
|
||||||
// by clearing refs to video and track, we should lose our hold over the camera
|
// by clearing refs to video and track, we should lose our hold over the camera
|
||||||
this._video = null;
|
this._video = null;
|
||||||
this._track = null;
|
this._track = null;
|
||||||
|
|
Loading…
Reference in a new issue