title: How to close html5 video and flash alternative without it sometimes playing audio in the background?
body: <p>Sometimes when I click on the "close" button( before the video loads up) the audio of the video still plays in the background? I am closing the video with this code: </p>
  
  <pre><code>$(document).ready(function() {          
      var a = $
      a("img").click(function() {
      a("#trailer").fadeOut(300)
          a("video").remove();
  </code></pre>
  
  <p>more code: </p>
  
  <pre><code>&lt;div id="trailer"&gt;
  &lt;img id="close" src="images/close.png" alt="close" /&gt;
  &lt;div id="video"&gt;
  &lt;video controls  autoplay="autoplay" poster="video/trailer.jpg" width="600"  onclick="if(/Android/.test(navigator.userAgent))this.play();"&gt;
  &lt;source src="video/trailer.mp4" type="video/mp4" /&gt;
  &lt;source src="video/trailer.webm" type="video/webm" /&gt;
  &lt;source src="video/trailer.ogv" type="video/ogg" /&gt;
  &lt;embed src="video/flashfox.swf" width="600" height="480"  flashVars="autoplay=true&amp;amp;controls=true&amp;amp;loop=true&amp;amp;src=trailer.mp4" allowFullScreen="true" wmode="transparent" type="application/x-shockwave-flash" pluginspage="http://www.adobe.com/go/getflashplayer_en" /&gt;
  &lt;/video&gt;
  &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>Thanks! </p>
  
  <p>EDIT</p>
  
  <p>Code doesn't work in this segment.</p>
  
  <pre><code>    a("#trailerb").click(function() {
          a("video")[0].pause().remove();
          a("#trailer").show("50");
          a("#video").load("video.html");
  </code></pre>
  
  <p>What should happen is on click any video playing, pauses and removes from view, then a fresh new video pops us from the .load method: here is the code from the video.html </p>
  
  <pre><code>&lt;video controls="controls"  autoplay="autoplay" poster="video/trailer.jpg" width="600"  height=""  onclick="if(/Android/.test(navigator.userAgent))this.play();"&gt;
  &lt;source src="video/trailer.mp4" type="video/mp4" /&gt;
  &lt;source src="video/trailer.webm" type="video/webm" /&gt;
  &lt;source src="video/trailer.ogv" type="video/ogg" /&gt;
  &lt;embed src="video/flashfox.swf" width="600" height="480"  flashVars="autoplay=true&amp;amp;controls=true&amp;amp;loop=true&amp;amp;src=trailer.mp4" allowFullScreen="true" wmode="transparent" type="application/x-shockwave-flash" pluginspage="http://www.adobe.com/go/getflashplayer_en" /&gt;
  &lt;/video&gt;
  </code></pre>
  
  <p>At the moment clicking on "#trailerb" only pauses any video playing, without executing:</p>
  
  <pre><code>a("#trailer").show("50");
  a("#video").load("video.html");
  </code></pre>
  
  <p>Thanks for your time!!! </p>