Skip to content

Commit

Permalink
Update src/ui/backend/sound/HTML5API.js
Browse files Browse the repository at this point in the history
Cleanup code with a local variable and some comments.  Only toggle the muted state if the item is muted.
  • Loading branch information
Martin Hunt committed Feb 20, 2013
1 parent 07c1e2b commit b98a570
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/ui/backend/sound/HTML5API.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,11 +151,17 @@ var MultiSound = Class(function () {
this._isPaused = false;
}

this._currentSource = this._getRandom();
this._currentSource.loop = opts.loop || this.isBackgroundMusic;
this._currentSource.play();
this._currentSource.muted = !this._currentSource.muted;
this._currentSource.muted = !this._currentSource.muted;
var src = this._getRandom();
src.loop = opts.loop || this.isBackgroundMusic;
src.play();

if (src.muted) {
// Chrome bug? Audio objects with muted set before they
// are played won't be muted, so toggle the mute state
// twice after calling play.
src.muted = false;
src.muted = true;
}
};

this._getRandom = function () {
Expand Down

0 comments on commit b98a570

Please sign in to comment.