Skip to content

Commit

Permalink
Handled empty playProps
Browse files Browse the repository at this point in the history
  • Loading branch information
lannymcnie committed Jun 8, 2017
1 parent ae744ad commit 4b6bc17
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
6 changes: 3 additions & 3 deletions src/soundjs/Sound.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;}
Expand Down Expand Up @@ -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;
}
}
Expand Down
10 changes: 6 additions & 4 deletions src/soundjs/data/PlayPropsConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.");
}
};

Expand All @@ -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;
};

Expand Down

0 comments on commit 4b6bc17

Please sign in to comment.