Chrome browser extension to enable streaming of video and data to MakeCode via the libs/video common package. To include this package in your Arcade project, add "video": "*" to pxt.json's dependencies section.
- Download athe latest
makecode-data-pipe.zipfrom the releases page https://github.com/eanders-MS/pxt-data-pipe/releases. - Unzip the downloaded extension to a suitable location.
- In Chrome, open the extension management page by navigating to
chrome://extensions. - Enable developer mode if necessary by clicking the toggle switch next to Developer mode.
- Uninstall the previous version, if it's installed.
- Click the LOAD UNPACKED button and select the folder where you unzipped the extension.
NodeJS&NPMinstalled (nodejs.org).yarn, installed globally:npm install -g yarn
IMPORTANT: This repository uses yarn for dependency management. npm will not work! Running scripts with npm (e.g. npm run build) is safe (though yarn can do this too: yarn build).
Run yarn install in the repo root to install dependencies for all projects.
The extension consists of multiple projects that get individually webpacked, but all are built in a single pass.
- Option 1: To make a development build that watches for changes and rebuilds on-the-fly: Run
yarn watchinpackages/browser-extensionfolder. - Option 2: To make a production build: Run
yarn buildinpackages/browser-extensionfolder.
Special note: These projects depend on a shared library:
packages/browser-extension/common
When running yarn watch, code changes in shared libraries are not automatically picked up and must be manually rebuilt. There are two ways to do this:
- Stop and restart
yarn watch. - Run
yarn buildin the shared lib folder. Once this is done, the activeyarn watchprocess will pick up the changes.
- In Chrome, open the extension management page by navigating to
chrome://extensions. - Enable developer mode if necessary by clicking the toggle switch next to Developer mode.
- Click the LOAD UNPACKED button and select the
packages/browser-extension/distfolder.
Note: Whenever the extension is rebuilt, it must be reloaded in Chrome via the "reload" button.
Note: Whenever the extension is reloaded, its connection to existing MakeCode tabs is broken. This is a feature/limitation of Chrome with no straightforward workaround. Refresh these pages to reconnect them to the extension.
Verify the browser extension is loaded. If you don't need to develop in the extension, installing the pre-built version is much simpler than building from source.
- Follow the install steps above.
- In Chrome, look for the extension with the MakeCode icon.
- Click the icon. A window should appear enumerating your webcams.
On the Arcade side, video stream funtionality is in located in the libs/video package. This package isn't shipped with production Arcade. It exists in the eanders/video-streams branch of the different repos the comprise MakeCode, which are:
- https://github.com/microsoft/pxt/ (master branch)
- https://github.com/microsoft/pxt-common-packages (eanders/video-streams branch)
- https://github.com/microsoft/pxt-arcade (eanders/video-streams branch)
- https://github.com/microsoft/pxt-arcade-sim (eanders/video-streams branch)
-
Sync these branches and symlink all the folders.
-
In
pxt-common-packages/:$> npm link ../pxt
-
In
pxt-arcade-sim/:$> npm link ../pxt$> npm link ../pxt-common-packages
-
In
pxt-arcade/:$> npm link ../pxt$> npm link ../pxt-common-packages$> npm link ../pxt-arcade-sim
-
-
In
pxt/: run$> gulp watch
-
In
pxt-arcade/: run$> pxt serve --rebundle
-
Wait for Arcade to open in the browser.
-
Start a new project and add the
videopackage topxt.json's dependencies. A new "Video" toolbox category should appear. -
Write some code that uses the video blocks. Something like this is a good quick test:
let frame: Image = null forever(function () { frame = video.getCurrentFrame(0) video.setPaletteFromStream(0) scene.setBackgroundImage(frame) })
-
Open the extension UI, if not already open. Your MakeCode tab should be listed. If not there, refresh the MakeCode page.
-
Start a camera.
-
Enable that camera for your MakeCode tab. You should see the video feed in the Arcade simulator.