mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
update now playing screen
This commit is contained in:
parent
52e8f36d41
commit
3b258484af
7 changed files with 106 additions and 42 deletions
|
@ -840,7 +840,12 @@
|
|||
};
|
||||
|
||||
self.audioTracks = function () {
|
||||
return [];
|
||||
var state = self.lastPlayerData || {};
|
||||
state = state.NowPlayingItem || {};
|
||||
var streams = state.MediaStreams || [];
|
||||
return streams.filter(function (s) {
|
||||
return s.Type === 'Audio';
|
||||
});
|
||||
};
|
||||
|
||||
self.setAudioStreamIndex = function (index) {
|
||||
|
@ -859,7 +864,12 @@
|
|||
};
|
||||
|
||||
self.subtitleTracks = function () {
|
||||
return [];
|
||||
var state = self.lastPlayerData || {};
|
||||
state = state.NowPlayingItem || {};
|
||||
var streams = state.MediaStreams || [];
|
||||
return streams.filter(function (s) {
|
||||
return s.Type === 'Subtitle';
|
||||
});
|
||||
};
|
||||
|
||||
self.getSubtitleStreamIndex = function () {
|
||||
|
@ -975,8 +985,7 @@
|
|||
return Promise.resolve([]);
|
||||
};
|
||||
|
||||
self.getCurrentPlaylistIndex = function () {
|
||||
return 0;
|
||||
self.getCurrentPlaylistItemId = function () {
|
||||
};
|
||||
|
||||
self.setCurrentPlaylistItem = function (playlistItemId) {
|
||||
|
|
|
@ -64,6 +64,7 @@
|
|||
|
||||
.listItem-shaded:nth-child(even) {
|
||||
background: #1c1c1c;
|
||||
background: rgba(30, 30, 30, .9);
|
||||
}
|
||||
|
||||
.three-line {
|
||||
|
@ -112,9 +113,9 @@
|
|||
color: #fff;
|
||||
}
|
||||
|
||||
.listItemIcon:not(.listItemIcon-transparent) {
|
||||
background-color: #52B54B;
|
||||
}
|
||||
.listItemIcon:not(.listItemIcon-transparent) {
|
||||
background-color: #52B54B;
|
||||
}
|
||||
|
||||
.listItemProgressBar {
|
||||
position: absolute;
|
||||
|
|
|
@ -1118,9 +1118,8 @@ define(['events', 'datetime', 'appSettings', 'pluginManager', 'userSettings', 'g
|
|||
var apiClient = connectionManager.getApiClient(item.ServerId);
|
||||
|
||||
if (item.LocalTrailerCount) {
|
||||
apiClient.getLocalTrailers(apiClient.getCurrentUserId(), item.Id).then(function (result) {
|
||||
|
||||
self.play({
|
||||
return apiClient.getLocalTrailers(apiClient.getCurrentUserId(), item.Id).then(function (result) {
|
||||
return self.play({
|
||||
items: result
|
||||
});
|
||||
});
|
||||
|
@ -1128,10 +1127,10 @@ define(['events', 'datetime', 'appSettings', 'pluginManager', 'userSettings', 'g
|
|||
var remoteTrailers = item.RemoteTrailers || [];
|
||||
|
||||
if (!remoteTrailers.length) {
|
||||
return;
|
||||
return Promise.reject();
|
||||
}
|
||||
|
||||
self.play({
|
||||
return self.play({
|
||||
items: remoteTrailers.map(function (t) {
|
||||
return {
|
||||
Name: t.Name || (item.Name + ' Trailer'),
|
||||
|
|
|
@ -81,7 +81,6 @@
|
|||
ids: itemIds.split(',')
|
||||
});
|
||||
dialogHelper.close(dlg);
|
||||
showToast();
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -102,13 +101,6 @@
|
|||
loading.hide();
|
||||
|
||||
dialogHelper.close(dlg);
|
||||
showToast();
|
||||
});
|
||||
}
|
||||
|
||||
function showToast() {
|
||||
require(['toast'], function (toast) {
|
||||
toast(globalize.translate('sharedcomponents#MessageItemsAdded'));
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -116,7 +108,7 @@
|
|||
select.dispatchEvent(new CustomEvent('change', {}));
|
||||
}
|
||||
|
||||
function populatePlaylists(panel) {
|
||||
function populatePlaylists(editorOptions, panel) {
|
||||
|
||||
var select = panel.querySelector('#selectPlaylistToAddTo');
|
||||
|
||||
|
@ -136,7 +128,7 @@
|
|||
|
||||
var html = '';
|
||||
|
||||
if (playbackManager.isPlaying()) {
|
||||
if (editorOptions.enableAddToPlayQueue !== false && playbackManager.isPlaying()) {
|
||||
html += '<option value="queue">' + globalize.translate('sharedcomponents#AddToPlayQueue') + '</option>';
|
||||
}
|
||||
|
||||
|
@ -148,7 +140,12 @@
|
|||
});
|
||||
|
||||
select.innerHTML = html;
|
||||
select.value = userSettings.get('playlisteditor-lastplaylistid') || '';
|
||||
|
||||
var defaultValue = editorOptions.defaultValue;
|
||||
if (!defaultValue) {
|
||||
defaultValue = userSettings.get('playlisteditor-lastplaylistid') || '';
|
||||
}
|
||||
select.value = defaultValue === 'new' ? '' : defaultValue;
|
||||
|
||||
// If the value is empty set it again, in case we tried to set a lastplaylistid that is no longer valid
|
||||
if (!select.value) {
|
||||
|
@ -195,7 +192,7 @@
|
|||
return html;
|
||||
}
|
||||
|
||||
function initEditor(content, items) {
|
||||
function initEditor(content, options, items) {
|
||||
|
||||
content.querySelector('#selectPlaylistToAddTo').addEventListener('change', function () {
|
||||
if (this.value) {
|
||||
|
@ -213,7 +210,7 @@
|
|||
|
||||
if (items.length) {
|
||||
content.querySelector('.fldSelectPlaylist').classList.remove('hide');
|
||||
populatePlaylists(content);
|
||||
populatePlaylists(options, content);
|
||||
} else {
|
||||
content.querySelector('.fldSelectPlaylist').classList.add('hide');
|
||||
|
||||
|
@ -270,7 +267,7 @@
|
|||
|
||||
dlg.innerHTML = html;
|
||||
|
||||
initEditor(dlg, items);
|
||||
initEditor(dlg, options, items);
|
||||
|
||||
dlg.querySelector('.btnCancel').addEventListener('click', function () {
|
||||
|
||||
|
|
|
@ -207,11 +207,18 @@
|
|||
};
|
||||
|
||||
self.audioTracks = function () {
|
||||
return [];
|
||||
var state = self.lastPlayerData || {};
|
||||
state = state.NowPlayingItem || {};
|
||||
var streams = state.MediaStreams || [];
|
||||
return streams.filter(function (s) {
|
||||
return s.Type === 'Audio';
|
||||
});
|
||||
};
|
||||
|
||||
self.getAudioStreamIndex = function () {
|
||||
|
||||
var state = self.lastPlayerData || {};
|
||||
state = state.PlayState || {};
|
||||
return state.AudioStreamIndex;
|
||||
};
|
||||
|
||||
self.setAudioStreamIndex = function (index) {
|
||||
|
@ -221,11 +228,18 @@
|
|||
};
|
||||
|
||||
self.subtitleTracks = function () {
|
||||
return [];
|
||||
var state = self.lastPlayerData || {};
|
||||
state = state.NowPlayingItem || {};
|
||||
var streams = state.MediaStreams || [];
|
||||
return streams.filter(function (s) {
|
||||
return s.Type === 'Subtitle';
|
||||
});
|
||||
};
|
||||
|
||||
self.getSubtitleStreamIndex = function () {
|
||||
|
||||
var state = self.lastPlayerData || {};
|
||||
state = state.PlayState || {};
|
||||
return state.SubtitleStreamIndex;
|
||||
};
|
||||
|
||||
self.setSubtitleStreamIndex = function (index) {
|
||||
|
@ -287,8 +301,7 @@
|
|||
return Promise.resolve([]);
|
||||
};
|
||||
|
||||
self.getCurrentPlaylistIndex = function () {
|
||||
return 0;
|
||||
self.getCurrentPlaylistItemId = function () {
|
||||
};
|
||||
|
||||
self.setCurrentPlaylistItem = function (playlistItemId) {
|
||||
|
|
|
@ -7,7 +7,9 @@
|
|||
});
|
||||
}
|
||||
|
||||
function showAudioMenu(context, player, button, item, currentIndex) {
|
||||
function showAudioMenu(context, player, button, item) {
|
||||
|
||||
var currentIndex = playbackManager.getAudioStreamIndex(player);
|
||||
|
||||
var streams = (item.MediaStreams || []).filter(function (i) {
|
||||
|
||||
|
@ -42,7 +44,9 @@
|
|||
});
|
||||
}
|
||||
|
||||
function showSubtitleMenu(context, player, button, item, currentIndex) {
|
||||
function showSubtitleMenu(context, player, button, item) {
|
||||
|
||||
var currentIndex = playbackManager.getSubtitleStreamIndex(player);
|
||||
|
||||
var streams = (item.MediaStreams || []).filter(function (i) {
|
||||
|
||||
|
@ -490,6 +494,12 @@
|
|||
dragHandle: true
|
||||
});
|
||||
|
||||
if (items.length) {
|
||||
context.querySelector('.playlistSection').classList.remove('hide');
|
||||
} else {
|
||||
context.querySelector('.playlistSection').classList.add('hide');
|
||||
}
|
||||
|
||||
var itemsContainer = context.querySelector('.playlist');
|
||||
|
||||
itemsContainer.innerHTML = html;
|
||||
|
@ -680,6 +690,36 @@
|
|||
}
|
||||
}
|
||||
|
||||
function getSaveablePlaylistItems() {
|
||||
|
||||
return getPlaylistItems(currentPlayer).then(function (items) {
|
||||
|
||||
return items.filter(function (i) {
|
||||
return i.Id && i.ServerId;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function savePlaylist() {
|
||||
|
||||
require(['playlistEditor'], function (playlistEditor) {
|
||||
|
||||
getSaveablePlaylistItems().then(function (items) {
|
||||
|
||||
var serverId = items.length ? items[0].ServerId : ApiClient.serverId();
|
||||
|
||||
new playlistEditor().show({
|
||||
items: items.map(function(i) {
|
||||
return i.Id;
|
||||
}),
|
||||
serverId: serverId,
|
||||
enableAddToPlayQueue: false,
|
||||
defaultValue: 'new'
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function bindEvents(context) {
|
||||
|
||||
var btnCommand = context.querySelectorAll('.btnCommand');
|
||||
|
@ -699,19 +739,17 @@
|
|||
|
||||
context.querySelector('.btnAudioTracks').addEventListener('click', function (e) {
|
||||
|
||||
if (currentPlayer && lastPlayerState && lastPlayerState.PlayState) {
|
||||
if (currentPlayer && lastPlayerState && lastPlayerState.NowPlayingItem) {
|
||||
|
||||
var currentIndex = lastPlayerState.PlayState.AudioStreamIndex;
|
||||
showAudioMenu(context, currentPlayer, e.target, lastPlayerState.NowPlayingItem, currentIndex);
|
||||
showAudioMenu(context, currentPlayer, e.target, lastPlayerState.NowPlayingItem);
|
||||
}
|
||||
});
|
||||
|
||||
context.querySelector('.btnSubtitles').addEventListener('click', function (e) {
|
||||
|
||||
if (currentPlayer && lastPlayerState && lastPlayerState.PlayState) {
|
||||
if (currentPlayer && lastPlayerState && lastPlayerState.NowPlayingItem) {
|
||||
|
||||
var currentIndex = lastPlayerState.PlayState.SubtitleStreamIndex;
|
||||
showSubtitleMenu(context, currentPlayer, e.target, lastPlayerState.NowPlayingItem, currentIndex);
|
||||
showSubtitleMenu(context, currentPlayer, e.target, lastPlayerState.NowPlayingItem);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -792,6 +830,8 @@
|
|||
|
||||
playbackManager.movePlaylistItem(playlistItemId, newIndex, currentPlayer);
|
||||
});
|
||||
|
||||
context.querySelector('.btnSavePlaylist').addEventListener('click', savePlaylist);
|
||||
}
|
||||
|
||||
function onPlayerChange() {
|
||||
|
|
|
@ -160,8 +160,13 @@
|
|||
</div>
|
||||
|
||||
<br />
|
||||
<div>
|
||||
<h1>${TabPlaylist}</h1>
|
||||
<div class="playlistSection hide">
|
||||
<div style="display: flex; align-items: center;margin:2em 0 1em">
|
||||
<h1 style="margin:0;">${TabPlaylist}</h1>
|
||||
<button is="paper-icon-button-light" class="btnSavePlaylist" title="${ButtonSave}" style="margin-left:1em;">
|
||||
<i class="md-icon"></i>
|
||||
</button>
|
||||
</div>
|
||||
<div class="playlist itemsContainer vertical-list" is="emby-itemscontainer" data-dragreorder="true">
|
||||
</div>
|
||||
</div>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue