title: Using a variable in the new media javascript object
body: <p>I am actually really hoping this is a noob question. Have looked around and tried for about an hour for a solution to this but I'm getting nowhere.</p>
  
  <p>Real simple. I am using Cordova to build Android App. I am going through my code and trying to clean it up and make it more reusable.</p>
  
  <p>I have several views/pages that play audio files. I am using the Cordova media api as HTML5 audio is not well supported.</p>
  
  <p>Anyway, I use JQuery to get the ID of heading tag and then combine it with another string to make a variable. Then I am trying to use that variable to be the source for a "new Media" object. I am definitely missing something here, because it is not working and is returning null. My code is pasted below:</p>
  
  <pre><code>var playing = 0;
  var myMedia = null;
  var mySound = $("h3").attr("id");
  var soundPath = "/android_asset/www/audio/"+mySound+".mp3";
  myMedia = new Media('"'+soundPath+'"', stopAudio);
  
  function playAudio() {
  switch (playing) {
      case 0: 
       myMedia.play();
       document.getElementById('play').src = "../icons/pause-btn-grey@2x.png";
       playing = 1;
       break;
  
      case 1:
        myMedia.pause();
        document.getElementById('play').src = "../icons/play-btn-grey@2x.png";
        playing = 0;
      break;
  }
  </code></pre>
  
  <p>I would really appreciate if someone could point me in the right direction. I am sure it is something I have overlooked but cannot "see the wood from the trees".</p>