title: Audio Playlist in HTML
body: <p><strong>I Just solved it, thanks to everyone.</strong></p>
  
  <p>I'm trying to understand how to do Audio Playlists in html so I tried to follow the tutorial in here: <a href="https://www.youtube.com/watch?v=vtZCMTtP-0Y" rel="nofollow noreferrer">https://www.youtube.com/watch?v=vtZCMTtP-0Y</a> (code presented below), to achieve my goal. The only problem is that it doesn't work, when a song ends it returns always to the second song on the list, also the console tells me there's a "Uncaught (in promise) DOMException", that I don't know how to solve. </p>
  
  <pre><code>function audioPlayer() {
      var currentSong = 0;
      $("#audioPlayer")[0].src = $("playlist li a")[0];
      $("#audioPlayer")[0].play();
      $("#playlist li a").click(function(e) {
          e.preventDefault();
          $("#audioPlayer")[0].src = this;
          $("#audioPlayer")[0].play();
          $("#playlist li").removeClass("current-song");
          currentSong = $(this).parent().index();
          $(this).parent().addClass("current-song");
      });
  
      $("#audioPlayer")[0].addEventListener("ended", function() {
          currentSong++;
          if (currentSong == $("#playlist li a").length) {
              currentSong = 0;
          }
          $("#playlist li").removeClass("current-song");
          $("#playlist li:eq(" + currentSong + ")").addClass("current-song");
          $("#audioPlayer")[0].src = $("#playlist li a")[currentSong].href;
          $("#audioPlayer")[0].play();
      });
  }
  </code></pre>
  
  <p>Also, with css I tried to make the name of the song that is playing blue, but what happens is that all the name of the songs i click get blue, instead of just the one playing. </p>
  
  <pre><code>#audioPlayer {
    display: block;
    margin-left: auto;
    margin-right: auto;
  }
  
  #playlist li a {
    color: white;
    text-decoration: none;
  }
  
  #playlist .current-song a {
    color: #0b80f7;
  }
  </code></pre>
  
  <p>I would really appreciate if someone could help me.</p>
  
  <p><strong>I Just solved it, thanks to everyone.</strong> </p>