From f5044dc25450534e249f7ba02fb99a7b24ba3205 Mon Sep 17 00:00:00 2001 From: Ray Schamp <ray@scratch.mit.edu> Date: Mon, 14 Aug 2017 17:19:43 -0400 Subject: [PATCH] Instantiate AudioEngine in GUI This way a stage is not necessary for sound blocks to work --- src/containers/gui.jsx | 3 +++ src/containers/stage.jsx | 3 --- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/containers/gui.jsx b/src/containers/gui.jsx index 87f195aab..ed1fe28ea 100644 --- a/src/containers/gui.jsx +++ b/src/containers/gui.jsx @@ -1,3 +1,4 @@ +import AudioEngine from 'scratch-audio'; import PropTypes from 'prop-types'; import React from 'react'; import VM from 'scratch-vm'; @@ -16,6 +17,8 @@ class GUI extends React.Component { this.state = {tabIndex: 0}; } componentDidMount () { + this.audioEngine = new AudioEngine(); + this.props.vm.attachAudioEngine(this.audioEngine); this.props.vm.loadProject(this.props.projectData); this.props.vm.setCompatibilityMode(true); this.props.vm.start(); diff --git a/src/containers/stage.jsx b/src/containers/stage.jsx index d9ab05f12..219d83a70 100644 --- a/src/containers/stage.jsx +++ b/src/containers/stage.jsx @@ -2,7 +2,6 @@ import bindAll from 'lodash.bindall'; import PropTypes from 'prop-types'; import React from 'react'; import Renderer from 'scratch-render'; -import AudioEngine from 'scratch-audio'; import VM from 'scratch-vm'; import StageComponent from '../components/stage/stage.jsx'; @@ -37,8 +36,6 @@ class Stage extends React.Component { this.updateRect(); this.renderer = new Renderer(this.canvas); this.props.vm.attachRenderer(this.renderer); - this.audioEngine = new AudioEngine(); - this.props.vm.attachAudioEngine(this.audioEngine); } shouldComponentUpdate (nextProps) { return this.props.width !== nextProps.width || this.props.height !== nextProps.height; -- GitLab