title: Keeping audio player persistently/continuously playing while navigating HTML pages
body: <p>I am using <a href="http://www.alsacreations.fr/dewplayer-en.html" rel="noreferrer">Dewplayer</a> to play a background music on my website.
  I have done the integration and it works fine.</p>
  
  <p>When I click on my next page, the player stops playing the music until and unless I again click to start which restarts the music. My pages are static HTML pages. Below is my code with the link to the files.</p>
  
  <p><strong>The CSS:</strong></p>
  
  <pre><code>#content {
    margin-left:15%;
    width:500px;
    text-align:left;
  }
  #hint {
    color:#666;
    margin-left:15%;
    width:300px;
    text-align:left;
    margin-top:3em;
  }
  </code></pre>
  
  <p><strong>The HTML:</strong></p>
  
  <pre><code>  &lt;a href="link1.html"&gt;Link1&lt;/a&gt;
      &lt;a href="link2.html"&gt;Link2&lt;/a&gt;
      &lt;a href="link3.html"&gt;Link3&lt;/a&gt;
  
  
  
  
  &lt;object type="application/x-shockwave-flash" data="dewplayer-mini.swf?mp3=mp3/test2.mp3" width="160" height="20" id="dewplayer-mini"&gt;&lt;param name="wmode" value="transparent" /&gt;&lt;param name="movie" value="dewplayer-mini.swf?mp3=mp3/test2.mp3" /&gt;&lt;/object&gt;
  </code></pre>
  
  <p>So from the above link, when you click to play the music, the music will be played, but as soon as you click on link2 or link3, it will be stopped. What I need is, that it should be played consistently and continuously irrespective of page navigation. People have suggested me using Frameset, iframes or flash (not the flash audio player), but I am not willing to use them.</p>
  
  <p>I searched a lot of such similar question on Stackoverflow which are as below.</p>
  
  <p><a href="https://stackoverflow.com/questions/18411148/continuous-persistant-audio-players">https://stackoverflow.com/questions/18411148/continuous-persistant-audio-players</a></p>
  
  <p><a href="https://stackoverflow.com/questions/9555250/how-to-keep-audio-playing-while-navigating-through-pages">How to keep audio playing while navigating through pages?</a></p>
  
  <p><a href="https://stackoverflow.com/questions/16210473/audio-player-constant-playing">Audio Player: Constant playing</a></p>
  
  <p>The second one suggested that it can be done with Ajax, but I am creating static pages and don't have a great hand on using Ajax.</p>
  
  <p><strong>PS:</strong> I am open to using any other player which has this functionality.</p>
  
  <p><strong>EDIT : Created the same using jQuery</strong></p>
  
  <p>As people suggested me to use jQuery/JavaScript for flash, I have created the player using jQuery as below. On the demo, the red Square box is stop/pause and Blue is Play.</p>
  
  <p><strong>The HTML:</strong></p>
  
  <pre><code>&lt;audio id="player" src="http://www.soundjay.com/ambient/check-point-1.mp3"&gt;&lt;/audio&gt;
  &lt;a class="soundIcnPlay" title="button" id="button"&gt;&amp;nbsp;&lt;/a&gt;
  </code></pre>
  
  <p><strong>The jQuery Code:</strong></p>
  
  <pre><code>$(document).ready(function() {
      var playing = false;
  
      $('a#button').click(function() {
          $(this).toggleClass("down");
  
          if (playing == false) {
              document.getElementById('player').play();
              playing = true;
              $(this).removeClass('soundIcnPlay');
              $(this).addClass('soundIcnPause');
  
          } else {
              document.getElementById('player').pause();
              playing = false;
              $(this).removeClass('soundIcnPause');
              $(this).addClass('soundIcnPlay');
          }
  
  
      });
  });
  </code></pre>
  
  <p><strong>The CSS:</strong></p>
  
  <pre><code>.soundIcnPlay {
      background: none repeat scroll 0 0 red;
      cursor: pointer;
      display: block;
      height: 100px;
      width: 100px;
  }
  
  .soundIcnPause {
      background: none repeat scroll 0 0 blue;
      cursor: pointer;
      display: block;
      height: 100px;
      width: 100px;
  }
  </code></pre>
  
  <p><strong>The jsFiddle Link:</strong></p>
  
  <p><strong><a href="http://jsfiddle.net/VxpLn/" rel="noreferrer">Audio Demo</a></strong></p>