1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00

update now playing playlist

This commit is contained in:
Luke Pulverenti 2017-01-17 16:08:50 -05:00
parent bb816420e7
commit 6820da0e4f
5 changed files with 145 additions and 38 deletions

View file

@ -142,6 +142,20 @@ define(['itemHelper', 'mediaInfo', 'indicators', 'connectionManager', 'layoutMan
return html;
}
function getRightButtonsHtml(options) {
var html = '';
for (var i = 0, length = options.rightButtons.length; i < length; i++) {
var button = options.rightButtons[i];
html += '<button is="paper-icon-button-light" class="listItemButton itemAction autoSize" data-action="custom" data-customaction="' + button.id + '" title="' + button.title + '"><i class="md-icon">' + button.icon + '</i></button>';
}
return html;
}
function getListViewHtml(options) {
var items = options.items;
@ -406,9 +420,8 @@ define(['itemHelper', 'mediaInfo', 'indicators', 'connectionManager', 'layoutMan
html += '<button is="paper-icon-button-light" class="listItemButton itemAction autoSize" data-action="menu"><i class="md-icon">' + moreIcon + '</i></button>';
}
if (options.recordButton) {
html += '<button is="paper-icon-button-light" class="listItemButton itemAction autoSize" data-action="programdialog">' + indicators.getTimerIndicator(item) + '</button>';
if (options.rightButtons) {
html += getRightButtonsHtml(options);
}
if (options.enableUserDataButtons !== false) {

View file

@ -2215,7 +2215,12 @@ define(['events', 'datetime', 'appSettings', 'pluginManager', 'userSettings', 'g
}
}
self.setCurrentPlaylistIndex = function (i) {
self.setCurrentPlaylistIndex = function (i, player) {
player = player || currentPlayer;
if (player && !enableLocalPlaylistManagement(player)) {
return player.setCurrentPlaylistIndex(i);
}
var newItem = playlist[i];
@ -2228,7 +2233,43 @@ define(['events', 'datetime', 'appSettings', 'pluginManager', 'userSettings', 'g
});
};
self.getCurrentPlaylistIndex = function (i) {
self.removeFromPlaylist = function (index, player) {
if (index < 0) {
throw new Error('Invalid playlist index');
}
player = player || currentPlayer;
if (player && !enableLocalPlaylistManagement(player)) {
return player.removeFromPlaylist(i);
}
if (playlist.length <= 1) {
return self.stop();
}
var isCurrentIndex = self.getCurrentPlaylistIndex(player) === index;
playlist.splice(index, 1);
events.trigger(player, 'playlistitemremove', [
{
index: index
}]);
if (isCurrentIndex) {
return self.setCurrentPlaylistIndex(Math.min(index, playlist.length - 1), player);
}
return Promise.resolve();
};
self.getCurrentPlaylistIndex = function (i, player) {
player = player || currentPlayer;
if (player && !enableLocalPlaylistManagement(player)) {
return player.getCurrentPlaylistIndex();
}
return currentPlaylistIndex;
};
@ -2241,7 +2282,7 @@ define(['events', 'datetime', 'appSettings', 'pluginManager', 'userSettings', 'g
}
repeatMode = value;
events.trigger(self, 'repeatmodechange');
events.trigger(player, 'repeatmodechange');
};
self.getRepeatMode = function (player) {

View file

@ -330,6 +330,20 @@ define(['playbackManager', 'inputManager', 'connectionManager', 'embyRouter', 'g
else if (action === 'addtoplaylist') {
getItem(target).then(addToPlaylist);
}
else if (action === 'custom') {
var customAction = target.getAttribute('data-customaction');
card.dispatchEvent(new CustomEvent('action-' + customAction, {
detail: {
item: getItem(target),
index: parseInt(card.getAttribute('data-index') || '-1')
},
cancelable: false,
bubbles: true
}));
}
}
function addToPlaylist(item) {