From dcdc2c08317e5542414ee38e70e6dc2041e9f2d7 Mon Sep 17 00:00:00 2001 From: Eric Rosenbaum Date: Tue, 31 Jan 2017 18:36:29 -0500 Subject: [PATCH] check for non-existent sound --- src/index.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/index.js b/src/index.js index ab8ceed..a2f5f3d 100644 --- a/src/index.js +++ b/src/index.js @@ -143,6 +143,11 @@ function AudioPlayer (audioEngine) { } AudioPlayer.prototype.playSound = function (md5) { + // if this sound is not in the audio engine, return + if (!this.audioEngine.audioBuffers[md5]) { + return; + } + // if this sprite or clone is already playing this sound, stop it first if (this.activeSoundPlayers[md5]) { this.activeSoundPlayers[md5].stop();