title: Building custom mp3 player for website - can't figure out how to write play last song, play next song functions
body: <p>I am building an mp3 player on my site, ustreet.com, that can be controlled by custom buttons that I have put in my HTML. </p>
  
  <p>Here is a picture of what it looks like: </p>
  
  <p><img src="https://i.stack.imgur.com/yiSzN.png" alt="enter image description here"></p>
  
  <p>JSript has built-in audio object controls for playing and pausing, and I've figured those out, as you can see:</p>
  
  <pre><code>                &lt;div class = "mp3Player" style="display: inline-block; width:100%"&gt;
  
                      &lt;audio id="music" src = "LetsDance.mp3" type = "audio/mp3"&gt;&lt;/audio&gt;   
  
                      &lt;a class = "last" style="margin-left: 1em; float: left; display: inline-block; vertical-align:158%; -moz-transform:rotate(180deg); -webkit-transform:rotate(180deg); -o-transform:rotate(180deg); -ms-transform:rotate(180deg); font-size: 100%" onclick="previous()" class="button"&gt;►►&lt;/a&gt;                    
                      &lt;a class = "play" style="display: inline-block; vertical-align:134%;" onclick="music.play()" class="button"&gt;►&lt;/a&gt;
                      &lt;a class = "pause" style="font-weight: bold; display: inline-block; vertical-align:134%;" onclick="music.pause()" class="button"&gt;ll&lt;/a&gt;
                      &lt;a class = "next" style="margin-right: 1em; float: right; display: inline-block; vertical-align:145%; font-size: 100%" onclick = "next()" class="button"&gt;►►&lt;/a&gt;                       
  
                  &lt;/div&gt;
  </code></pre>
  
  <p>I have an array of mp3 file source names also:</p>
  
  <pre><code> mp3sources = ["a.mp3","b.mp3","c.mp3","d.mp3"];
  </code></pre>
  
  <p>I am trying to figure out how to write a function that syncs the audio object being called by these buttons with this array. When the site is first loaded, the play button will cue the first string in mp3sources. Clicking the next button will cue the next song in the list to play, and clicking the last song will cue the previous song from the array. Please help me write this function - I'm not too good at JScript. I am better at PHP. </p>