From 271a19c05dd686f4fc0852d35cf4ad5c6c62d1b3 Mon Sep 17 00:00:00 2001 From: Karishma Chadha Date: Thu, 26 Apr 2018 19:17:41 -0400 Subject: [PATCH] Add runtime/render related functionality back to VM. --- src/io/video.js | 137 ++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 110 insertions(+), 27 deletions(-) diff --git a/src/io/video.js b/src/io/video.js index 70b753908..e65edbe65 100644 --- a/src/io/video.js +++ b/src/io/video.js @@ -1,7 +1,42 @@ class Video { constructor (runtime) { this.runtime = runtime; + + /** + * @typedef VideoProvider + * @property {Function} enableVideo - Requests camera access from the user, and upon success, + * enables the video feed + * @property {Function} disableVideo - Turns off the video feed + * @property {Function} getFrame - Return frame data from the video feed in + * specified dimensions, format, and mirroring. + */ this.provider = null; + + /** + * Id representing a Scratch Renderer skin the video is rendered to for + * previewing. + * @type {number} + */ + this._skinId = -1; + + /** + * The Scratch Renderer Skin object. + * @type {Skin} + */ + this._skin = null; + + /** + * Id for a drawable using the video's skin that will render as a video + * preview. + * @type {Drawable} + */ + this._drawable = -1; + + /** + * Store the last state of the video transparency ghost effect + * @type {number} + */ + this._ghost = 0; } static get FORMAT_IMAGE_DATA () { @@ -29,6 +64,14 @@ class Video { return 1; } + /** + * Set a video provider for this device. + * @param {VideoProvider} provider - Video provider to use + */ + setProvider (provider) { + this.provider = provider; + } + /** * Request video be enabled. Sets up video, creates video skin and enables preview. * @@ -37,8 +80,8 @@ class Video { * @return {Promise.