JustWave Player: Demo 2

Choose a song

  1. Demis Russos - Goodbye My Love Goodbye[demo].mp3
  2. Elvis Presley - Pretty woman[demo].mp3
  3. KirillTV - Always.mp3
  4. Queens of Dogtown - I Remember You[demo].mp3
  5. Sweden Village.mp3
  6. We Wish You.mp3
  7. zx.spectrum_life.mp3
  8. KirillTV - Always.ogg
  9. We Wish You.ogg
  10. http://everwebcodebox.com/audio-player-master/audio/CosmicTraveler.mp3
  11. http://justwave.beotiger.com/media/Sweden%20Village.mp3

How to create a simple player with playlist in less than 25 lines of code?

Tip: we need jQuery and JustWave player. That's all!
Show me the answer $(document).ready( function() {
    $.justwave();
    // main routine for loading songs
    $('.songs li[data-src]').click(function() {
        $('audio')[0].src = $(this).attr('data-src'); // name of an audio
        $(this).addClass('active').siblings().removeClass('active');
    });
    // start first song
    $('.songs li[data-src]').first().click();
    // loop list
    $('audio').first().on('ended', nextSong).on('error', nextSong);
});

function nextSong()
{
    var next = $('.songs li[data-src].active').next();
    if (!next.length) next = $('.songs li[data-src]').first();
    next.addClass('active').siblings().removeClass('active');
    $('audio')[0].src = next.attr('data-src');
}

(c) beotiger Andrey Tzar 2015 AD http://justwave.beotiger.com https://github.com/beotiger email: beotiger@gmail.com Yandex.Metrica