fix:avoid unexpected value of videoState

This commit is contained in:
QinXianSheng 2024-01-22 18:10:25 +08:00 committed by GitHub
parent 5cf2de9eef
commit f30e1e3418
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -566,7 +566,7 @@ class Scratch3VideoSensingBlocks {
* @param {VideoState} args.VIDEO_STATE - the video state to set the device to
*/
videoToggle (args) {
const state = args.VIDEO_STATE;
const state = Object.values(VideoState).includes(args.VIDEO_STATE) ? args.VIDEO_STATE : VideoState.OFF;
this.globalVideoState = state;
if (state === VideoState.OFF) {
this.runtime.ioDevices.video.disableVideo();