function createPlaylist(properties) {
// Setup the player to autoplay the next track
var a = audiojs.createAll({
trackEnded: function() {
var next = $('.playhead ol li.playing').next();
if (!next.length) next = $('.playhead ol li').first();
next.addClass('.playhead playing').siblings().removeClass('playing');
audio.load($('.playhead a', next).attr('data-src'));
audio.play();
}
});
// Load in the first track
var audio = a[0];
first = $('.playhead ol a').attr('data-src');
$('.playhead ol li').first().addClass('playing');
audio.load(first);
// Load in a track on click
$('.playhead ol li').click(function(e) {
e.preventDefault();
$(this).addClass('playing').siblings().removeClass('playing');
audio.load($('a', this).attr('data-src'));
audio.play();
});
}
let playlist = createPlaylist(someData);
playlist = createPlaylist(anotherData);