title: Stop/Play audio on focusout/focusin on mobile browser
body: <p>I simply try to play an audio file on the client if the page lost its focus, e.g. if the user switched to another tab or if the user minimized the browser.</p>
  
  <p>I was able to solve it with this code and it works for me on desctop browsers.</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
      &lt;title&gt;Audio - Minimize Test&lt;/title&gt;
      &lt;script src="https://code.jquery.com/jquery-2.2.3.min.js"&gt;&lt;/script&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
      &lt;h1&gt;Test&lt;/h1&gt;
      &lt;script&gt;
  
          var audio = new Audio('test.mp3');
  
          $(window).focusout
          (
              function()
              {
                  $("body").css("background-color", "red");
                  audio.play();
              }
          );
  
          $(window).focusin
          (
              function()
              {
                  $("body").css("background-color", "#FFFFFF");
                  audio.pause();
              }
          );
      &lt;/script&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Now i try to make it work on mobile browsers too, if the user presses the "home" button on the smartphone (minimize the browser) to switch to his main menu, then the soundfile should play. </p>
  
  <p>I tested it on my windows phone, but no sound plays if i press the "home" button. Does someone know if this is possible yet?</p>
  
  <p>Maybe this could help too: <a href="https://www.w3.org/TR/page-visibility/" rel="nofollow">https://www.w3.org/TR/page-visibility/</a></p>