title: MP3 Flash Fallback on Opera & FireFox using MediaElement.js
body: <p>I'm trying to add mediaelement.js to my site to present a single player for any MP3 link on a particular page.  The design is working fine for IE 9 and Chrome 11 (which have HTML5 MP3 support), but it has an issue with the flash fallback on Opera 11 and FireFox 4.  Clicking any MP3 link on the page uses the <strong>.setSrc()</strong> method of media element player to change the source of the player, but in Opera and FF, the first time this method is called, it returns error "<strong>this.media.setSrc is not a function</strong>".  Any call to the function after that works fine.</p>
  
  <p>Another issue is after the element containing the player is hidden "display:none" and then displayed again, calling the <strong>.pause()</strong> function will produce error "<strong>this.pluginApi.pauseMedia is not a function</strong>".  After that error is thrown, subsequent calls work fine until the element is hidden and displayed again.</p>
  
  <p>Here's the relevant code, and any help would be very much appreciated.</p>
  
  <pre><code>&lt;script type="text/javascript" src="../js/mejs/mediaelement-and-player.min.js"&gt;&lt;/script&gt;
  &lt;script type="text/javascript" src="../js/media.js"&gt;&lt;/script&gt;
  &lt;div id="mediaPlayerFooter" class="mediaPlayerWrapper"&gt;
      &lt;div id="mediaPlayer"&gt;
          &lt;audio id="mp3Player" src="mp3/null.mp3" autoplay="autoplay" type="audio/mp3"&gt;&lt;/audio&gt;  
      &lt;/div&gt;
      &lt;div id="closeButtonWrapper"&gt;&lt;p&gt;&lt;a id="closeButton" href="#close"&gt;Close&lt;/a&gt;&lt;/p&gt;&lt;/div&gt;
  &lt;/div&gt;
  
  $(function() {
      // Show the footer, load the MP3 file, and play.
      $("a[href*='.mp3']").click(function(e) {
          e.preventDefault();
          PlayMP3($(this).prop('href'));
      }); 
  
      // Stop the MP3 playback and close the footer.
      $('#closeButton').click(function(e) {
          e.preventDefault();
          ClosePlayer();
      });
  });
  function CreatePlayer() {
      var player = new MediaElementPlayer('#mp3Player',{
          audioWidth: 250, 
          startVolume: 1.0
      });
      return player;
  }
  function PlayMP3(sourceUrl){
      $('#mediaPlayerFooter').slideDown(750);
      var player = CreatePlayer();
      try {
          player.pause();
          player.setSrc(sourceUrl);
          player.load();
          player.play();
      }
      catch(err)
      {
          txt="There was an error loading the MP3.  ";
          txt+="Error message: " + err.message;
          console.log(txt);
      }
  }
  function ClosePlayer(){
      var player = CreatePlayer();
      player.pause();
      $('#mediaPlayerFooter').slideUp(750);
  }
  </code></pre>