From: ScottDowne Date: Tue, 23 Aug 2011 16:51:35 +0000 (-0400) Subject: [#t678] fun with sound! idea for mute/unmute X-Git-Tag: v0.8^2~18^2~1 X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=50a253a38704c6329fea0600a06eceead88fff2a;p=popcorn-js.git [#t678] fun with sound! idea for mute/unmute --- diff --git a/popcorn.js b/popcorn.js index 5e84999..06a2051 100644 --- a/popcorn.js +++ b/popcorn.js @@ -505,18 +505,18 @@ // Mute the calling media, optionally toggle mute: function( toggle ) { - var event = toggle == null ? "muted" : "unmuted"; + var event = toggle == null || toggle === true? "muted" : "unmuted"; // If `toggle` is explicitly `false`, // unmute the media and restore the volume level - if ( toggle === false ) { + if ( event === "unmuted" ) { this.media.muted = false; this.media.volume = this.data.state.volume; } // If `toggle` is either null or undefined, // save the current volume and mute the media element - if ( toggle == null ) { + if ( event === "muted" ) { this.data.state.volume = this.media.volume; this.media.muted = true; } @@ -528,8 +528,9 @@ }, // Convenience method, unmute the calling media - unmute: function() { - return this.mute( false ); + unmute: function( toggle ) { + + return this.mute( toggle == null ? false : !toggle ); }, // Get the client bounding box of an instance element