mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
Add auto-cast feature.
This commit is contained in:
parent
f31801c85b
commit
e9caf5e336
6 changed files with 81 additions and 0 deletions
|
@ -177,6 +177,7 @@
|
||||||
"src/components/remotecontrol/remotecontrol.js",
|
"src/components/remotecontrol/remotecontrol.js",
|
||||||
"src/components/sanatizefilename.js",
|
"src/components/sanatizefilename.js",
|
||||||
"src/components/scrollManager.js",
|
"src/components/scrollManager.js",
|
||||||
|
"src/components/autocast.js",
|
||||||
"src/plugins/experimentalWarnings/plugin.js",
|
"src/plugins/experimentalWarnings/plugin.js",
|
||||||
"src/plugins/sessionPlayer/plugin.js",
|
"src/plugins/sessionPlayer/plugin.js",
|
||||||
"src/plugins/htmlAudioPlayer/plugin.js",
|
"src/plugins/htmlAudioPlayer/plugin.js",
|
||||||
|
|
49
src/components/autocast.js
Normal file
49
src/components/autocast.js
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
import events from 'events';
|
||||||
|
import playbackManager from 'playbackManager';
|
||||||
|
|
||||||
|
export function supported() {
|
||||||
|
return typeof(Storage) !== 'undefined';
|
||||||
|
}
|
||||||
|
|
||||||
|
export function enable(isEnabled) {
|
||||||
|
if (!supported()) return;
|
||||||
|
|
||||||
|
if (isEnabled) {
|
||||||
|
const currentPlayerInfo = playbackManager.getPlayerInfo();
|
||||||
|
|
||||||
|
if (currentPlayerInfo && currentPlayerInfo.id && currentPlayerInfo.id) {
|
||||||
|
localStorage.setItem('autocastPlayerId', currentPlayerInfo.id);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
localStorage.removeItem('autocastPlayerId');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function isEnabled() {
|
||||||
|
if (!supported()) return false;
|
||||||
|
|
||||||
|
const playerId = localStorage.getItem('autocastPlayerId');
|
||||||
|
const currentPlayerInfo = playbackManager.getPlayerInfo();
|
||||||
|
|
||||||
|
return (currentPlayerInfo && playerId && currentPlayerInfo.id === playerId);
|
||||||
|
}
|
||||||
|
|
||||||
|
function onOpen() {
|
||||||
|
if (!supported()) return;
|
||||||
|
|
||||||
|
const playerId = localStorage.getItem('autocastPlayerId');
|
||||||
|
|
||||||
|
playbackManager.getTargets().then(function (targets) {
|
||||||
|
for (var i = 0; i < targets.length; i++) {
|
||||||
|
if (targets[i].id == playerId) {
|
||||||
|
playbackManager.trySetActivePlayer(targets[i].playerName, targets[i]);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const apiClient = window.connectionManager.currentApiClient();
|
||||||
|
if (apiClient) {
|
||||||
|
events.on(apiClient, 'websocketopen', onOpen);
|
||||||
|
}
|
|
@ -6,6 +6,7 @@ import playbackManager from 'playbackManager';
|
||||||
import appRouter from 'appRouter';
|
import appRouter from 'appRouter';
|
||||||
import globalize from 'globalize';
|
import globalize from 'globalize';
|
||||||
import appHost from 'apphost';
|
import appHost from 'apphost';
|
||||||
|
import * as autocast from 'autocast';
|
||||||
|
|
||||||
function mirrorItem(info, player) {
|
function mirrorItem(info, player) {
|
||||||
var item = info.item;
|
var item = info.item;
|
||||||
|
@ -219,6 +220,16 @@ function showActivePlayerMenuInternal(dialogHelper, playerInfo) {
|
||||||
html += '</label>';
|
html += '</label>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
html += '</div><div>';
|
||||||
|
|
||||||
|
if (autocast.supported()) {
|
||||||
|
html += '<label class="checkboxContainer">';
|
||||||
|
var checkedHtml = autocast.isEnabled() ? ' checked' : '';
|
||||||
|
html += '<input type="checkbox" is="emby-checkbox" class="chkAutoCast"' + checkedHtml + '/>';
|
||||||
|
html += '<span>' + globalize.translate('EnableAutoCast') + '</span>';
|
||||||
|
html += '</label>';
|
||||||
|
}
|
||||||
|
|
||||||
html += '</div>';
|
html += '</div>';
|
||||||
|
|
||||||
html += '<div style="margin-top:1em;display:flex;justify-content: flex-end;">';
|
html += '<div style="margin-top:1em;display:flex;justify-content: flex-end;">';
|
||||||
|
@ -237,6 +248,12 @@ function showActivePlayerMenuInternal(dialogHelper, playerInfo) {
|
||||||
chkMirror.addEventListener('change', onMirrorChange);
|
chkMirror.addEventListener('change', onMirrorChange);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var chkAutoCast = dlg.querySelector('.chkAutoCast');
|
||||||
|
|
||||||
|
if (chkAutoCast) {
|
||||||
|
chkAutoCast.addEventListener('change', onAutoCastChange);
|
||||||
|
}
|
||||||
|
|
||||||
var destination = '';
|
var destination = '';
|
||||||
|
|
||||||
var btnRemoteControl = dlg.querySelector('.btnRemoteControl');
|
var btnRemoteControl = dlg.querySelector('.btnRemoteControl');
|
||||||
|
@ -269,6 +286,10 @@ function onMirrorChange() {
|
||||||
playbackManager.enableDisplayMirroring(this.checked);
|
playbackManager.enableDisplayMirroring(this.checked);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function onAutoCastChange() {
|
||||||
|
autocast.enable(this.checked);
|
||||||
|
}
|
||||||
|
|
||||||
document.addEventListener('viewshow', function (e) {
|
document.addEventListener('viewshow', function (e) {
|
||||||
var state = e.detail.state || {};
|
var state = e.detail.state || {};
|
||||||
var item = state.item;
|
var item = state.item;
|
||||||
|
|
|
@ -52,6 +52,7 @@ import 'flexStyles';
|
||||||
|
|
||||||
lazyLoadViewMenuBarImages();
|
lazyLoadViewMenuBarImages();
|
||||||
bindMenuEvents();
|
bindMenuEvents();
|
||||||
|
updateCastIcon();
|
||||||
}
|
}
|
||||||
|
|
||||||
function getCurrentApiClient() {
|
function getCurrentApiClient() {
|
||||||
|
@ -910,6 +911,12 @@ import 'flexStyles';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function ensureHeader() {
|
||||||
|
return new Promise(function (resolve) {
|
||||||
|
window.connectionManager.user(getCurrentApiClient()).then(updateUserInHeader).then(resolve);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
let currentPageType;
|
let currentPageType;
|
||||||
pageClassOn('pagebeforeshow', 'page', function (e) {
|
pageClassOn('pagebeforeshow', 'page', function (e) {
|
||||||
if (!this.classList.contains('withTabs')) {
|
if (!this.classList.contains('withTabs')) {
|
||||||
|
@ -996,6 +1003,7 @@ import 'flexStyles';
|
||||||
};
|
};
|
||||||
|
|
||||||
window.LibraryMenu = LibraryMenu;
|
window.LibraryMenu = LibraryMenu;
|
||||||
|
renderHeader();
|
||||||
|
|
||||||
export default LibraryMenu;
|
export default LibraryMenu;
|
||||||
|
|
||||||
|
|
|
@ -591,6 +591,7 @@ function initClient() {
|
||||||
define('metadataEditor', [componentsPath + '/metadataEditor/metadataEditor'], returnFirstDependency);
|
define('metadataEditor', [componentsPath + '/metadataEditor/metadataEditor'], returnFirstDependency);
|
||||||
define('personEditor', [componentsPath + '/metadataEditor/personEditor'], returnFirstDependency);
|
define('personEditor', [componentsPath + '/metadataEditor/personEditor'], returnFirstDependency);
|
||||||
define('playerSelectionMenu', [componentsPath + '/playback/playerSelectionMenu'], returnFirstDependency);
|
define('playerSelectionMenu', [componentsPath + '/playback/playerSelectionMenu'], returnFirstDependency);
|
||||||
|
define('autocast', [componentsPath + '/autocast'], returnFirstDependency);
|
||||||
define('playerSettingsMenu', [componentsPath + '/playback/playersettingsmenu'], returnFirstDependency);
|
define('playerSettingsMenu', [componentsPath + '/playback/playersettingsmenu'], returnFirstDependency);
|
||||||
define('playMethodHelper', [componentsPath + '/playback/playmethodhelper'], returnFirstDependency);
|
define('playMethodHelper', [componentsPath + '/playback/playmethodhelper'], returnFirstDependency);
|
||||||
define('brightnessOsd', [componentsPath + '/playback/brightnessosd'], returnFirstDependency);
|
define('brightnessOsd', [componentsPath + '/playback/brightnessosd'], returnFirstDependency);
|
||||||
|
|
|
@ -183,6 +183,7 @@
|
||||||
"EditImages": "Edit images",
|
"EditImages": "Edit images",
|
||||||
"EditMetadata": "Edit metadata",
|
"EditMetadata": "Edit metadata",
|
||||||
"EditSubtitles": "Edit subtitles",
|
"EditSubtitles": "Edit subtitles",
|
||||||
|
"EnableAutoCast": "Set as Default",
|
||||||
"EnableBackdropsHelp": "Display backdrops in the background of some pages while browsing the library.",
|
"EnableBackdropsHelp": "Display backdrops in the background of some pages while browsing the library.",
|
||||||
"EnableCinemaMode": "Cinema mode",
|
"EnableCinemaMode": "Cinema mode",
|
||||||
"EnableColorCodedBackgrounds": "Color coded backgrounds",
|
"EnableColorCodedBackgrounds": "Color coded backgrounds",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue