weixin_39880615 2020-11-22 04:49
浏览 0

Set video state after project load

Resolves

Fixes #1635, fixes #1062, partially #1715 with a test for whether the videoSensing extension loads

Proposed Changes

This PR does a few things: - Checks the stage target after the project has loaded and sets the project's videoOn and videoTransparency accordingly. - Makes the check for this._drawable more specific in video.js. Since its default value is -1, it evaluated to truthy even when it shouldn't have. This was causing some issues when I was writing a test for the video state since (!this._drawable) evaluated to true and the video device thought a renderer should be present. - Arranges the load-extensions test project files in subdirectories now that we have multiple tests in load-extensions.js

Reason for Changes

Previously the check for the stage's video properties was done before targets were installed, so the stage target's info wasn't available. Now with the PROJECT_LOADED event, we can wait until later to check the stage and get the info we need to correctly set the project's video values.

Test Coverage

I've added some tests for whether the video is on and the video's transparency in load-extensions.js. There doesn't appear to be a flag or property indicating the video io device has been turned on in the same way that _ghost stores the transparency value, so I used the definition of the mirror property as a proxy for that information. Let me know if I should check whether the video is on another way though!

该提问来源于开源项目:LLK/scratch-vm

  • 写回答

5条回答 默认 最新

  • weixin_39880615 2020-11-22 04:49
    关注

    thanks for noticing that, I agree it would be best not to have the camera turn on at all if you're not expecting it to! I was able to prevent this by changing the line you pointed out and by enabling the video based on the project's videoState in the getInfo function, whereas previously it enabled it on all cases.

    One thing that was tricky is that these changes prevented the camera from turning on when a user first adds the video sensing extension in the UI, which is something I believe we do want. I tracked it down to an inconsistent default videoState value in the scratch-gui, and I have a PR in to fix that: https://github.com/LLK/scratch-gui/pull/3817 . So we should probably wait to merge this PR into the VM until after this is updated in the GUI.

    评论

报告相同问题?