From 4b6bc1737739ce47c6bb3234cbba4da273e51f97 Mon Sep 17 00:00:00 2001 From: Lanny McNie Date: Thu, 8 Jun 2017 11:19:09 -0600 Subject: [PATCH] Handled empty playProps --- src/soundjs/Sound.js | 6 +++--- src/soundjs/data/PlayPropsConfig.js | 10 ++++++---- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/soundjs/Sound.js b/src/soundjs/Sound.js index 2735c7aa..5fe7a385 100644 --- a/src/soundjs/Sound.js +++ b/src/soundjs/Sound.js @@ -1370,7 +1370,7 @@ this.createjs = this.createjs || {}; var defaultPlayProps = s._defaultPlayPropsHash[instance.src] || {}; if (playProps.interrupt == null) {playProps.interrupt = defaultPlayProps.interrupt || s.defaultInterruptBehavior}; if (playProps.delay == null) {playProps.delay = defaultPlayProps.delay || 0;} - if (playProps.offset == null) {playProps.offset = instance.getPosition();} + if (playProps.offset == null) {playProps.offset = instance.position;} if (playProps.loop == null) {playProps.loop = instance.loop;} if (playProps.volume == null) {playProps.volume = instance.volume;} if (playProps.pan == null) {playProps.pan = instance.pan;} @@ -1698,8 +1698,8 @@ this.createjs = this.createjs || {}; } // Audio is a better candidate than the current target, according to playhead - if ((interrupt == Sound.INTERRUPT_EARLY && target.getPosition() < replacement.getPosition()) || - (interrupt == Sound.INTERRUPT_LATE && target.getPosition() > replacement.getPosition())) { + if ((interrupt == Sound.INTERRUPT_EARLY && target.position < replacement.position) || + (interrupt == Sound.INTERRUPT_LATE && target.position > replacement.position)) { replacement = target; } } diff --git a/src/soundjs/data/PlayPropsConfig.js b/src/soundjs/data/PlayPropsConfig.js index cac0f256..d03b040f 100644 --- a/src/soundjs/data/PlayPropsConfig.js +++ b/src/soundjs/data/PlayPropsConfig.js @@ -153,12 +153,12 @@ this.createjs = this.createjs || {}; * @static */ s.create = function (value) { - if (value instanceof s || value instanceof Object) { + if (value == null || value instanceof s || value instanceof Object) { var ppc = new createjs.PlayPropsConfig(); ppc.set(value); return ppc; - } else { - throw new Error("Type not recognized."); + } else if (value == null) { + throw new Error("PlayProps configuration not recognized."); } }; @@ -175,7 +175,9 @@ this.createjs = this.createjs || {}; * @return {PlayPropsConfig} Returns the instance the method is called on (useful for chaining calls.) */ p.set = function(props) { - for (var n in props) { this[n] = props[n]; } + if (props != null) { + for (var n in props) { this[n] = props[n]; } + } return this; };