title: jPlayer playing two media files
body: <p>I am attempting to piece together a jPlayer example that plays two audio files, one right after another.</p>
  
  <p>I need to have full event control, so i decided not to use the playlist option, unless somebody can give me an example of having a way of controlling when the events fire, something like:</p>
  
  <ul>
  <li>first media 'before' function</li>
  <li>first media 'after' function</li>
  <li>second media 'before' function</li>
  <li>second media 'after' function</li>
  </ul>
  
  <p>My example below is using a global variable in the "ended:" function and seems pretty clumsy.  </p>
  
  <p>Does anybody have a better suggestion how i might accomplish this?  here is my working example of using the global variable:</p>
  
  <pre><code>$(document).ready(function(){
      $("#jquery_jplayer_1").jPlayer({
          ready: function (event) {
              console.log('ready function.');
          },
          ended: function()   {
                  console.log('ending function starting.');
                  var player = $("#jquery_jplayer_1");
                  player.jPlayer("stop");
                  player.jPlayer("clearMedia");
                  player.jPlayer("setMedia", { 
                      wav: globalParmTwo
                  }); 
                  player.jPlayer("play", 0);
                  globalParmTwo = null;
          },
          loop:  false,     // added to remove the if condition
          supplied: "wav, oga",
          wmode: "window",
          useStateClassSkin: true,
          autoBlur: false,
          smoothPlayBar: true,
          keyEnabled: true,
          remainingDuration: true,
          toggleDuration: true
      });
  });
  
  var globalParmTwo = null;
  function komPare(parmOne, parmTwo)  {
      globalParmTwo = parmTwo;
      var player = $("#jquery_jplayer_1");
      player.jPlayer("stop");
      player.jPlayer("clearMedia");
      player.jPlayer("setMedia", { 
          wav: parmOne
      }); 
      player.jPlayer("play", 0);
   }
  </code></pre>
  
  <p>And here my working example using the playlist, which seems like a better solution, assuming there is some way to fire specific functions at specific times:</p>
  
  <pre><code>var myPlaylist = null;
  $(document).ready(function(){
  
      myPlaylist = new jPlayerPlaylist({
          jPlayer: "#jquery_jplayer_N",
          cssSelectorAncestor: "#jp_container_N"
      }, []
      , {
          playlistOptions: {
              enableRemoveControls: true
          },
          supplied: "wav, ogv",
          useStateClassSkin: true,
          autoBlur: false,
          smoothPlayBar: true,
          keyEnabled: true,
          audioFullScreen: false
      });
      $('.jp-playlist').hide();
      myPlaylist.option("autoPlay", true);
  });
  
  function komPare(firstMediaUrl, secondMediaUrl) {
      myPlaylist.setPlaylist([
          { wav: firstMediaUrl },
          { wav: secondMediaUrl }
      ]);
  };
  </code></pre>
  
  <p>any suggestions are very appreciated.</p>
  
  <p>UPDATE:  i removed an if-condition and put in "loop: false," instead in the first example.</p>