mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2024-12-23 14:32:59 -05:00
Ensure music extension _decodeSound is promise
Currently if there is no audio engine detected this returns undefined, which in turn causes the line above to fail trying to call `.then` on it.
This commit is contained in:
parent
cc2bf1dfc7
commit
1d414dd5a0
1 changed files with 4 additions and 3 deletions
|
@ -125,10 +125,11 @@ class Scratch3MusicBlocks {
|
|||
* @return {Promise} - a promise which will resolve once the sound has decoded.
|
||||
*/
|
||||
_decodeSound (soundBuffer) {
|
||||
if (!this.runtime.audioEngine) return;
|
||||
if (!this.runtime.audioEngine.audioContext) return;
|
||||
const context = this.runtime.audioEngine && this.runtime.audioEngine.audioContext;
|
||||
|
||||
const context = this.runtime.audioEngine.audioContext;
|
||||
if (!context) {
|
||||
return Promise.reject(new Error('No Audio Context Detected'));
|
||||
}
|
||||
|
||||
// Check for newer promise-based API
|
||||
if (context.decodeAudioData.length === 1) {
|
||||
|
|
Loading…
Reference in a new issue