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
|
||||
*/
|
||||
_setupVideo () {
|
||||
if (this._lastSetup) {
|
||||
return this._lastSetup;
|
||||
if (this._singleSetup) {
|
||||
return this._singleSetup;
|
||||
}
|
||||
|
||||
this._video = document.createElement('video');
|
||||
|
@ -149,17 +149,18 @@ class Video {
|
|||
resolve(this._video);
|
||||
}, err => {
|
||||
// There are probably some error types we could handle gracefully here.
|
||||
this._lastSetup = null;
|
||||
this._singleSetup = null;
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
|
||||
return video.then(() => this._setupPreview());
|
||||
this._singleSetup = video.then(() => this._setupPreview());
|
||||
return this._singleSetup;
|
||||
}
|
||||
|
||||
_disableVideo () {
|
||||
this._disablePreview();
|
||||
this._lastSetup = null;
|
||||
this._singleSetup = null;
|
||||
// by clearing refs to video and track, we should lose our hold over the camera
|
||||
this._video = null;
|
||||
this._track = null;
|
||||
|
|
Loading…
Reference in a new issue