title: unity3d webgl mute the sound when tab or browser inactive
body: <p>Does anyone know a proper way to mute the sound in the game when tab or browser is inactive?</p>
  <p>I've tried to do this by <a href="http://jsfiddle.net/jt6cm9ng/" rel="nofollow noreferrer">this</a>(by JS libraries) way</p>
  <pre><code>var hidden, visibilityChange;
  if (typeof document.hidden !== &quot;undefined&quot;) {
      hidden = &quot;hidden&quot;;
      visibilityChange = &quot;visibilitychange&quot;;
  } else if (typeof document.mozHidden !== &quot;undefined&quot;) {
      hidden = &quot;mozHidden&quot;;
      visibilityChange = &quot;mozvisibilitychange&quot;;
  } else if (typeof document.msHidden !== &quot;undefined&quot;) {
      hidden = &quot;msHidden&quot;;
      visibilityChange = &quot;msvisibilitychange&quot;;
  } else if (typeof document.webkitHidden !== &quot;undefined&quot;) {
      hidden = &quot;webkitHidden&quot;;
      visibilityChange = &quot;webkitvisibilitychange&quot;;
  }
  
  document.addEventListener(visibilityChange, handleVisibilityChange, false);
  
  function handleVisibilityChange() {
      $(&quot;video&quot;).prop('muted', document[hidden]);
  }
  </code></pre>
  <p>but its not work for me. Thank you.</p>