AndrewMantarro
9/11/2017 - 12:26 AM

This is a HTML5 list music player Example: http://jsfiddle.net/lastrose/vkMqR/

This is a HTML5 list music player Example: http://jsfiddle.net/lastrose/vkMqR/

<script>
  
var audio;
var playlist;
var tracks;
var current;

init();
function init(){
    current = 0;
    audio = $('audio');
    playlist = $('#playlist');
    tracks = playlist.find('li a');
    len = tracks.length - 1;
    audio[0].volume = .50;
    playlist.find('a').click(function(e){
        e.preventDefault();
        link = $(this);
        current = link.parent().index();
        run(link, audio[0]);
    });
    audio[0].addEventListener('ended',function(e){
        current++;
        if(current == len){
            current = 0;
            link = playlist.find('a')[0];
        }else{
            link = playlist.find('a')[current];    
        }
        run($(link),audio[0]);
    });
}
function run(link, player){
        player.src = link.attr('href');
        par = link.parent();
        par.addClass('active').siblings().removeClass('active');
        audio[0].load();
        audio[0].play();
}
  
  </script>
<audio id="audio" preload="auto" controls type="audio/mpeg" tabindex="0">
<src type="audio/mp3" src="*** MP3 LINK ***" />Sorry, your browser does not support HTML5 audio.</audio></div>

<ul id="playlist">
<li class="active"><a href="*** BUTTON LINK ***"> Song Name </a></li>
<li><a href="*** MP3 LINK ***"> Song Name </a></li>
<li><a href="*** MP3 LINK ***"> Song Name </a></li>
<li><a href="*** MP3 LINK ***"> Song Name </a></li>
<li><a href="*** MP3 LINK ***"> Song Name </a></li>
<li><a href="*** MP3 LINK ***"> Song Name </a></li>
<li><a href="*** MP3 LINK ***"> Song Name </a></li>
</ul>
* {
box-sizing:border-box;
}

#playlist, audio{
  background:#00ACE3;
  width:100%;
  padding:10px;
}

#playlist .active{
  color:#E6CF59;
  text-decoration:none;
}

#playlist {
  list-style: none;
  width:100%;
  display: inline-block;
}

#playlist li {
  background:rgba(0,0,0,0.4);
  margin-bottom: 1px;
  display:inline-block;
  text-decoration: none;
  width:49.5%;
}

#playlist li a{
  color:#fff;

  padding:10px 20px;
display: block;
  text-decoration: none;
  width:100%;
}

#playlist li a:hover{
  text-decoration:none;
  background:rgba(0,0,0,0.7);
  color:#fff;
}

#playlist li a:before {
  font-family: FontAwesome;
  content: "\f144";
  margin-right: 10px;
}

audio {
padding:0!important;}