]> khamidou — GitHub mirrors - popcorn-js.git/commitdiff
[#t678] fun with sound! idea for mute/unmute
authorScottDowne <sdowne@learn.senecac.on.ca>
Tue, 23 Aug 2011 16:51:35 +0000 (12:51 -0400)
committerScottDowne <sdowne@learn.senecac.on.ca>
Tue, 23 Aug 2011 16:51:35 +0000 (12:51 -0400)
popcorn.js

index 5e8499959cb0f59bde6dd448a208aad8161931ed..06a205170c6943763a7cd1b905904fb5c5858651 100644 (file)
     // 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;
       }
     },
 
     // 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