(function ($, document) {
function reloadPlaylist(page) {
var html = '';
html += '
';
html += '';
html += ' | ';
html += 'Name | ';
html += 'Album | ';
html += 'Time | ';
html += 'Rating | ';
html += '
';
$.each(MediaPlayer.playlist, function (i, item) {
var name = LibraryBrowser.getPosterViewDisplayName(item);
var parentName = item.SeriesName || item.Album || item.ProductionYear || '';
html += '';
html += ' | ';
html += '' + name + ' | ';
html += '' + parentName + ' | ';
html += '' + Dashboard.getDisplayTime(item.RunTimeTicks) + ' | ';
html += '' + LibraryBrowser.getUserDataIconsHtml(item) + ' | ';
html += ' | ';
html += '
';
});
html += '
';
$("#playlist", page).html(html).trigger('create');
}
$(document).on('pageinit', "#playlistPage", function () {
var page = this;
$(page).on('click', '.lnkPlay', function () {
var index = parseInt(this.getAttribute('data-index'));
MediaPlayer.currentPlaylistIndex(index);
reloadPlaylist(page);
}).on('click', '.lnkRemove', function () {
var index = parseInt(this.getAttribute('data-index'));
MediaPlayer.removeFromPlaylist(index);
reloadPlaylist(page);
});
}).on('pagebeforeshow', "#playlistPage", function () {
var page = this;
reloadPlaylist(page);
});
})(jQuery, document);