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 () {
|
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) {
|
self.setAudioStreamIndex = function (index) {
|
||||||
|
@ -859,7 +864,12 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
self.subtitleTracks = function () {
|
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 () {
|
self.getSubtitleStreamIndex = function () {
|
||||||
|
@ -975,8 +985,7 @@
|
||||||
return Promise.resolve([]);
|
return Promise.resolve([]);
|
||||||
};
|
};
|
||||||
|
|
||||||
self.getCurrentPlaylistIndex = function () {
|
self.getCurrentPlaylistItemId = function () {
|
||||||
return 0;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
self.setCurrentPlaylistItem = function (playlistItemId) {
|
self.setCurrentPlaylistItem = function (playlistItemId) {
|
||||||
|
|
|
@ -64,6 +64,7 @@
|
||||||
|
|
||||||
.listItem-shaded:nth-child(even) {
|
.listItem-shaded:nth-child(even) {
|
||||||
background: #1c1c1c;
|
background: #1c1c1c;
|
||||||
|
background: rgba(30, 30, 30, .9);
|
||||||
}
|
}
|
||||||
|
|
||||||
.three-line {
|
.three-line {
|
||||||
|
@ -112,9 +113,9 @@
|
||||||
color: #fff;
|
color: #fff;
|
||||||
}
|
}
|
||||||
|
|
||||||
.listItemIcon:not(.listItemIcon-transparent) {
|
.listItemIcon:not(.listItemIcon-transparent) {
|
||||||
background-color: #52B54B;
|
background-color: #52B54B;
|
||||||
}
|
}
|
||||||
|
|
||||||
.listItemProgressBar {
|
.listItemProgressBar {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
|
|
|
@ -1118,9 +1118,8 @@ define(['events', 'datetime', 'appSettings', 'pluginManager', 'userSettings', 'g
|
||||||
var apiClient = connectionManager.getApiClient(item.ServerId);
|
var apiClient = connectionManager.getApiClient(item.ServerId);
|
||||||
|
|
||||||
if (item.LocalTrailerCount) {
|
if (item.LocalTrailerCount) {
|
||||||
apiClient.getLocalTrailers(apiClient.getCurrentUserId(), item.Id).then(function (result) {
|
return apiClient.getLocalTrailers(apiClient.getCurrentUserId(), item.Id).then(function (result) {
|
||||||
|
return self.play({
|
||||||
self.play({
|
|
||||||
items: result
|
items: result
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -1128,10 +1127,10 @@ define(['events', 'datetime', 'appSettings', 'pluginManager', 'userSettings', 'g
|
||||||
var remoteTrailers = item.RemoteTrailers || [];
|
var remoteTrailers = item.RemoteTrailers || [];
|
||||||
|
|
||||||
if (!remoteTrailers.length) {
|
if (!remoteTrailers.length) {
|
||||||
return;
|
return Promise.reject();
|
||||||
}
|
}
|
||||||
|
|
||||||
self.play({
|
return self.play({
|
||||||
items: remoteTrailers.map(function (t) {
|
items: remoteTrailers.map(function (t) {
|
||||||
return {
|
return {
|
||||||
Name: t.Name || (item.Name + ' Trailer'),
|
Name: t.Name || (item.Name + ' Trailer'),
|
||||||
|
|
|
@ -81,7 +81,6 @@
|
||||||
ids: itemIds.split(',')
|
ids: itemIds.split(',')
|
||||||
});
|
});
|
||||||
dialogHelper.close(dlg);
|
dialogHelper.close(dlg);
|
||||||
showToast();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -102,13 +101,6 @@
|
||||||
loading.hide();
|
loading.hide();
|
||||||
|
|
||||||
dialogHelper.close(dlg);
|
dialogHelper.close(dlg);
|
||||||
showToast();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function showToast() {
|
|
||||||
require(['toast'], function (toast) {
|
|
||||||
toast(globalize.translate('sharedcomponents#MessageItemsAdded'));
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,7 +108,7 @@
|
||||||
select.dispatchEvent(new CustomEvent('change', {}));
|
select.dispatchEvent(new CustomEvent('change', {}));
|
||||||
}
|
}
|
||||||
|
|
||||||
function populatePlaylists(panel) {
|
function populatePlaylists(editorOptions, panel) {
|
||||||
|
|
||||||
var select = panel.querySelector('#selectPlaylistToAddTo');
|
var select = panel.querySelector('#selectPlaylistToAddTo');
|
||||||
|
|
||||||
|
@ -136,7 +128,7 @@
|
||||||
|
|
||||||
var html = '';
|
var html = '';
|
||||||
|
|
||||||
if (playbackManager.isPlaying()) {
|
if (editorOptions.enableAddToPlayQueue !== false && playbackManager.isPlaying()) {
|
||||||
html += '<option value="queue">' + globalize.translate('sharedcomponents#AddToPlayQueue') + '</option>';
|
html += '<option value="queue">' + globalize.translate('sharedcomponents#AddToPlayQueue') + '</option>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -148,7 +140,12 @@
|
||||||
});
|
});
|
||||||
|
|
||||||
select.innerHTML = html;
|
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 the value is empty set it again, in case we tried to set a lastplaylistid that is no longer valid
|
||||||
if (!select.value) {
|
if (!select.value) {
|
||||||
|
@ -195,7 +192,7 @@
|
||||||
return html;
|
return html;
|
||||||
}
|
}
|
||||||
|
|
||||||
function initEditor(content, items) {
|
function initEditor(content, options, items) {
|
||||||
|
|
||||||
content.querySelector('#selectPlaylistToAddTo').addEventListener('change', function () {
|
content.querySelector('#selectPlaylistToAddTo').addEventListener('change', function () {
|
||||||
if (this.value) {
|
if (this.value) {
|
||||||
|
@ -213,7 +210,7 @@
|
||||||
|
|
||||||
if (items.length) {
|
if (items.length) {
|
||||||
content.querySelector('.fldSelectPlaylist').classList.remove('hide');
|
content.querySelector('.fldSelectPlaylist').classList.remove('hide');
|
||||||
populatePlaylists(content);
|
populatePlaylists(options, content);
|
||||||
} else {
|
} else {
|
||||||
content.querySelector('.fldSelectPlaylist').classList.add('hide');
|
content.querySelector('.fldSelectPlaylist').classList.add('hide');
|
||||||
|
|
||||||
|
@ -270,7 +267,7 @@
|
||||||
|
|
||||||
dlg.innerHTML = html;
|
dlg.innerHTML = html;
|
||||||
|
|
||||||
initEditor(dlg, items);
|
initEditor(dlg, options, items);
|
||||||
|
|
||||||
dlg.querySelector('.btnCancel').addEventListener('click', function () {
|
dlg.querySelector('.btnCancel').addEventListener('click', function () {
|
||||||
|
|
||||||
|
|
|
@ -207,11 +207,18 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
self.audioTracks = function () {
|
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 () {
|
self.getAudioStreamIndex = function () {
|
||||||
|
var state = self.lastPlayerData || {};
|
||||||
|
state = state.PlayState || {};
|
||||||
|
return state.AudioStreamIndex;
|
||||||
};
|
};
|
||||||
|
|
||||||
self.setAudioStreamIndex = function (index) {
|
self.setAudioStreamIndex = function (index) {
|
||||||
|
@ -221,11 +228,18 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
self.subtitleTracks = function () {
|
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 () {
|
self.getSubtitleStreamIndex = function () {
|
||||||
|
var state = self.lastPlayerData || {};
|
||||||
|
state = state.PlayState || {};
|
||||||
|
return state.SubtitleStreamIndex;
|
||||||
};
|
};
|
||||||
|
|
||||||
self.setSubtitleStreamIndex = function (index) {
|
self.setSubtitleStreamIndex = function (index) {
|
||||||
|
@ -287,8 +301,7 @@
|
||||||
return Promise.resolve([]);
|
return Promise.resolve([]);
|
||||||
};
|
};
|
||||||
|
|
||||||
self.getCurrentPlaylistIndex = function () {
|
self.getCurrentPlaylistItemId = function () {
|
||||||
return 0;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
self.setCurrentPlaylistItem = function (playlistItemId) {
|
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) {
|
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) {
|
var streams = (item.MediaStreams || []).filter(function (i) {
|
||||||
|
|
||||||
|
@ -490,6 +494,12 @@
|
||||||
dragHandle: true
|
dragHandle: true
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (items.length) {
|
||||||
|
context.querySelector('.playlistSection').classList.remove('hide');
|
||||||
|
} else {
|
||||||
|
context.querySelector('.playlistSection').classList.add('hide');
|
||||||
|
}
|
||||||
|
|
||||||
var itemsContainer = context.querySelector('.playlist');
|
var itemsContainer = context.querySelector('.playlist');
|
||||||
|
|
||||||
itemsContainer.innerHTML = html;
|
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) {
|
function bindEvents(context) {
|
||||||
|
|
||||||
var btnCommand = context.querySelectorAll('.btnCommand');
|
var btnCommand = context.querySelectorAll('.btnCommand');
|
||||||
|
@ -699,19 +739,17 @@
|
||||||
|
|
||||||
context.querySelector('.btnAudioTracks').addEventListener('click', function (e) {
|
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);
|
||||||
showAudioMenu(context, currentPlayer, e.target, lastPlayerState.NowPlayingItem, currentIndex);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
context.querySelector('.btnSubtitles').addEventListener('click', function (e) {
|
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);
|
||||||
showSubtitleMenu(context, currentPlayer, e.target, lastPlayerState.NowPlayingItem, currentIndex);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -792,6 +830,8 @@
|
||||||
|
|
||||||
playbackManager.movePlaylistItem(playlistItemId, newIndex, currentPlayer);
|
playbackManager.movePlaylistItem(playlistItemId, newIndex, currentPlayer);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
context.querySelector('.btnSavePlaylist').addEventListener('click', savePlaylist);
|
||||||
}
|
}
|
||||||
|
|
||||||
function onPlayerChange() {
|
function onPlayerChange() {
|
||||||
|
|
|
@ -160,8 +160,13 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<br />
|
<br />
|
||||||
<div>
|
<div class="playlistSection hide">
|
||||||
<h1>${TabPlaylist}</h1>
|
<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 class="playlist itemsContainer vertical-list" is="emby-itemscontainer" data-dragreorder="true">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue