mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
Migrate bundle, qualityOptions, appHost and appLoader
This commit is contained in:
parent
9640f13830
commit
f16df9788a
39 changed files with 1075 additions and 723 deletions
|
@ -95,6 +95,7 @@
|
||||||
"src/components/alert.js",
|
"src/components/alert.js",
|
||||||
"src/components/alphaPicker/alphaPicker.js",
|
"src/components/alphaPicker/alphaPicker.js",
|
||||||
"src/components/appFooter/appFooter.js",
|
"src/components/appFooter/appFooter.js",
|
||||||
|
"src/components/apphost.js",
|
||||||
"src/components/autoFocuser.js",
|
"src/components/autoFocuser.js",
|
||||||
"src/components/backdrop/backdrop.js",
|
"src/components/backdrop/backdrop.js",
|
||||||
"src/components/cardbuilder/cardBuilder.js",
|
"src/components/cardbuilder/cardBuilder.js",
|
||||||
|
@ -156,6 +157,7 @@
|
||||||
"src/components/recordingcreator/seriesrecordingeditor.js",
|
"src/components/recordingcreator/seriesrecordingeditor.js",
|
||||||
"src/components/recordingcreator/recordinghelper.js",
|
"src/components/recordingcreator/recordinghelper.js",
|
||||||
"src/components/refreshdialog/refreshdialog.js",
|
"src/components/refreshdialog/refreshdialog.js",
|
||||||
|
"src/components/qualityOptions.js",
|
||||||
"src/components/sanatizefilename.js",
|
"src/components/sanatizefilename.js",
|
||||||
"src/components/scrollManager.js",
|
"src/components/scrollManager.js",
|
||||||
"src/plugins/htmlVideoPlayer/plugin.js",
|
"src/plugins/htmlVideoPlayer/plugin.js",
|
||||||
|
|
|
@ -2,159 +2,165 @@
|
||||||
* require.js module definitions bundled by webpack
|
* require.js module definitions bundled by webpack
|
||||||
*/
|
*/
|
||||||
// Use define from require.js not webpack's define
|
// Use define from require.js not webpack's define
|
||||||
var _define = window.define;
|
const _define = window.define;
|
||||||
|
|
||||||
// fetch
|
// fetch
|
||||||
var fetch = require('whatwg-fetch');
|
const fetch = require('whatwg-fetch');
|
||||||
_define('fetch', function() {
|
_define('fetch', function() {
|
||||||
return fetch;
|
return fetch;
|
||||||
});
|
});
|
||||||
|
|
||||||
// Blurhash
|
// Blurhash
|
||||||
var blurhash = require('blurhash');
|
const blurhash = require('blurhash');
|
||||||
_define('blurhash', function() {
|
_define('blurhash', function() {
|
||||||
return blurhash;
|
return blurhash;
|
||||||
});
|
});
|
||||||
|
|
||||||
// query-string
|
// query-string
|
||||||
var query = require('query-string');
|
const query = require('query-string');
|
||||||
_define('queryString', function() {
|
_define('queryString', function() {
|
||||||
return query;
|
return query;
|
||||||
});
|
});
|
||||||
|
|
||||||
// flvjs
|
// flvjs
|
||||||
var flvjs = require('flv.js/dist/flv').default;
|
const flvjs = require('flv.js/dist/flv').default;
|
||||||
_define('flvjs', function() {
|
_define('flvjs', function() {
|
||||||
return flvjs;
|
return flvjs;
|
||||||
});
|
});
|
||||||
|
|
||||||
// jstree
|
// jstree
|
||||||
var jstree = require('jstree');
|
const jstree = require('jstree');
|
||||||
require('jstree/dist/themes/default/style.css');
|
require('jstree/dist/themes/default/style.css');
|
||||||
_define('jstree', function() {
|
_define('jstree', function() {
|
||||||
return jstree;
|
return jstree;
|
||||||
});
|
});
|
||||||
|
|
||||||
// jquery
|
// jquery
|
||||||
var jquery = require('jquery');
|
const jquery = require('jquery');
|
||||||
_define('jQuery', function() {
|
_define('jQuery', function() {
|
||||||
return jquery;
|
return jquery;
|
||||||
});
|
});
|
||||||
|
|
||||||
// hlsjs
|
// hlsjs
|
||||||
var hlsjs = require('hls.js');
|
const hlsjs = require('hls.js');
|
||||||
_define('hlsjs', function() {
|
_define('hlsjs', function() {
|
||||||
return hlsjs;
|
return hlsjs;
|
||||||
});
|
});
|
||||||
|
|
||||||
// howler
|
// howler
|
||||||
var howler = require('howler');
|
const howler = require('howler');
|
||||||
_define('howler', function() {
|
_define('howler', function() {
|
||||||
return howler;
|
return howler;
|
||||||
});
|
});
|
||||||
|
|
||||||
// resize-observer-polyfill
|
// resize-observer-polyfill
|
||||||
var resize = require('resize-observer-polyfill').default;
|
const resize = require('resize-observer-polyfill').default;
|
||||||
_define('resize-observer-polyfill', function() {
|
_define('resize-observer-polyfill', function() {
|
||||||
return resize;
|
return resize;
|
||||||
});
|
});
|
||||||
|
|
||||||
// swiper
|
// swiper
|
||||||
var swiper = require('swiper/js/swiper');
|
const swiper = require('swiper/js/swiper');
|
||||||
require('swiper/css/swiper.min.css');
|
require('swiper/css/swiper.min.css');
|
||||||
_define('swiper', function() {
|
_define('swiper', function() {
|
||||||
return swiper;
|
return swiper;
|
||||||
});
|
});
|
||||||
|
|
||||||
// sortable
|
// sortable
|
||||||
var sortable = require('sortablejs').default;
|
const sortable = require('sortablejs').default;
|
||||||
_define('sortable', function() {
|
_define('sortable', function() {
|
||||||
return sortable;
|
return sortable;
|
||||||
});
|
});
|
||||||
|
|
||||||
// webcomponents
|
// webcomponents
|
||||||
var webcomponents = require('webcomponents.js/webcomponents-lite');
|
const webcomponents = require('webcomponents.js/webcomponents-lite');
|
||||||
_define('webcomponents', function() {
|
_define('webcomponents', function() {
|
||||||
return webcomponents;
|
return webcomponents;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// shaka
|
||||||
|
const shaka = require('shaka-player');
|
||||||
|
_define('shaka', function() {
|
||||||
|
return shaka;
|
||||||
|
});
|
||||||
|
|
||||||
// libass-wasm
|
// libass-wasm
|
||||||
var libassWasm = require('libass-wasm');
|
const libassWasm = require('libass-wasm');
|
||||||
_define('JavascriptSubtitlesOctopus', function() {
|
_define('JavascriptSubtitlesOctopus', function() {
|
||||||
return libassWasm;
|
return libassWasm;
|
||||||
});
|
});
|
||||||
|
|
||||||
// material-icons
|
// material-icons
|
||||||
var materialIcons = require('material-design-icons-iconfont/dist/material-design-icons.css');
|
const materialIcons = require('material-design-icons-iconfont/dist/material-design-icons.css');
|
||||||
_define('material-icons', function() {
|
_define('material-icons', function() {
|
||||||
return materialIcons;
|
return materialIcons;
|
||||||
});
|
});
|
||||||
|
|
||||||
// noto font
|
// noto font
|
||||||
var noto = require('jellyfin-noto');
|
const noto = require('jellyfin-noto');
|
||||||
_define('jellyfin-noto', function () {
|
_define('jellyfin-noto', function () {
|
||||||
return noto;
|
return noto;
|
||||||
});
|
});
|
||||||
|
|
||||||
var epubjs = require('epubjs');
|
const epubjs = require('epubjs');
|
||||||
_define('epubjs', function () {
|
_define('epubjs', function () {
|
||||||
return epubjs;
|
return epubjs;
|
||||||
});
|
});
|
||||||
|
|
||||||
// page.js
|
// page.js
|
||||||
var page = require('page');
|
const page = require('page');
|
||||||
_define('page', function() {
|
_define('page', function() {
|
||||||
return page;
|
return page;
|
||||||
});
|
});
|
||||||
|
|
||||||
// core-js
|
// core-js
|
||||||
var polyfill = require('@babel/polyfill/dist/polyfill');
|
const polyfill = require('@babel/polyfill/dist/polyfill');
|
||||||
_define('polyfill', function () {
|
_define('polyfill', function () {
|
||||||
return polyfill;
|
return polyfill;
|
||||||
});
|
});
|
||||||
|
|
||||||
// domtokenlist-shim
|
// domtokenlist-shim
|
||||||
var classlist = require('classlist.js');
|
const classlist = require('classlist.js');
|
||||||
_define('classlist-polyfill', function () {
|
_define('classlist-polyfill', function () {
|
||||||
return classlist;
|
return classlist;
|
||||||
});
|
});
|
||||||
|
|
||||||
// Date-FNS
|
// Date-FNS
|
||||||
var dateFns = require('date-fns');
|
const dateFns = require('date-fns');
|
||||||
_define('date-fns', function () {
|
_define('date-fns', function () {
|
||||||
return dateFns;
|
return dateFns;
|
||||||
});
|
});
|
||||||
|
|
||||||
var dateFnsLocale = require('date-fns/locale');
|
const dateFnsLocale = require('date-fns/locale');
|
||||||
_define('date-fns/locale', function () {
|
_define('date-fns/locale', function () {
|
||||||
return dateFnsLocale;
|
return dateFnsLocale;
|
||||||
});
|
});
|
||||||
|
|
||||||
var fast_text_encoding = require('fast-text-encoding');
|
const fast_text_encoding = require('fast-text-encoding');
|
||||||
_define('fast-text-encoding', function () {
|
_define('fast-text-encoding', function () {
|
||||||
return fast_text_encoding;
|
return fast_text_encoding;
|
||||||
});
|
});
|
||||||
|
|
||||||
// intersection-observer
|
// intersection-observer
|
||||||
var intersection_observer = require('intersection-observer');
|
const intersection_observer = require('intersection-observer');
|
||||||
_define('intersection-observer', function () {
|
_define('intersection-observer', function () {
|
||||||
return intersection_observer;
|
return intersection_observer;
|
||||||
});
|
});
|
||||||
|
|
||||||
// screenfull
|
// screenfull
|
||||||
var screenfull = require('screenfull');
|
const screenfull = require('screenfull');
|
||||||
_define('screenfull', function () {
|
_define('screenfull', function () {
|
||||||
return screenfull;
|
return screenfull;
|
||||||
});
|
});
|
||||||
|
|
||||||
// headroom.js
|
// headroom.js
|
||||||
var headroom = require('headroom.js/dist/headroom');
|
const headroom = require('headroom.js/dist/headroom');
|
||||||
_define('headroom', function () {
|
_define('headroom', function () {
|
||||||
return headroom;
|
return headroom;
|
||||||
});
|
});
|
||||||
|
|
||||||
// apiclient
|
// apiclient
|
||||||
var apiclient = require('jellyfin-apiclient');
|
const apiclient = require('jellyfin-apiclient');
|
||||||
|
|
||||||
_define('apiclient', function () {
|
_define('apiclient', function () {
|
||||||
return apiclient.ApiClient;
|
return apiclient.ApiClient;
|
||||||
|
|
|
@ -9,14 +9,14 @@ import 'scrollStyles';
|
||||||
import 'listViewStyle';
|
import 'listViewStyle';
|
||||||
|
|
||||||
function getOffsets(elems) {
|
function getOffsets(elems) {
|
||||||
let results = [];
|
const results = [];
|
||||||
|
|
||||||
if (!document) {
|
if (!document) {
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const elem of elems) {
|
for (const elem of elems) {
|
||||||
let box = elem.getBoundingClientRect();
|
const box = elem.getBoundingClientRect();
|
||||||
|
|
||||||
results.push({
|
results.push({
|
||||||
top: box.top,
|
top: box.top,
|
||||||
|
@ -34,7 +34,7 @@ function getPosition(options, dlg) {
|
||||||
const windowHeight = windowSize.innerHeight;
|
const windowHeight = windowSize.innerHeight;
|
||||||
const windowWidth = windowSize.innerWidth;
|
const windowWidth = windowSize.innerWidth;
|
||||||
|
|
||||||
let pos = getOffsets([options.positionTo])[0];
|
const pos = getOffsets([options.positionTo])[0];
|
||||||
|
|
||||||
if (options.positionY !== 'top') {
|
if (options.positionY !== 'top') {
|
||||||
pos.top += (pos.height || 0) / 2;
|
pos.top += (pos.height || 0) / 2;
|
||||||
|
@ -82,7 +82,7 @@ export function show(options) {
|
||||||
// positionTo
|
// positionTo
|
||||||
// showCancel
|
// showCancel
|
||||||
// title
|
// title
|
||||||
let dialogOptions = {
|
const dialogOptions = {
|
||||||
removeOnClose: true,
|
removeOnClose: true,
|
||||||
enableHistory: options.enableHistory,
|
enableHistory: options.enableHistory,
|
||||||
scrollY: false
|
scrollY: false
|
||||||
|
@ -103,7 +103,7 @@ export function show(options) {
|
||||||
dialogOptions.autoFocus = false;
|
dialogOptions.autoFocus = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
let dlg = dialogHelper.createDialog(dialogOptions);
|
const dlg = dialogHelper.createDialog(dialogOptions);
|
||||||
|
|
||||||
if (isFullscreen) {
|
if (isFullscreen) {
|
||||||
dlg.classList.add('actionsheet-fullscreen');
|
dlg.classList.add('actionsheet-fullscreen');
|
||||||
|
@ -129,7 +129,7 @@ export function show(options) {
|
||||||
}
|
}
|
||||||
|
|
||||||
let renderIcon = false;
|
let renderIcon = false;
|
||||||
let icons = [];
|
const icons = [];
|
||||||
let itemIcon;
|
let itemIcon;
|
||||||
for (const item of options.items) {
|
for (const item of options.items) {
|
||||||
itemIcon = item.icon || (item.selected ? 'check' : null);
|
itemIcon = item.icon || (item.selected ? 'check' : null);
|
||||||
|
@ -241,7 +241,7 @@ export function show(options) {
|
||||||
centerFocus(dlg.querySelector('.actionSheetScroller'), false, true);
|
centerFocus(dlg.querySelector('.actionSheetScroller'), false, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
let btnCloseActionSheet = dlg.querySelector('.btnCloseActionSheet');
|
const btnCloseActionSheet = dlg.querySelector('.btnCloseActionSheet');
|
||||||
if (btnCloseActionSheet) {
|
if (btnCloseActionSheet) {
|
||||||
btnCloseActionSheet.addEventListener('click', function () {
|
btnCloseActionSheet.addEventListener('click', function () {
|
||||||
dialogHelper.close(dlg);
|
dialogHelper.close(dlg);
|
||||||
|
|
|
@ -329,8 +329,8 @@ define(['loading', 'globalize', 'events', 'viewManager', 'skinManager', 'backdro
|
||||||
}
|
}
|
||||||
|
|
||||||
if (shouldExitApp) {
|
if (shouldExitApp) {
|
||||||
if (appHost.supports('exit')) {
|
if (appHost.default.supports('exit')) {
|
||||||
appHost.exit();
|
appHost.default.exit();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -1,447 +1,445 @@
|
||||||
define(['appSettings', 'browser', 'events', 'htmlMediaHelper', 'webSettings', 'globalize'], function (appSettings, browser, events, htmlMediaHelper, webSettings, globalize) {
|
import appSettings from 'appSettings';
|
||||||
'use strict';
|
import browser from 'browser';
|
||||||
|
import events from 'events';
|
||||||
|
import htmlMediaHelper from 'htmlMediaHelper';
|
||||||
|
import * as webSettings from 'webSettings';
|
||||||
|
import globalize from 'globalize';
|
||||||
|
|
||||||
browser = browser.default || browser;
|
function getBaseProfileOptions(item) {
|
||||||
|
const disableHlsVideoAudioCodecs = [];
|
||||||
|
|
||||||
function getBaseProfileOptions(item) {
|
if (item && htmlMediaHelper.enableHlsJsPlayer(item.RunTimeTicks, item.MediaType)) {
|
||||||
var disableHlsVideoAudioCodecs = [];
|
if (browser.edge) {
|
||||||
|
disableHlsVideoAudioCodecs.push('mp3');
|
||||||
|
}
|
||||||
|
|
||||||
if (item && htmlMediaHelper.enableHlsJsPlayer(item.RunTimeTicks, item.MediaType)) {
|
disableHlsVideoAudioCodecs.push('ac3');
|
||||||
if (browser.edge) {
|
disableHlsVideoAudioCodecs.push('eac3');
|
||||||
disableHlsVideoAudioCodecs.push('mp3');
|
disableHlsVideoAudioCodecs.push('opus');
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
enableMkvProgressive: false,
|
||||||
|
disableHlsVideoAudioCodecs: disableHlsVideoAudioCodecs
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function getDeviceProfile(item, options = {}) {
|
||||||
|
return new Promise(function (resolve) {
|
||||||
|
import(['browserdeviceprofile']).then(({default: profileBuilder}) => {
|
||||||
|
let profile;
|
||||||
|
|
||||||
|
if (window.NativeShell) {
|
||||||
|
profile = window.NativeShell.AppHost.getDeviceProfile(profileBuilder);
|
||||||
|
} else {
|
||||||
|
const builderOpts = getBaseProfileOptions(item);
|
||||||
|
builderOpts.enableSsaRender = (item && !options.isRetry && appSettings.get('subtitleburnin') !== 'allcomplexformats');
|
||||||
|
profile = profileBuilder(builderOpts);
|
||||||
}
|
}
|
||||||
|
|
||||||
disableHlsVideoAudioCodecs.push('ac3');
|
resolve(profile);
|
||||||
disableHlsVideoAudioCodecs.push('eac3');
|
|
||||||
disableHlsVideoAudioCodecs.push('opus');
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
enableMkvProgressive: false,
|
|
||||||
disableHlsVideoAudioCodecs: disableHlsVideoAudioCodecs
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
function getDeviceProfileForWindowsUwp(item) {
|
|
||||||
return new Promise(function (resolve, reject) {
|
|
||||||
require(['browserdeviceprofile', 'environments/windows-uwp/mediacaps'], function (profileBuilder, uwpMediaCaps) {
|
|
||||||
var profileOptions = getBaseProfileOptions(item);
|
|
||||||
profileOptions.supportsDts = uwpMediaCaps.supportsDTS();
|
|
||||||
profileOptions.supportsTrueHd = uwpMediaCaps.supportsDolby();
|
|
||||||
profileOptions.audioChannels = uwpMediaCaps.getAudioChannels();
|
|
||||||
resolve(profileBuilder(profileOptions));
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function escapeRegExp(str) {
|
||||||
|
return str.replace(/([.*+?^=!:${}()|[\]/\\])/g, '\\$1');
|
||||||
|
}
|
||||||
|
|
||||||
|
function replaceAll(originalString, strReplace, strWith) {
|
||||||
|
const strReplace2 = escapeRegExp(strReplace);
|
||||||
|
const reg = new RegExp(strReplace2, 'ig');
|
||||||
|
return originalString.replace(reg, strWith);
|
||||||
|
}
|
||||||
|
|
||||||
|
function generateDeviceId() {
|
||||||
|
const keys = [];
|
||||||
|
|
||||||
|
if (keys.push(navigator.userAgent), keys.push(new Date().getTime()), self.btoa) {
|
||||||
|
const result = replaceAll(btoa(keys.join('|')), '=', '1');
|
||||||
|
return Promise.resolve(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getDeviceProfile(item, options) {
|
return Promise.resolve(new Date().getTime());
|
||||||
options = options || {};
|
}
|
||||||
|
|
||||||
if (self.Windows) {
|
function getDeviceId() {
|
||||||
return getDeviceProfileForWindowsUwp(item);
|
const key = '_deviceId2';
|
||||||
}
|
const deviceId = appSettings.get(key);
|
||||||
|
|
||||||
return new Promise(function (resolve) {
|
if (deviceId) {
|
||||||
require(['browserdeviceprofile'], function (profileBuilder) {
|
return Promise.resolve(deviceId);
|
||||||
var profile;
|
|
||||||
|
|
||||||
if (window.NativeShell) {
|
|
||||||
profile = window.NativeShell.AppHost.getDeviceProfile(profileBuilder);
|
|
||||||
} else {
|
|
||||||
var builderOpts = getBaseProfileOptions(item);
|
|
||||||
builderOpts.enableSsaRender = (item && !options.isRetry && appSettings.get('subtitleburnin') !== 'allcomplexformats');
|
|
||||||
profile = profileBuilder(builderOpts);
|
|
||||||
}
|
|
||||||
|
|
||||||
resolve(profile);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function escapeRegExp(str) {
|
return generateDeviceId().then(function (deviceId) {
|
||||||
return str.replace(/([.*+?^=!:${}()|\[\]\/\\])/g, '\\$1');
|
appSettings.set(key, deviceId);
|
||||||
|
return deviceId;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function getDeviceName() {
|
||||||
|
var deviceName;
|
||||||
|
if (browser.tizen) {
|
||||||
|
deviceName = 'Samsung Smart TV';
|
||||||
|
} else if (browser.web0s) {
|
||||||
|
deviceName = 'LG Smart TV';
|
||||||
|
} else if (browser.operaTv) {
|
||||||
|
deviceName = 'Opera TV';
|
||||||
|
} else if (browser.xboxOne) {
|
||||||
|
deviceName = 'Xbox One';
|
||||||
|
} else if (browser.ps4) {
|
||||||
|
deviceName = 'Sony PS4';
|
||||||
|
} else if (browser.chrome) {
|
||||||
|
deviceName = 'Chrome';
|
||||||
|
} else if (browser.edgeChromium) {
|
||||||
|
deviceName = 'Edge Chromium';
|
||||||
|
} else if (browser.edge) {
|
||||||
|
deviceName = 'Edge';
|
||||||
|
} else if (browser.firefox) {
|
||||||
|
deviceName = 'Firefox';
|
||||||
|
} else if (browser.opera) {
|
||||||
|
deviceName = 'Opera';
|
||||||
|
} else if (browser.safari) {
|
||||||
|
deviceName = 'Safari';
|
||||||
|
} else {
|
||||||
|
deviceName = 'Web Browser';
|
||||||
}
|
}
|
||||||
|
|
||||||
function replaceAll(originalString, strReplace, strWith) {
|
if (browser.ipad) {
|
||||||
var strReplace2 = escapeRegExp(strReplace);
|
deviceName += ' iPad';
|
||||||
var reg = new RegExp(strReplace2, 'ig');
|
} else if (browser.iphone) {
|
||||||
return originalString.replace(reg, strWith);
|
deviceName += ' iPhone';
|
||||||
|
} else if (browser.android) {
|
||||||
|
deviceName += ' Android';
|
||||||
}
|
}
|
||||||
|
|
||||||
function generateDeviceId() {
|
if (browser.ipad) {
|
||||||
var keys = [];
|
deviceName += ' iPad';
|
||||||
|
} else if (browser.iphone) {
|
||||||
if (keys.push(navigator.userAgent), keys.push(new Date().getTime()), self.btoa) {
|
deviceName += ' iPhone';
|
||||||
var result = replaceAll(btoa(keys.join('|')), '=', '1');
|
} else if (browser.android) {
|
||||||
return Promise.resolve(result);
|
deviceName += ' Android';
|
||||||
}
|
|
||||||
|
|
||||||
return Promise.resolve(new Date().getTime());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getDeviceId() {
|
return deviceName;
|
||||||
var key = '_deviceId2';
|
}
|
||||||
var deviceId = appSettings.get(key);
|
|
||||||
|
|
||||||
if (deviceId) {
|
function supportsVoiceInput() {
|
||||||
return Promise.resolve(deviceId);
|
if (!browser.tv) {
|
||||||
}
|
return window.SpeechRecognition || window.webkitSpeechRecognition || window.mozSpeechRecognition || window.oSpeechRecognition || window.msSpeechRecognition;
|
||||||
|
|
||||||
return generateDeviceId().then(function (deviceId) {
|
|
||||||
appSettings.set(key, deviceId);
|
|
||||||
return deviceId;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getDeviceName() {
|
return false;
|
||||||
var deviceName;
|
}
|
||||||
if (browser.tizen) {
|
|
||||||
deviceName = 'Samsung Smart TV';
|
|
||||||
} else if (browser.web0s) {
|
|
||||||
deviceName = 'LG Smart TV';
|
|
||||||
} else if (browser.operaTv) {
|
|
||||||
deviceName = 'Opera TV';
|
|
||||||
} else if (browser.xboxOne) {
|
|
||||||
deviceName = 'Xbox One';
|
|
||||||
} else if (browser.ps4) {
|
|
||||||
deviceName = 'Sony PS4';
|
|
||||||
} else if (browser.chrome) {
|
|
||||||
deviceName = 'Chrome';
|
|
||||||
} else if (browser.edgeChromium) {
|
|
||||||
deviceName = 'Edge Chromium';
|
|
||||||
} else if (browser.edge) {
|
|
||||||
deviceName = 'Edge';
|
|
||||||
} else if (browser.firefox) {
|
|
||||||
deviceName = 'Firefox';
|
|
||||||
} else if (browser.opera) {
|
|
||||||
deviceName = 'Opera';
|
|
||||||
} else if (browser.safari) {
|
|
||||||
deviceName = 'Safari';
|
|
||||||
} else {
|
|
||||||
deviceName = 'Web Browser';
|
|
||||||
}
|
|
||||||
|
|
||||||
if (browser.ipad) {
|
|
||||||
deviceName += ' iPad';
|
|
||||||
} else if (browser.iphone) {
|
|
||||||
deviceName += ' iPhone';
|
|
||||||
} else if (browser.android) {
|
|
||||||
deviceName += ' Android';
|
|
||||||
}
|
|
||||||
|
|
||||||
return deviceName;
|
|
||||||
}
|
|
||||||
|
|
||||||
function supportsVoiceInput() {
|
|
||||||
if (!browser.tv) {
|
|
||||||
return window.SpeechRecognition || window.webkitSpeechRecognition || window.mozSpeechRecognition || window.oSpeechRecognition || window.msSpeechRecognition;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
function supportsFullscreen() {
|
||||||
|
if (browser.tv) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function supportsFullscreen() {
|
const element = document.documentElement;
|
||||||
if (browser.tv) {
|
return (element.requestFullscreen || element.mozRequestFullScreen || element.webkitRequestFullscreen || element.msRequestFullscreen) || document.createElement('video').webkitEnterFullscreen;
|
||||||
return false;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
var element = document.documentElement;
|
function getSyncProfile() {
|
||||||
return (element.requestFullscreen || element.mozRequestFullScreen || element.webkitRequestFullscreen || element.msRequestFullscreen) || document.createElement('video').webkitEnterFullscreen;
|
return new Promise(function (resolve) {
|
||||||
}
|
require(['browserdeviceprofile', 'appSettings'], function (profileBuilder, appSettings) {
|
||||||
|
let profile;
|
||||||
|
|
||||||
function getSyncProfile() {
|
if (window.NativeShell) {
|
||||||
return new Promise(function (resolve) {
|
profile = window.NativeShell.AppHost.getSyncProfile(profileBuilder, appSettings);
|
||||||
require(['browserdeviceprofile', 'appSettings'], function (profileBuilder, appSettings) {
|
} else {
|
||||||
var profile;
|
profile = profileBuilder();
|
||||||
|
profile.MaxStaticMusicBitrate = appSettings.maxStaticMusicBitrate();
|
||||||
|
}
|
||||||
|
|
||||||
if (window.NativeShell) {
|
resolve(profile);
|
||||||
profile = window.NativeShell.AppHost.getSyncProfile(profileBuilder, appSettings);
|
|
||||||
} else {
|
|
||||||
profile = profileBuilder();
|
|
||||||
profile.MaxStaticMusicBitrate = appSettings.maxStaticMusicBitrate();
|
|
||||||
}
|
|
||||||
|
|
||||||
resolve(profile);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function getDefaultLayout() {
|
function getDefaultLayout() {
|
||||||
return 'desktop';
|
return 'desktop';
|
||||||
}
|
}
|
||||||
|
|
||||||
function supportsHtmlMediaAutoplay() {
|
|
||||||
if (browser.edgeUwp || browser.tizen || browser.web0s || browser.orsay || browser.operaTv || browser.ps4 || browser.xboxOne) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (browser.mobile) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
function supportsHtmlMediaAutoplay() {
|
||||||
|
if (browser.edgeUwp || browser.tizen || browser.web0s || browser.orsay || browser.operaTv || browser.ps4 || browser.xboxOne) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function supportsCue() {
|
if (browser.mobile) {
|
||||||
try {
|
return false;
|
||||||
var video = document.createElement('video');
|
|
||||||
var style = document.createElement('style');
|
|
||||||
|
|
||||||
style.textContent = 'video::cue {background: inherit}';
|
|
||||||
document.body.appendChild(style);
|
|
||||||
document.body.appendChild(video);
|
|
||||||
|
|
||||||
var cue = window.getComputedStyle(video, '::cue').background;
|
|
||||||
document.body.removeChild(style);
|
|
||||||
document.body.removeChild(video);
|
|
||||||
|
|
||||||
return !!cue.length;
|
|
||||||
} catch (err) {
|
|
||||||
console.error('error detecting cue support: ' + err);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function onAppVisible() {
|
return true;
|
||||||
if (isHidden) {
|
}
|
||||||
isHidden = false;
|
|
||||||
console.debug('triggering app resume event');
|
function supportsCue() {
|
||||||
events.trigger(appHost, 'resume');
|
try {
|
||||||
}
|
const video = document.createElement('video');
|
||||||
|
const style = document.createElement('style');
|
||||||
|
|
||||||
|
style.textContent = 'video::cue {background: inherit}';
|
||||||
|
document.body.appendChild(style);
|
||||||
|
document.body.appendChild(video);
|
||||||
|
|
||||||
|
const cue = window.getComputedStyle(video, '::cue').background;
|
||||||
|
document.body.removeChild(style);
|
||||||
|
document.body.removeChild(video);
|
||||||
|
|
||||||
|
return !!cue.length;
|
||||||
|
} catch (err) {
|
||||||
|
console.error('error detecting cue support: ' + err);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function onAppVisible() {
|
||||||
|
if (isHidden) {
|
||||||
|
isHidden = false;
|
||||||
|
console.debug('triggering app resume event');
|
||||||
|
events.trigger(appHost, 'resume');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function onAppHidden() {
|
||||||
|
if (!isHidden) {
|
||||||
|
isHidden = true;
|
||||||
|
console.debug('app is hidden');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const supportedFeatures = function () {
|
||||||
|
const features = [];
|
||||||
|
|
||||||
|
if (navigator.share) {
|
||||||
|
features.push('sharing');
|
||||||
}
|
}
|
||||||
|
|
||||||
function onAppHidden() {
|
if (!browser.edgeUwp && !browser.tv && !browser.xboxOne && !browser.ps4) {
|
||||||
if (!isHidden) {
|
features.push('filedownload');
|
||||||
isHidden = true;
|
|
||||||
console.debug('app is hidden');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var supportedFeatures = function () {
|
if (browser.operaTv || browser.tizen || browser.orsay || browser.web0s) {
|
||||||
var features = [];
|
features.push('exit');
|
||||||
|
} else {
|
||||||
|
features.push('exitmenu');
|
||||||
|
features.push('plugins');
|
||||||
|
}
|
||||||
|
|
||||||
if (navigator.share) {
|
if (!browser.operaTv && !browser.tizen && !browser.orsay && !browser.web0s && !browser.ps4) {
|
||||||
features.push('sharing');
|
features.push('externallinks');
|
||||||
}
|
features.push('externalpremium');
|
||||||
|
}
|
||||||
|
|
||||||
if (!browser.edgeUwp && !browser.tv && !browser.xboxOne && !browser.ps4) {
|
if (!browser.operaTv) {
|
||||||
features.push('filedownload');
|
features.push('externallinkdisplay');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (browser.operaTv || browser.tizen || browser.orsay || browser.web0s) {
|
if (supportsVoiceInput()) {
|
||||||
features.push('exit');
|
features.push('voiceinput');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (supportsHtmlMediaAutoplay()) {
|
||||||
|
features.push('htmlaudioautoplay');
|
||||||
|
features.push('htmlvideoautoplay');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (browser.edgeUwp) {
|
||||||
|
features.push('sync');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (supportsFullscreen()) {
|
||||||
|
features.push('fullscreenchange');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (browser.tv || browser.xboxOne || browser.ps4 || browser.mobile) {
|
||||||
|
features.push('physicalvolumecontrol');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!browser.tv && !browser.xboxOne && !browser.ps4) {
|
||||||
|
features.push('remotecontrol');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!browser.operaTv && !browser.tizen && !browser.orsay && !browser.web0s && !browser.edgeUwp) {
|
||||||
|
features.push('remotevideo');
|
||||||
|
}
|
||||||
|
|
||||||
|
features.push('displaylanguage');
|
||||||
|
features.push('otherapppromotions');
|
||||||
|
features.push('displaymode');
|
||||||
|
features.push('targetblank');
|
||||||
|
features.push('screensaver');
|
||||||
|
|
||||||
|
webSettings.enableMultiServer().then(enabled => {
|
||||||
|
if (enabled) features.push('multiserver');
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!browser.orsay && (browser.firefox || browser.ps4 || browser.edge || supportsCue())) {
|
||||||
|
features.push('subtitleappearancesettings');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!browser.orsay) {
|
||||||
|
features.push('subtitleburnsettings');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!browser.tv && !browser.ps4 && !browser.xboxOne) {
|
||||||
|
features.push('fileinput');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (browser.chrome) {
|
||||||
|
features.push('chromecast');
|
||||||
|
}
|
||||||
|
|
||||||
|
return features;
|
||||||
|
}();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Do exit according to platform
|
||||||
|
*/
|
||||||
|
function doExit() {
|
||||||
|
try {
|
||||||
|
if (window.NativeShell) {
|
||||||
|
window.NativeShell.AppHost.exit();
|
||||||
|
} else if (browser.tizen) {
|
||||||
|
tizen.application.getCurrentApplication().exit();
|
||||||
|
} else if (browser.web0s) {
|
||||||
|
webOS.platformBack();
|
||||||
} else {
|
} else {
|
||||||
features.push('exitmenu');
|
window.close();
|
||||||
features.push('plugins');
|
|
||||||
}
|
}
|
||||||
|
} catch (err) {
|
||||||
|
console.error('error closing application: ' + err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!browser.operaTv && !browser.tizen && !browser.orsay && !browser.web0s && !browser.ps4) {
|
let exitPromise;
|
||||||
features.push('externallinks');
|
|
||||||
features.push('externalpremium');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!browser.operaTv) {
|
/**
|
||||||
features.push('externallinkdisplay');
|
* Ask user for exit
|
||||||
}
|
*/
|
||||||
|
function askForExit() {
|
||||||
if (supportsVoiceInput()) {
|
if (exitPromise) {
|
||||||
features.push('voiceinput');
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
if (supportsHtmlMediaAutoplay()) {
|
|
||||||
features.push('htmlaudioautoplay');
|
|
||||||
features.push('htmlvideoautoplay');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (browser.edgeUwp) {
|
|
||||||
features.push('sync');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (supportsFullscreen()) {
|
|
||||||
features.push('fullscreenchange');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (browser.tv || browser.xboxOne || browser.ps4 || browser.mobile) {
|
|
||||||
features.push('physicalvolumecontrol');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!browser.tv && !browser.xboxOne && !browser.ps4) {
|
|
||||||
features.push('remotecontrol');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!browser.operaTv && !browser.tizen && !browser.orsay && !browser.web0s && !browser.edgeUwp) {
|
|
||||||
features.push('remotevideo');
|
|
||||||
}
|
|
||||||
|
|
||||||
features.push('displaylanguage');
|
|
||||||
features.push('otherapppromotions');
|
|
||||||
features.push('displaymode');
|
|
||||||
features.push('targetblank');
|
|
||||||
features.push('screensaver');
|
|
||||||
|
|
||||||
webSettings.getMultiServer().then(enabled => {
|
|
||||||
if (enabled) features.push('multiserver');
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!browser.orsay && (browser.firefox || browser.ps4 || browser.edge || supportsCue())) {
|
|
||||||
features.push('subtitleappearancesettings');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!browser.orsay) {
|
|
||||||
features.push('subtitleburnsettings');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!browser.tv && !browser.ps4 && !browser.xboxOne) {
|
|
||||||
features.push('fileinput');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (browser.chrome || browser.edgeChromium) {
|
|
||||||
features.push('chromecast');
|
|
||||||
}
|
|
||||||
|
|
||||||
return features;
|
|
||||||
}();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Do exit according to platform
|
|
||||||
*/
|
|
||||||
function doExit() {
|
|
||||||
try {
|
|
||||||
if (window.NativeShell) {
|
|
||||||
window.NativeShell.AppHost.exit();
|
|
||||||
} else if (browser.tizen) {
|
|
||||||
tizen.application.getCurrentApplication().exit();
|
|
||||||
} else if (browser.web0s) {
|
|
||||||
webOS.platformBack();
|
|
||||||
} else {
|
|
||||||
window.close();
|
|
||||||
}
|
|
||||||
} catch (err) {
|
|
||||||
console.error('error closing application: ' + err);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var exitPromise;
|
require(['actionsheet'], function (actionsheet) {
|
||||||
|
exitPromise = actionsheet.show({
|
||||||
/**
|
title: globalize.translate('MessageConfirmAppExit'),
|
||||||
* Ask user for exit
|
items: [
|
||||||
*/
|
{id: 'yes', name: globalize.translate('Yes')},
|
||||||
function askForExit() {
|
{id: 'no', name: globalize.translate('No')}
|
||||||
if (exitPromise) {
|
]
|
||||||
return;
|
}).then(function (value) {
|
||||||
}
|
if (value === 'yes') {
|
||||||
|
|
||||||
require(['actionsheet'], function (actionsheet) {
|
|
||||||
exitPromise = actionsheet.show({
|
|
||||||
title: globalize.translate('MessageConfirmAppExit'),
|
|
||||||
items: [
|
|
||||||
{id: 'yes', name: globalize.translate('Yes')},
|
|
||||||
{id: 'no', name: globalize.translate('No')}
|
|
||||||
]
|
|
||||||
}).then(function (value) {
|
|
||||||
if (value === 'yes') {
|
|
||||||
doExit();
|
|
||||||
}
|
|
||||||
}).finally(function () {
|
|
||||||
exitPromise = null;
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
var deviceId;
|
|
||||||
var deviceName;
|
|
||||||
var appName = 'Jellyfin Web';
|
|
||||||
var appVersion = '10.7.0';
|
|
||||||
|
|
||||||
var appHost = {
|
|
||||||
getWindowState: function () {
|
|
||||||
return document.windowState || 'Normal';
|
|
||||||
},
|
|
||||||
setWindowState: function (state) {
|
|
||||||
alert('setWindowState is not supported and should not be called');
|
|
||||||
},
|
|
||||||
exit: function () {
|
|
||||||
if (!!window.appMode && browser.tizen) {
|
|
||||||
askForExit();
|
|
||||||
} else {
|
|
||||||
doExit();
|
doExit();
|
||||||
}
|
}
|
||||||
},
|
}).finally(function () {
|
||||||
supports: function (command) {
|
exitPromise = null;
|
||||||
if (window.NativeShell) {
|
});
|
||||||
return window.NativeShell.AppHost.supports(command);
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return supportedFeatures.indexOf(command.toLowerCase()) !== -1;
|
let deviceId;
|
||||||
},
|
let deviceName;
|
||||||
preferVisualCards: browser.android || browser.chrome,
|
const appName = 'Jellyfin Web';
|
||||||
getSyncProfile: getSyncProfile,
|
const appVersion = '10.6.0';
|
||||||
getDefaultLayout: function () {
|
|
||||||
if (window.NativeShell) {
|
|
||||||
return window.NativeShell.AppHost.getDefaultLayout();
|
|
||||||
}
|
|
||||||
|
|
||||||
return getDefaultLayout();
|
const appHost = {
|
||||||
},
|
getWindowState: function () {
|
||||||
getDeviceProfile: getDeviceProfile,
|
return document.windowState || 'Normal';
|
||||||
init: function () {
|
},
|
||||||
if (window.NativeShell) {
|
setWindowState: function () {
|
||||||
return window.NativeShell.AppHost.init();
|
alert('setWindowState is not supported and should not be called');
|
||||||
}
|
},
|
||||||
|
exit: function () {
|
||||||
deviceName = getDeviceName();
|
if (!!window.appMode && browser.tizen) {
|
||||||
getDeviceId().then(function (id) {
|
askForExit();
|
||||||
deviceId = id;
|
|
||||||
});
|
|
||||||
},
|
|
||||||
deviceName: function () {
|
|
||||||
return window.NativeShell ? window.NativeShell.AppHost.deviceName() : deviceName;
|
|
||||||
},
|
|
||||||
deviceId: function () {
|
|
||||||
return window.NativeShell ? window.NativeShell.AppHost.deviceId() : deviceId;
|
|
||||||
},
|
|
||||||
appName: function () {
|
|
||||||
return window.NativeShell ? window.NativeShell.AppHost.appName() : appName;
|
|
||||||
},
|
|
||||||
appVersion: function () {
|
|
||||||
return window.NativeShell ? window.NativeShell.AppHost.appVersion() : appVersion;
|
|
||||||
},
|
|
||||||
getPushTokenInfo: function () {
|
|
||||||
return {};
|
|
||||||
},
|
|
||||||
setUserScalable: function (scalable) {
|
|
||||||
if (!browser.tv) {
|
|
||||||
var att = scalable ? 'width=device-width, initial-scale=1, minimum-scale=1, user-scalable=yes' : 'width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no';
|
|
||||||
document.querySelector('meta[name=viewport]').setAttribute('content', att);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
var isHidden = false;
|
|
||||||
var hidden;
|
|
||||||
var visibilityChange;
|
|
||||||
|
|
||||||
if (typeof document.hidden !== 'undefined') { /* eslint-disable-line compat/compat */
|
|
||||||
hidden = 'hidden';
|
|
||||||
visibilityChange = 'visibilitychange';
|
|
||||||
} else if (typeof document.webkitHidden !== 'undefined') {
|
|
||||||
hidden = 'webkitHidden';
|
|
||||||
visibilityChange = 'webkitvisibilitychange';
|
|
||||||
}
|
|
||||||
|
|
||||||
document.addEventListener(visibilityChange, function () {
|
|
||||||
/* eslint-disable-next-line compat/compat */
|
|
||||||
if (document[hidden]) {
|
|
||||||
onAppHidden();
|
|
||||||
} else {
|
} else {
|
||||||
onAppVisible();
|
doExit();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
supports: function (command) {
|
||||||
|
if (window.NativeShell) {
|
||||||
|
return window.NativeShell.AppHost.supports(command);
|
||||||
}
|
}
|
||||||
}, false);
|
|
||||||
|
|
||||||
if (self.addEventListener) {
|
return supportedFeatures.indexOf(command.toLowerCase()) !== -1;
|
||||||
self.addEventListener('focus', onAppVisible);
|
},
|
||||||
self.addEventListener('blur', onAppHidden);
|
preferVisualCards: browser.android || browser.chrome,
|
||||||
|
getSyncProfile: getSyncProfile,
|
||||||
|
getDefaultLayout: function () {
|
||||||
|
if (window.NativeShell) {
|
||||||
|
return window.NativeShell.AppHost.getDefaultLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
return getDefaultLayout();
|
||||||
|
},
|
||||||
|
getDeviceProfile: getDeviceProfile,
|
||||||
|
init: function () {
|
||||||
|
if (window.NativeShell) {
|
||||||
|
return window.NativeShell.AppHost.init();
|
||||||
|
}
|
||||||
|
|
||||||
|
deviceName = getDeviceName();
|
||||||
|
getDeviceId().then(function (id) {
|
||||||
|
deviceId = id;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
deviceName: function () {
|
||||||
|
return window.NativeShell ? window.NativeShell.AppHost.deviceName() : deviceName;
|
||||||
|
},
|
||||||
|
deviceId: function () {
|
||||||
|
return window.NativeShell ? window.NativeShell.AppHost.deviceId() : deviceId;
|
||||||
|
},
|
||||||
|
appName: function () {
|
||||||
|
return window.NativeShell ? window.NativeShell.AppHost.appName() : appName;
|
||||||
|
},
|
||||||
|
appVersion: function () {
|
||||||
|
return window.NativeShell ? window.NativeShell.AppHost.appVersion() : appVersion;
|
||||||
|
},
|
||||||
|
getPushTokenInfo: function () {
|
||||||
|
return {};
|
||||||
|
},
|
||||||
|
setThemeColor: function (color) {
|
||||||
|
const metaThemeColor = document.querySelector('meta[name=theme-color]');
|
||||||
|
|
||||||
|
if (metaThemeColor) {
|
||||||
|
metaThemeColor.setAttribute('content', color);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
setUserScalable: function (scalable) {
|
||||||
|
if (!browser.tv) {
|
||||||
|
const att = scalable ? 'width=device-width, initial-scale=1, minimum-scale=1, user-scalable=yes' : 'width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no';
|
||||||
|
document.querySelector('meta[name=viewport]').setAttribute('content', att);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return appHost;
|
let isHidden = false;
|
||||||
});
|
let hidden;
|
||||||
|
let visibilityChange;
|
||||||
|
|
||||||
|
if (typeof document.hidden !== 'undefined') { /* eslint-disable-line compat/compat */
|
||||||
|
hidden = 'hidden';
|
||||||
|
visibilityChange = 'visibilitychange';
|
||||||
|
} else if (typeof document.webkitHidden !== 'undefined') {
|
||||||
|
hidden = 'webkitHidden';
|
||||||
|
visibilityChange = 'webkitvisibilitychange';
|
||||||
|
}
|
||||||
|
|
||||||
|
document.addEventListener(visibilityChange, function () {
|
||||||
|
/* eslint-disable-next-line compat/compat */
|
||||||
|
if (document[hidden]) {
|
||||||
|
onAppHidden();
|
||||||
|
} else {
|
||||||
|
onAppVisible();
|
||||||
|
}
|
||||||
|
}, false);
|
||||||
|
|
||||||
|
if (self.addEventListener) {
|
||||||
|
self.addEventListener('focus', onAppVisible);
|
||||||
|
self.addEventListener('blur', onAppHidden);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default appHost;
|
||||||
|
|
|
@ -362,12 +362,12 @@ import 'programStyles';
|
||||||
let hasOpenRow;
|
let hasOpenRow;
|
||||||
let hasOpenSection;
|
let hasOpenSection;
|
||||||
|
|
||||||
let sectionTitleTagName = options.sectionTitleTagName || 'div';
|
const sectionTitleTagName = options.sectionTitleTagName || 'div';
|
||||||
let apiClient;
|
let apiClient;
|
||||||
let lastServerId;
|
let lastServerId;
|
||||||
|
|
||||||
for (const [i, item] of items.entries()) {
|
for (const [i, item] of items.entries()) {
|
||||||
let serverId = item.ServerId || options.serverId;
|
const serverId = item.ServerId || options.serverId;
|
||||||
|
|
||||||
if (serverId !== lastServerId) {
|
if (serverId !== lastServerId) {
|
||||||
lastServerId = serverId;
|
lastServerId = serverId;
|
||||||
|
@ -621,7 +621,7 @@ import 'programStyles';
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
let blurHashes = options.imageBlurhashes || item.ImageBlurHashes || {};
|
const blurHashes = options.imageBlurhashes || item.ImageBlurHashes || {};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
imgUrl: imgUrl,
|
imgUrl: imgUrl,
|
||||||
|
@ -656,7 +656,7 @@ import 'programStyles';
|
||||||
for (let i = 0; i < character.length; i++) {
|
for (let i = 0; i < character.length; i++) {
|
||||||
sum += parseInt(character.charAt(i));
|
sum += parseInt(character.charAt(i));
|
||||||
}
|
}
|
||||||
let index = String(sum).substr(-1);
|
const index = String(sum).substr(-1);
|
||||||
|
|
||||||
return (index % numRandomColors) + 1;
|
return (index % numRandomColors) + 1;
|
||||||
} else {
|
} else {
|
||||||
|
@ -682,7 +682,7 @@ import 'programStyles';
|
||||||
|
|
||||||
for (let i = 0; i < lines.length; i++) {
|
for (let i = 0; i < lines.length; i++) {
|
||||||
let currentCssClass = cssClass;
|
let currentCssClass = cssClass;
|
||||||
let text = lines[i];
|
const text = lines[i];
|
||||||
|
|
||||||
if (valid > 0 && isOuterFooter) {
|
if (valid > 0 && isOuterFooter) {
|
||||||
currentCssClass += ' cardText-secondary';
|
currentCssClass += ' cardText-secondary';
|
||||||
|
@ -707,7 +707,7 @@ import 'programStyles';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (forceLines) {
|
if (forceLines) {
|
||||||
let linesLength = maxLines || Math.min(lines.length, maxLines || lines.length);
|
const linesLength = maxLines || Math.min(lines.length, maxLines || lines.length);
|
||||||
|
|
||||||
while (valid < linesLength) {
|
while (valid < linesLength) {
|
||||||
html += "<div class='" + cssClass + "'> </div>";
|
html += "<div class='" + cssClass + "'> </div>";
|
||||||
|
@ -1036,7 +1036,7 @@ import 'programStyles';
|
||||||
* @returns {string} HTML markup for the item count indicator.
|
* @returns {string} HTML markup for the item count indicator.
|
||||||
*/
|
*/
|
||||||
function getItemCountsHtml(options, item) {
|
function getItemCountsHtml(options, item) {
|
||||||
let counts = [];
|
const counts = [];
|
||||||
let childText;
|
let childText;
|
||||||
|
|
||||||
if (item.Type === 'Playlist') {
|
if (item.Type === 'Playlist') {
|
||||||
|
@ -1318,7 +1318,7 @@ import 'programStyles';
|
||||||
let cardBoxClose = '';
|
let cardBoxClose = '';
|
||||||
let cardScalableClose = '';
|
let cardScalableClose = '';
|
||||||
|
|
||||||
let cardContentClass = 'cardContent';
|
const cardContentClass = 'cardContent';
|
||||||
|
|
||||||
let blurhashAttrib = '';
|
let blurhashAttrib = '';
|
||||||
if (blurhash && blurhash.length > 0) {
|
if (blurhash && blurhash.length > 0) {
|
||||||
|
@ -1337,7 +1337,7 @@ import 'programStyles';
|
||||||
cardImageContainerClose = '</button>';
|
cardImageContainerClose = '</button>';
|
||||||
}
|
}
|
||||||
|
|
||||||
let cardScalableClass = 'cardScalable';
|
const cardScalableClass = 'cardScalable';
|
||||||
|
|
||||||
cardImageContainerOpen = '<div class="' + cardBoxClass + '"><div class="' + cardScalableClass + '"><div class="cardPadder cardPadder-' + shape + '"></div>' + cardImageContainerOpen;
|
cardImageContainerOpen = '<div class="' + cardBoxClass + '"><div class="' + cardScalableClass + '"><div class="cardPadder cardPadder-' + shape + '"></div>' + cardImageContainerOpen;
|
||||||
cardBoxClose = '</div>';
|
cardBoxClose = '</div>';
|
||||||
|
@ -1681,7 +1681,7 @@ import 'programStyles';
|
||||||
const cells = itemsContainer.querySelectorAll('.card[data-id="' + programId + '"]');
|
const cells = itemsContainer.querySelectorAll('.card[data-id="' + programId + '"]');
|
||||||
|
|
||||||
for (let i = 0, length = cells.length; i < length; i++) {
|
for (let i = 0, length = cells.length; i < length; i++) {
|
||||||
let cell = cells[i];
|
const cell = cells[i];
|
||||||
const icon = cell.querySelector('.timerIndicator');
|
const icon = cell.querySelector('.timerIndicator');
|
||||||
if (!icon) {
|
if (!icon) {
|
||||||
const indicatorsElem = ensureIndicators(cell);
|
const indicatorsElem = ensureIndicators(cell);
|
||||||
|
@ -1700,8 +1700,8 @@ import 'programStyles';
|
||||||
const cells = itemsContainer.querySelectorAll('.card[data-timerid="' + timerId + '"]');
|
const cells = itemsContainer.querySelectorAll('.card[data-timerid="' + timerId + '"]');
|
||||||
|
|
||||||
for (let i = 0; i < cells.length; i++) {
|
for (let i = 0; i < cells.length; i++) {
|
||||||
let cell = cells[i];
|
const cell = cells[i];
|
||||||
let icon = cell.querySelector('.timerIndicator');
|
const icon = cell.querySelector('.timerIndicator');
|
||||||
if (icon) {
|
if (icon) {
|
||||||
icon.parentNode.removeChild(icon);
|
icon.parentNode.removeChild(icon);
|
||||||
}
|
}
|
||||||
|
@ -1718,8 +1718,8 @@ import 'programStyles';
|
||||||
const cells = itemsContainer.querySelectorAll('.card[data-seriestimerid="' + cancelledTimerId + '"]');
|
const cells = itemsContainer.querySelectorAll('.card[data-seriestimerid="' + cancelledTimerId + '"]');
|
||||||
|
|
||||||
for (let i = 0; i < cells.length; i++) {
|
for (let i = 0; i < cells.length; i++) {
|
||||||
let cell = cells[i];
|
const cell = cells[i];
|
||||||
let icon = cell.querySelector('.timerIndicator');
|
const icon = cell.querySelector('.timerIndicator');
|
||||||
if (icon) {
|
if (icon) {
|
||||||
icon.parentNode.removeChild(icon);
|
icon.parentNode.removeChild(icon);
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,13 +75,13 @@ import 'emby-button';
|
||||||
context.querySelector('.languageSection').classList.add('hide');
|
context.querySelector('.languageSection').classList.add('hide');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (appHost.supports('displaymode')) {
|
if (appHost.default.supports('displaymode')) {
|
||||||
context.querySelector('.fldDisplayMode').classList.remove('hide');
|
context.querySelector('.fldDisplayMode').classList.remove('hide');
|
||||||
} else {
|
} else {
|
||||||
context.querySelector('.fldDisplayMode').classList.add('hide');
|
context.querySelector('.fldDisplayMode').classList.add('hide');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (appHost.supports('externallinks')) {
|
if (appHost.default.supports('externallinks')) {
|
||||||
context.querySelector('.learnHowToContributeContainer').classList.remove('hide');
|
context.querySelector('.learnHowToContributeContainer').classList.remove('hide');
|
||||||
} else {
|
} else {
|
||||||
context.querySelector('.learnHowToContributeContainer').classList.add('hide');
|
context.querySelector('.learnHowToContributeContainer').classList.add('hide');
|
||||||
|
@ -136,7 +136,7 @@ import 'emby-button';
|
||||||
function saveUser(context, user, userSettingsInstance, apiClient) {
|
function saveUser(context, user, userSettingsInstance, apiClient) {
|
||||||
user.Configuration.DisplayMissingEpisodes = context.querySelector('.chkDisplayMissingEpisodes').checked;
|
user.Configuration.DisplayMissingEpisodes = context.querySelector('.chkDisplayMissingEpisodes').checked;
|
||||||
|
|
||||||
if (appHost.supports('displaylanguage')) {
|
if (appHost.default.supports('displaylanguage')) {
|
||||||
userSettingsInstance.language(context.querySelector('#selectLanguage').value);
|
userSettingsInstance.language(context.querySelector('#selectLanguage').value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -208,7 +208,7 @@ import 'cardStyle';
|
||||||
html += '<div class="cardPadder-' + shape + '"></div>';
|
html += '<div class="cardPadder-' + shape + '"></div>';
|
||||||
html += '<div class="cardContent">';
|
html += '<div class="cardContent">';
|
||||||
|
|
||||||
if (layoutManager.tv || !appHost.supports('externallinks')) {
|
if (layoutManager.tv || !appHost.default.supports('externallinks')) {
|
||||||
html += '<div class="cardImageContainer lazy" data-src="' + getDisplayUrl(image.Url, apiClient) + '" style="background-position:center center;background-size:contain;"></div>';
|
html += '<div class="cardImageContainer lazy" data-src="' + getDisplayUrl(image.Url, apiClient) + '" style="background-position:center center;background-size:contain;"></div>';
|
||||||
} else {
|
} else {
|
||||||
html += '<a is="emby-linkbutton" target="_blank" href="' + getDisplayUrl(image.Url, apiClient) + '" class="button-link cardImageContainer lazy" data-src="' + getDisplayUrl(image.Url, apiClient) + '" style="background-position:center center;background-size:contain"></a>';
|
html += '<a is="emby-linkbutton" target="_blank" href="' + getDisplayUrl(image.Url, apiClient) + '" class="button-link cardImageContainer lazy" data-src="' + getDisplayUrl(image.Url, apiClient) + '" style="background-position:center center;background-size:contain"></a>';
|
||||||
|
|
|
@ -17,8 +17,8 @@ import 'css!./style';
|
||||||
// Although the default values recommended by Blurhash developers is 32x32, a size of 18x18 seems to be the sweet spot for us,
|
// Although the default values recommended by Blurhash developers is 32x32, a size of 18x18 seems to be the sweet spot for us,
|
||||||
// improving the performance and reducing the memory usage, while retaining almost full blur quality.
|
// improving the performance and reducing the memory usage, while retaining almost full blur quality.
|
||||||
// Lower values had more visible pixelation
|
// Lower values had more visible pixelation
|
||||||
let width = 18;
|
const width = 18;
|
||||||
let height = 18;
|
const height = 18;
|
||||||
let pixels;
|
let pixels;
|
||||||
try {
|
try {
|
||||||
pixels = blurhash.decode(blurhashstr, width, height);
|
pixels = blurhash.decode(blurhashstr, width, height);
|
||||||
|
@ -27,11 +27,11 @@ import 'css!./style';
|
||||||
target.classList.add('non-blurhashable');
|
target.classList.add('non-blurhashable');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let canvas = document.createElement('canvas');
|
const canvas = document.createElement('canvas');
|
||||||
canvas.width = width;
|
canvas.width = width;
|
||||||
canvas.height = height;
|
canvas.height = height;
|
||||||
let ctx = canvas.getContext('2d');
|
const ctx = canvas.getContext('2d');
|
||||||
let imgData = ctx.createImageData(width, height);
|
const imgData = ctx.createImageData(width, height);
|
||||||
|
|
||||||
imgData.data.set(pixels);
|
imgData.data.set(pixels);
|
||||||
ctx.putImageData(imgData, 0, 0);
|
ctx.putImageData(imgData, 0, 0);
|
||||||
|
@ -55,7 +55,7 @@ import 'css!./style';
|
||||||
if (!entry) {
|
if (!entry) {
|
||||||
throw new Error('entry cannot be null');
|
throw new Error('entry cannot be null');
|
||||||
}
|
}
|
||||||
let target = entry.target;
|
const target = entry.target;
|
||||||
var source = undefined;
|
var source = undefined;
|
||||||
|
|
||||||
if (target) {
|
if (target) {
|
||||||
|
@ -78,7 +78,7 @@ import 'css!./style';
|
||||||
throw new TypeError('url cannot be undefined');
|
throw new TypeError('url cannot be undefined');
|
||||||
}
|
}
|
||||||
|
|
||||||
let preloaderImg = new Image();
|
const preloaderImg = new Image();
|
||||||
preloaderImg.src = url;
|
preloaderImg.src = url;
|
||||||
|
|
||||||
elem.classList.add('lazy-hidden');
|
elem.classList.add('lazy-hidden');
|
||||||
|
|
|
@ -82,7 +82,7 @@ export function enablePlayedIndicator(item) {
|
||||||
|
|
||||||
export function getPlayedIndicatorHtml(item) {
|
export function getPlayedIndicatorHtml(item) {
|
||||||
if (enablePlayedIndicator(item)) {
|
if (enablePlayedIndicator(item)) {
|
||||||
let userData = item.UserData || {};
|
const userData = item.UserData || {};
|
||||||
if (userData.UnplayedItemCount) {
|
if (userData.UnplayedItemCount) {
|
||||||
return '<div class="countIndicator indicator">' + userData.UnplayedItemCount + '</div>';
|
return '<div class="countIndicator indicator">' + userData.UnplayedItemCount + '</div>';
|
||||||
}
|
}
|
||||||
|
|
|
@ -158,7 +158,7 @@ import actionsheet from 'actionsheet';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Books are promoted to major download Button and therefor excluded in the context menu
|
// Books are promoted to major download Button and therefor excluded in the context menu
|
||||||
if ((item.CanDownload && appHost.supports('filedownload')) && item.Type !== 'Book') {
|
if ((item.CanDownload && appHost.default.supports('filedownload')) && item.Type !== 'Book') {
|
||||||
commands.push({
|
commands.push({
|
||||||
name: globalize.translate('Download'),
|
name: globalize.translate('Download'),
|
||||||
id: 'download',
|
id: 'download',
|
||||||
|
|
|
@ -196,7 +196,7 @@ import 'css!./multiSelect';
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (user.Policy.EnableContentDownloading && appHost.supports('filedownload')) {
|
if (user.Policy.EnableContentDownloading && appHost.default.supports('filedownload')) {
|
||||||
menuItems.push({
|
menuItems.push({
|
||||||
name: globalize.translate('ButtonDownload'),
|
name: globalize.translate('ButtonDownload'),
|
||||||
id: 'download',
|
id: 'download',
|
||||||
|
|
|
@ -415,7 +415,7 @@ import 'emby-ratingbutton';
|
||||||
showVolumeSlider = false;
|
showVolumeSlider = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (currentPlayer.isLocalPlayer && appHost.supports('physicalvolumecontrol')) {
|
if (currentPlayer.isLocalPlayer && appHost.default.supports('physicalvolumecontrol')) {
|
||||||
showMuteButton = false;
|
showMuteButton = false;
|
||||||
showVolumeSlider = false;
|
showVolumeSlider = false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -127,7 +127,7 @@ import connectionManager from 'connectionManager';
|
||||||
artwork: getImageUrls(item)
|
artwork: getImageUrls(item)
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
let itemImageUrl = seriesImageUrl(item, { maxHeight: 3000 }) || imageUrl(item, { maxHeight: 3000 });
|
const itemImageUrl = seriesImageUrl(item, { maxHeight: 3000 }) || imageUrl(item, { maxHeight: 3000 });
|
||||||
|
|
||||||
window.NativeShell.updateMediaSession({
|
window.NativeShell.updateMediaSession({
|
||||||
action: eventName,
|
action: eventName,
|
||||||
|
@ -244,10 +244,10 @@ import connectionManager from 'connectionManager';
|
||||||
|
|
||||||
/* eslint-disable-next-line compat/compat */
|
/* eslint-disable-next-line compat/compat */
|
||||||
navigator.mediaSession.setActionHandler('seekto', function (object) {
|
navigator.mediaSession.setActionHandler('seekto', function (object) {
|
||||||
let item = playbackManager.getPlayerState(currentPlayer).NowPlayingItem;
|
const item = playbackManager.getPlayerState(currentPlayer).NowPlayingItem;
|
||||||
// Convert to ms
|
// Convert to ms
|
||||||
let duration = parseInt(item.RunTimeTicks ? (item.RunTimeTicks / 10000) : 0);
|
const duration = parseInt(item.RunTimeTicks ? (item.RunTimeTicks / 10000) : 0);
|
||||||
let wantedTime = object.seekTime * 1000;
|
const wantedTime = object.seekTime * 1000;
|
||||||
playbackManager.seekPercent(wantedTime / duration * 100, currentPlayer);
|
playbackManager.seekPercent(wantedTime / duration * 100, currentPlayer);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -3520,7 +3520,7 @@ class PlaybackManager {
|
||||||
'PlayTrailers'
|
'PlayTrailers'
|
||||||
];
|
];
|
||||||
|
|
||||||
if (apphost.supports('fullscreenchange')) {
|
if (appHost.default.supports('fullscreenchange')) {
|
||||||
list.push('ToggleFullscreen');
|
list.push('ToggleFullscreen');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -121,7 +121,7 @@ export function show(button) {
|
||||||
|
|
||||||
// Unfortunately we can't allow the url to change or chromecast will throw a security error
|
// Unfortunately we can't allow the url to change or chromecast will throw a security error
|
||||||
// Might be able to solve this in the future by moving the dialogs to hashbangs
|
// Might be able to solve this in the future by moving the dialogs to hashbangs
|
||||||
if (!(!browser.chrome && !browser.edgeChromium || appHost.supports('castmenuhashchange'))) {
|
if (!(!browser.chrome && !browser.edgeChromium || appHost.default.supports('castmenuhashchange'))) {
|
||||||
menuOptions.enableHistory = false;
|
menuOptions.enableHistory = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -98,7 +98,7 @@ import 'emby-checkbox';
|
||||||
context.querySelector('.videoQualitySection').classList.add('hide');
|
context.querySelector('.videoQualitySection').classList.add('hide');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (appHost.supports('multiserver')) {
|
if (appHost.default.supports('multiserver')) {
|
||||||
context.querySelector('.fldVideoInNetworkQuality').classList.remove('hide');
|
context.querySelector('.fldVideoInNetworkQuality').classList.remove('hide');
|
||||||
context.querySelector('.fldVideoInternetQuality').classList.remove('hide');
|
context.querySelector('.fldVideoInternetQuality').classList.remove('hide');
|
||||||
|
|
||||||
|
@ -162,7 +162,7 @@ import 'emby-checkbox';
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (appHost.supports('externalplayerintent') && userId === loggedInUserId) {
|
if (appHost.default.supports('externalplayerintent') && userId === loggedInUserId) {
|
||||||
context.querySelector('.fldExternalPlayer').classList.remove('hide');
|
context.querySelector('.fldExternalPlayer').classList.remove('hide');
|
||||||
} else {
|
} else {
|
||||||
context.querySelector('.fldExternalPlayer').classList.add('hide');
|
context.querySelector('.fldExternalPlayer').classList.add('hide');
|
||||||
|
@ -171,7 +171,7 @@ import 'emby-checkbox';
|
||||||
if (userId === loggedInUserId && (user.Policy.EnableVideoPlaybackTranscoding || user.Policy.EnableAudioPlaybackTranscoding)) {
|
if (userId === loggedInUserId && (user.Policy.EnableVideoPlaybackTranscoding || user.Policy.EnableAudioPlaybackTranscoding)) {
|
||||||
context.querySelector('.qualitySections').classList.remove('hide');
|
context.querySelector('.qualitySections').classList.remove('hide');
|
||||||
|
|
||||||
if (appHost.supports('chromecast') && user.Policy.EnableVideoPlaybackTranscoding) {
|
if (appHost.default.supports('chromecast') && user.Policy.EnableVideoPlaybackTranscoding) {
|
||||||
context.querySelector('.fldChromecastQuality').classList.remove('hide');
|
context.querySelector('.fldChromecastQuality').classList.remove('hide');
|
||||||
} else {
|
} else {
|
||||||
context.querySelector('.fldChromecastQuality').classList.add('hide');
|
context.querySelector('.fldChromecastQuality').classList.add('hide');
|
||||||
|
|
|
@ -1,160 +1,165 @@
|
||||||
define(['globalize'], function (globalize) {
|
import globalize from 'globalize';
|
||||||
'use strict';
|
|
||||||
|
|
||||||
function getVideoQualityOptions(options) {
|
export function getVideoQualityOptions(options) {
|
||||||
var maxStreamingBitrate = options.currentMaxBitrate;
|
|
||||||
var videoWidth = options.videoWidth;
|
|
||||||
var videoHeight = options.videoHeight;
|
|
||||||
|
|
||||||
// If the aspect ratio is less than 16/9 (1.77), set the width as if it were pillarboxed.
|
var maxStreamingBitrate = options.currentMaxBitrate;
|
||||||
// 4:3 1440x1080 -> 1920x1080
|
var videoWidth = options.videoWidth;
|
||||||
if (videoWidth / videoHeight < 16 / 9) {
|
var videoHeight = options.videoHeight;
|
||||||
videoWidth = videoHeight * (16 / 9);
|
|
||||||
}
|
|
||||||
|
|
||||||
var maxAllowedWidth = videoWidth || 4096;
|
// If the aspect ratio is less than 16/9 (1.77), set the width as if it were pillarboxed.
|
||||||
|
// 4:3 1440x1080 -> 1920x1080
|
||||||
var qualityOptions = [];
|
if (videoWidth / videoHeight < 16 / 9) {
|
||||||
|
videoWidth = videoHeight * (16 / 9);
|
||||||
if (maxAllowedWidth >= 3800) {
|
|
||||||
qualityOptions.push({ name: '4K - 120 Mbps', maxHeight: 2160, bitrate: 120000000 });
|
|
||||||
qualityOptions.push({ name: '4K - 100 Mbps', maxHeight: 2160, bitrate: 100000000 });
|
|
||||||
qualityOptions.push({ name: '4K - 80 Mbps', maxHeight: 2160, bitrate: 80000000 });
|
|
||||||
}
|
|
||||||
|
|
||||||
// Some 1080- videos are reported as 1912?
|
|
||||||
if (maxAllowedWidth >= 1900) {
|
|
||||||
qualityOptions.push({ name: '1080p - 60 Mbps', maxHeight: 1080, bitrate: 60000000 });
|
|
||||||
qualityOptions.push({ name: '1080p - 50 Mbps', maxHeight: 1080, bitrate: 50000000 });
|
|
||||||
qualityOptions.push({ name: '1080p - 40 Mbps', maxHeight: 1080, bitrate: 40000000 });
|
|
||||||
qualityOptions.push({ name: '1080p - 30 Mbps', maxHeight: 1080, bitrate: 30000000 });
|
|
||||||
qualityOptions.push({ name: '1080p - 25 Mbps', maxHeight: 1080, bitrate: 25000000 });
|
|
||||||
qualityOptions.push({ name: '1080p - 20 Mbps', maxHeight: 1080, bitrate: 20000000 });
|
|
||||||
qualityOptions.push({ name: '1080p - 15 Mbps', maxHeight: 1080, bitrate: 15000000 });
|
|
||||||
qualityOptions.push({ name: '1080p - 10 Mbps', maxHeight: 1080, bitrate: 10000001 });
|
|
||||||
qualityOptions.push({ name: '1080p - 8 Mbps', maxHeight: 1080, bitrate: 8000001 });
|
|
||||||
qualityOptions.push({ name: '1080p - 6 Mbps', maxHeight: 1080, bitrate: 6000001 });
|
|
||||||
qualityOptions.push({ name: '1080p - 5 Mbps', maxHeight: 1080, bitrate: 5000001 });
|
|
||||||
qualityOptions.push({ name: '1080p - 4 Mbps', maxHeight: 1080, bitrate: 4000002 });
|
|
||||||
} else if (maxAllowedWidth >= 1260) {
|
|
||||||
qualityOptions.push({ name: '720p - 10 Mbps', maxHeight: 720, bitrate: 10000000 });
|
|
||||||
qualityOptions.push({ name: '720p - 8 Mbps', maxHeight: 720, bitrate: 8000000 });
|
|
||||||
qualityOptions.push({ name: '720p - 6 Mbps', maxHeight: 720, bitrate: 6000000 });
|
|
||||||
qualityOptions.push({ name: '720p - 5 Mbps', maxHeight: 720, bitrate: 5000000 });
|
|
||||||
} else if (maxAllowedWidth >= 620) {
|
|
||||||
qualityOptions.push({ name: '480p - 4 Mbps', maxHeight: 480, bitrate: 4000001 });
|
|
||||||
qualityOptions.push({ name: '480p - 3 Mbps', maxHeight: 480, bitrate: 3000001 });
|
|
||||||
qualityOptions.push({ name: '480p - 2.5 Mbps', maxHeight: 480, bitrate: 2500000 });
|
|
||||||
qualityOptions.push({ name: '480p - 2 Mbps', maxHeight: 480, bitrate: 2000001 });
|
|
||||||
qualityOptions.push({ name: '480p - 1.5 Mbps', maxHeight: 480, bitrate: 1500001 });
|
|
||||||
}
|
|
||||||
|
|
||||||
if (maxAllowedWidth >= 1260) {
|
|
||||||
qualityOptions.push({ name: '720p - 4 Mbps', maxHeight: 720, bitrate: 4000000 });
|
|
||||||
qualityOptions.push({ name: '720p - 3 Mbps', maxHeight: 720, bitrate: 3000000 });
|
|
||||||
qualityOptions.push({ name: '720p - 2 Mbps', maxHeight: 720, bitrate: 2000000 });
|
|
||||||
|
|
||||||
// The extra 1 is because they're keyed off the bitrate value
|
|
||||||
qualityOptions.push({ name: '720p - 1.5 Mbps', maxHeight: 720, bitrate: 1500000 });
|
|
||||||
qualityOptions.push({ name: '720p - 1 Mbps', maxHeight: 720, bitrate: 1000001 });
|
|
||||||
}
|
|
||||||
|
|
||||||
qualityOptions.push({ name: '480p - 1 Mbps', maxHeight: 480, bitrate: 1000000 });
|
|
||||||
qualityOptions.push({ name: '480p - 720 kbps', maxHeight: 480, bitrate: 720000 });
|
|
||||||
qualityOptions.push({ name: '480p - 420 kbps', maxHeight: 480, bitrate: 420000 });
|
|
||||||
qualityOptions.push({ name: '360p', maxHeight: 360, bitrate: 400000 });
|
|
||||||
qualityOptions.push({ name: '240p', maxHeight: 240, bitrate: 320000 });
|
|
||||||
qualityOptions.push({ name: '144p', maxHeight: 144, bitrate: 192000 });
|
|
||||||
|
|
||||||
var autoQualityOption = {
|
|
||||||
name: globalize.translate('Auto'),
|
|
||||||
bitrate: 0,
|
|
||||||
selected: options.isAutomaticBitrateEnabled
|
|
||||||
};
|
|
||||||
|
|
||||||
if (options.enableAuto) {
|
|
||||||
qualityOptions.push(autoQualityOption);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (maxStreamingBitrate) {
|
|
||||||
var selectedIndex = -1;
|
|
||||||
for (var i = 0, length = qualityOptions.length; i < length; i++) {
|
|
||||||
var option = qualityOptions[i];
|
|
||||||
|
|
||||||
if (selectedIndex === -1 && option.bitrate <= maxStreamingBitrate) {
|
|
||||||
selectedIndex = i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (selectedIndex === -1) {
|
|
||||||
selectedIndex = qualityOptions.length - 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
var currentQualityOption = qualityOptions[selectedIndex];
|
|
||||||
|
|
||||||
if (!options.isAutomaticBitrateEnabled) {
|
|
||||||
currentQualityOption.selected = true;
|
|
||||||
} else {
|
|
||||||
autoQualityOption.autoText = currentQualityOption.name;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return qualityOptions;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getAudioQualityOptions(options) {
|
var maxAllowedWidth = videoWidth || 4096;
|
||||||
var maxStreamingBitrate = options.currentMaxBitrate;
|
//var maxAllowedHeight = videoHeight || 2304;
|
||||||
|
|
||||||
var qualityOptions = [];
|
var qualityOptions = [];
|
||||||
|
|
||||||
qualityOptions.push({ name: '2 Mbps', bitrate: 2000000 });
|
if (maxAllowedWidth >= 3800) {
|
||||||
qualityOptions.push({ name: '1.5 Mbps', bitrate: 1500000 });
|
qualityOptions.push({ name: '4K - 120 Mbps', maxHeight: 2160, bitrate: 120000000 });
|
||||||
qualityOptions.push({ name: '1 Mbps', bitrate: 1000000 });
|
qualityOptions.push({ name: '4K - 100 Mbps', maxHeight: 2160, bitrate: 100000000 });
|
||||||
qualityOptions.push({ name: '320 kbps', bitrate: 320000 });
|
qualityOptions.push({ name: '4K - 80 Mbps', maxHeight: 2160, bitrate: 80000000 });
|
||||||
qualityOptions.push({ name: '256 kbps', bitrate: 256000 });
|
|
||||||
qualityOptions.push({ name: '192 kbps', bitrate: 192000 });
|
|
||||||
qualityOptions.push({ name: '128 kbps', bitrate: 128000 });
|
|
||||||
qualityOptions.push({ name: '96 kbps', bitrate: 96000 });
|
|
||||||
qualityOptions.push({ name: '64 kbps', bitrate: 64000 });
|
|
||||||
|
|
||||||
var autoQualityOption = {
|
|
||||||
name: globalize.translate('Auto'),
|
|
||||||
bitrate: 0,
|
|
||||||
selected: options.isAutomaticBitrateEnabled
|
|
||||||
};
|
|
||||||
|
|
||||||
if (options.enableAuto) {
|
|
||||||
qualityOptions.push(autoQualityOption);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (maxStreamingBitrate) {
|
|
||||||
var selectedIndex = -1;
|
|
||||||
for (var i = 0, length = qualityOptions.length; i < length; i++) {
|
|
||||||
var option = qualityOptions[i];
|
|
||||||
|
|
||||||
if (selectedIndex === -1 && option.bitrate <= maxStreamingBitrate) {
|
|
||||||
selectedIndex = i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (selectedIndex === -1) {
|
|
||||||
selectedIndex = qualityOptions.length - 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
var currentQualityOption = qualityOptions[selectedIndex];
|
|
||||||
|
|
||||||
if (!options.isAutomaticBitrateEnabled) {
|
|
||||||
currentQualityOption.selected = true;
|
|
||||||
} else {
|
|
||||||
autoQualityOption.autoText = currentQualityOption.name;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return qualityOptions;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
// Some 1080- videos are reported as 1912?
|
||||||
getVideoQualityOptions: getVideoQualityOptions,
|
if (maxAllowedWidth >= 1900) {
|
||||||
getAudioQualityOptions: getAudioQualityOptions
|
|
||||||
|
qualityOptions.push({ name: '1080p - 60 Mbps', maxHeight: 1080, bitrate: 60000000 });
|
||||||
|
qualityOptions.push({ name: '1080p - 50 Mbps', maxHeight: 1080, bitrate: 50000000 });
|
||||||
|
qualityOptions.push({ name: '1080p - 40 Mbps', maxHeight: 1080, bitrate: 40000000 });
|
||||||
|
qualityOptions.push({ name: '1080p - 30 Mbps', maxHeight: 1080, bitrate: 30000000 });
|
||||||
|
qualityOptions.push({ name: '1080p - 25 Mbps', maxHeight: 1080, bitrate: 25000000 });
|
||||||
|
qualityOptions.push({ name: '1080p - 20 Mbps', maxHeight: 1080, bitrate: 20000000 });
|
||||||
|
qualityOptions.push({ name: '1080p - 15 Mbps', maxHeight: 1080, bitrate: 15000000 });
|
||||||
|
qualityOptions.push({ name: '1080p - 10 Mbps', maxHeight: 1080, bitrate: 10000001 });
|
||||||
|
qualityOptions.push({ name: '1080p - 8 Mbps', maxHeight: 1080, bitrate: 8000001 });
|
||||||
|
qualityOptions.push({ name: '1080p - 6 Mbps', maxHeight: 1080, bitrate: 6000001 });
|
||||||
|
qualityOptions.push({ name: '1080p - 5 Mbps', maxHeight: 1080, bitrate: 5000001 });
|
||||||
|
qualityOptions.push({ name: '1080p - 4 Mbps', maxHeight: 1080, bitrate: 4000002 });
|
||||||
|
|
||||||
|
} else if (maxAllowedWidth >= 1260) {
|
||||||
|
qualityOptions.push({ name: '720p - 10 Mbps', maxHeight: 720, bitrate: 10000000 });
|
||||||
|
qualityOptions.push({ name: '720p - 8 Mbps', maxHeight: 720, bitrate: 8000000 });
|
||||||
|
qualityOptions.push({ name: '720p - 6 Mbps', maxHeight: 720, bitrate: 6000000 });
|
||||||
|
qualityOptions.push({ name: '720p - 5 Mbps', maxHeight: 720, bitrate: 5000000 });
|
||||||
|
|
||||||
|
} else if (maxAllowedWidth >= 620) {
|
||||||
|
qualityOptions.push({ name: '480p - 4 Mbps', maxHeight: 480, bitrate: 4000001 });
|
||||||
|
qualityOptions.push({ name: '480p - 3 Mbps', maxHeight: 480, bitrate: 3000001 });
|
||||||
|
qualityOptions.push({ name: '480p - 2.5 Mbps', maxHeight: 480, bitrate: 2500000 });
|
||||||
|
qualityOptions.push({ name: '480p - 2 Mbps', maxHeight: 480, bitrate: 2000001 });
|
||||||
|
qualityOptions.push({ name: '480p - 1.5 Mbps', maxHeight: 480, bitrate: 1500001 });
|
||||||
|
}
|
||||||
|
|
||||||
|
if (maxAllowedWidth >= 1260) {
|
||||||
|
qualityOptions.push({ name: '720p - 4 Mbps', maxHeight: 720, bitrate: 4000000 });
|
||||||
|
qualityOptions.push({ name: '720p - 3 Mbps', maxHeight: 720, bitrate: 3000000 });
|
||||||
|
qualityOptions.push({ name: '720p - 2 Mbps', maxHeight: 720, bitrate: 2000000 });
|
||||||
|
|
||||||
|
// The extra 1 is because they're keyed off the bitrate value
|
||||||
|
qualityOptions.push({ name: '720p - 1.5 Mbps', maxHeight: 720, bitrate: 1500000 });
|
||||||
|
qualityOptions.push({ name: '720p - 1 Mbps', maxHeight: 720, bitrate: 1000001 });
|
||||||
|
}
|
||||||
|
|
||||||
|
qualityOptions.push({ name: '480p - 1 Mbps', maxHeight: 480, bitrate: 1000000 });
|
||||||
|
qualityOptions.push({ name: '480p - 720 kbps', maxHeight: 480, bitrate: 720000 });
|
||||||
|
qualityOptions.push({ name: '480p - 420 kbps', maxHeight: 480, bitrate: 420000 });
|
||||||
|
qualityOptions.push({ name: '360p', maxHeight: 360, bitrate: 400000 });
|
||||||
|
qualityOptions.push({ name: '240p', maxHeight: 240, bitrate: 320000 });
|
||||||
|
qualityOptions.push({ name: '144p', maxHeight: 144, bitrate: 192000 });
|
||||||
|
|
||||||
|
var autoQualityOption = {
|
||||||
|
name: globalize.translate('Auto'),
|
||||||
|
bitrate: 0,
|
||||||
|
selected: options.isAutomaticBitrateEnabled
|
||||||
};
|
};
|
||||||
});
|
|
||||||
|
if (options.enableAuto) {
|
||||||
|
qualityOptions.push(autoQualityOption);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (maxStreamingBitrate) {
|
||||||
|
var selectedIndex = -1;
|
||||||
|
for (var i = 0, length = qualityOptions.length; i < length; i++) {
|
||||||
|
|
||||||
|
var option = qualityOptions[i];
|
||||||
|
|
||||||
|
if (selectedIndex === -1 && option.bitrate <= maxStreamingBitrate) {
|
||||||
|
selectedIndex = i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (selectedIndex === -1) {
|
||||||
|
selectedIndex = qualityOptions.length - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
var currentQualityOption = qualityOptions[selectedIndex];
|
||||||
|
|
||||||
|
if (!options.isAutomaticBitrateEnabled) {
|
||||||
|
currentQualityOption.selected = true;
|
||||||
|
} else {
|
||||||
|
autoQualityOption.autoText = currentQualityOption.name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return qualityOptions;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getAudioQualityOptions(options) {
|
||||||
|
var maxStreamingBitrate = options.currentMaxBitrate;
|
||||||
|
|
||||||
|
var qualityOptions = [];
|
||||||
|
|
||||||
|
qualityOptions.push({ name: '2 Mbps', bitrate: 2000000 });
|
||||||
|
qualityOptions.push({ name: '1.5 Mbps', bitrate: 1500000 });
|
||||||
|
qualityOptions.push({ name: '1 Mbps', bitrate: 1000000 });
|
||||||
|
qualityOptions.push({ name: '320 kbps', bitrate: 320000 });
|
||||||
|
qualityOptions.push({ name: '256 kbps', bitrate: 256000 });
|
||||||
|
qualityOptions.push({ name: '192 kbps', bitrate: 192000 });
|
||||||
|
qualityOptions.push({ name: '128 kbps', bitrate: 128000 });
|
||||||
|
qualityOptions.push({ name: '96 kbps', bitrate: 96000 });
|
||||||
|
qualityOptions.push({ name: '64 kbps', bitrate: 64000 });
|
||||||
|
|
||||||
|
var autoQualityOption = {
|
||||||
|
name: globalize.translate('Auto'),
|
||||||
|
bitrate: 0,
|
||||||
|
selected: options.isAutomaticBitrateEnabled
|
||||||
|
};
|
||||||
|
|
||||||
|
if (options.enableAuto) {
|
||||||
|
qualityOptions.push(autoQualityOption);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (maxStreamingBitrate) {
|
||||||
|
var selectedIndex = -1;
|
||||||
|
for (var i = 0, length = qualityOptions.length; i < length; i++) {
|
||||||
|
var option = qualityOptions[i];
|
||||||
|
|
||||||
|
if (selectedIndex === -1 && option.bitrate <= maxStreamingBitrate) {
|
||||||
|
selectedIndex = i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (selectedIndex === -1) {
|
||||||
|
|
||||||
|
selectedIndex = qualityOptions.length - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
var currentQualityOption = qualityOptions[selectedIndex];
|
||||||
|
|
||||||
|
if (!options.isAutomaticBitrateEnabled) {
|
||||||
|
currentQualityOption.selected = true;
|
||||||
|
} else {
|
||||||
|
autoQualityOption.autoText = currentQualityOption.name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return qualityOptions;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default {
|
||||||
|
getVideoQualityOptions,
|
||||||
|
getAudioQualityOptions
|
||||||
|
};
|
||||||
|
|
|
@ -397,7 +397,7 @@ define(['browser', 'datetime', 'backdrop', 'libraryBrowser', 'listView', 'imageL
|
||||||
showVolumeSlider = false;
|
showVolumeSlider = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (currentPlayer.isLocalPlayer && appHost.supports('physicalvolumecontrol')) {
|
if (currentPlayer.isLocalPlayer && appHost.default.supports('physicalvolumecontrol')) {
|
||||||
showMuteButton = false;
|
showMuteButton = false;
|
||||||
showVolumeSlider = false;
|
showVolumeSlider = false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -251,7 +251,7 @@ import layoutManager from 'layoutManager';
|
||||||
* @return {ScrollerData} Scroller data.
|
* @return {ScrollerData} Scroller data.
|
||||||
*/
|
*/
|
||||||
function getScrollerData(scroller, vertical) {
|
function getScrollerData(scroller, vertical) {
|
||||||
let data = {};
|
const data = {};
|
||||||
|
|
||||||
if (!vertical) {
|
if (!vertical) {
|
||||||
data.scrollPos = scroller.scrollLeft;
|
data.scrollPos = scroller.scrollLeft;
|
||||||
|
|
184
src/components/skinManager.js
Normal file
184
src/components/skinManager.js
Normal file
|
@ -0,0 +1,184 @@
|
||||||
|
define(['apphost', 'userSettings', 'browser', 'events', 'backdrop', 'globalize', 'require', 'appSettings'], function (appHost, userSettings, browser, events, backdrop, globalize, require, appSettings) {
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
var themeStyleElement;
|
||||||
|
var currentThemeId;
|
||||||
|
|
||||||
|
function unloadTheme() {
|
||||||
|
var elem = themeStyleElement;
|
||||||
|
if (elem) {
|
||||||
|
elem.parentNode.removeChild(elem);
|
||||||
|
themeStyleElement = null;
|
||||||
|
currentThemeId = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function loadUserSkin(options) {
|
||||||
|
options = options || {};
|
||||||
|
if (options.start) {
|
||||||
|
Emby.Page.invokeShortcut(options.start);
|
||||||
|
} else {
|
||||||
|
Emby.Page.goHome();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function getThemes() {
|
||||||
|
return [{
|
||||||
|
name: 'Apple TV',
|
||||||
|
id: 'appletv'
|
||||||
|
}, {
|
||||||
|
name: 'Blue Radiance',
|
||||||
|
id: 'blueradiance'
|
||||||
|
}, {
|
||||||
|
name: 'Dark',
|
||||||
|
id: 'dark',
|
||||||
|
isDefault: true,
|
||||||
|
isDefaultServerDashboard: true
|
||||||
|
}, {
|
||||||
|
name: 'Light',
|
||||||
|
id: 'light'
|
||||||
|
}, {
|
||||||
|
name: 'Purple Haze',
|
||||||
|
id: 'purplehaze'
|
||||||
|
}, {
|
||||||
|
name: 'Windows Media Center',
|
||||||
|
id: 'wmc'
|
||||||
|
}];
|
||||||
|
}
|
||||||
|
|
||||||
|
var skinManager = {
|
||||||
|
getThemes: getThemes,
|
||||||
|
loadUserSkin: loadUserSkin
|
||||||
|
};
|
||||||
|
|
||||||
|
function getThemeStylesheetInfo(id, isDefaultProperty) {
|
||||||
|
var themes = skinManager.getThemes();
|
||||||
|
var defaultTheme;
|
||||||
|
var selectedTheme;
|
||||||
|
|
||||||
|
for (var i = 0, length = themes.length; i < length; i++) {
|
||||||
|
var theme = themes[i];
|
||||||
|
if (theme[isDefaultProperty]) {
|
||||||
|
defaultTheme = theme;
|
||||||
|
}
|
||||||
|
if (id === theme.id) {
|
||||||
|
selectedTheme = theme;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
selectedTheme = selectedTheme || defaultTheme;
|
||||||
|
return {
|
||||||
|
stylesheetPath: require.toUrl('themes/' + selectedTheme.id + '/theme.css'),
|
||||||
|
themeId: selectedTheme.id
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
var themeResources = {};
|
||||||
|
var lastSound = 0;
|
||||||
|
var currentSound;
|
||||||
|
|
||||||
|
function loadThemeResources(id) {
|
||||||
|
lastSound = 0;
|
||||||
|
if (currentSound) {
|
||||||
|
currentSound.stop();
|
||||||
|
currentSound = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
backdrop.clearBackdrop();
|
||||||
|
}
|
||||||
|
|
||||||
|
function onThemeLoaded() {
|
||||||
|
document.documentElement.classList.remove('preload');
|
||||||
|
try {
|
||||||
|
var color = getComputedStyle(document.querySelector('.skinHeader')).getPropertyValue('background-color');
|
||||||
|
if (color) {
|
||||||
|
appHost.default.setThemeColor(color);
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
console.error('error setting theme color: ' + err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
skinManager.setTheme = function (id, context) {
|
||||||
|
return new Promise(function (resolve, reject) {
|
||||||
|
if (currentThemeId && currentThemeId === id) {
|
||||||
|
resolve();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var isDefaultProperty = context === 'serverdashboard' ? 'isDefaultServerDashboard' : 'isDefault';
|
||||||
|
var info = getThemeStylesheetInfo(id, isDefaultProperty);
|
||||||
|
if (currentThemeId && currentThemeId === info.themeId) {
|
||||||
|
resolve();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var linkUrl = info.stylesheetPath;
|
||||||
|
unloadTheme();
|
||||||
|
|
||||||
|
var link = document.createElement('link');
|
||||||
|
link.setAttribute('rel', 'stylesheet');
|
||||||
|
link.setAttribute('type', 'text/css');
|
||||||
|
link.onload = function () {
|
||||||
|
onThemeLoaded();
|
||||||
|
resolve();
|
||||||
|
};
|
||||||
|
|
||||||
|
link.setAttribute('href', linkUrl);
|
||||||
|
document.head.appendChild(link);
|
||||||
|
themeStyleElement = link;
|
||||||
|
currentThemeId = info.themeId;
|
||||||
|
loadThemeResources(info.themeId);
|
||||||
|
|
||||||
|
onViewBeforeShow({});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
function onViewBeforeShow(e) {
|
||||||
|
if (e.detail && e.detail.type === 'video-osd') {
|
||||||
|
// This removes the space that the scrollbar takes while playing a video
|
||||||
|
document.body.classList.remove('force-scroll');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (themeResources.backdrop) {
|
||||||
|
backdrop.setBackdrop(themeResources.backdrop);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!browser.mobile && userSettings.enableThemeSongs()) {
|
||||||
|
if (lastSound === 0) {
|
||||||
|
if (themeResources.themeSong) {
|
||||||
|
playSound(themeResources.themeSong);
|
||||||
|
}
|
||||||
|
} else if ((new Date().getTime() - lastSound) > 30000) {
|
||||||
|
if (themeResources.effect) {
|
||||||
|
playSound(themeResources.effect);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// This keeps the scrollbar always present in all pages, so we avoid clipping while switching between pages
|
||||||
|
// that need the scrollbar and pages that don't.
|
||||||
|
document.body.classList.add('force-scroll');
|
||||||
|
}
|
||||||
|
|
||||||
|
document.addEventListener('viewshow', onViewBeforeShow);
|
||||||
|
|
||||||
|
function playSound(path, volume) {
|
||||||
|
lastSound = new Date().getTime();
|
||||||
|
require(['howler'], function (howler) {
|
||||||
|
/* globals Howl */
|
||||||
|
try {
|
||||||
|
var sound = new Howl({
|
||||||
|
src: [path],
|
||||||
|
volume: volume || 0.1
|
||||||
|
});
|
||||||
|
sound.play();
|
||||||
|
currentSound = sound;
|
||||||
|
} catch (err) {
|
||||||
|
console.error('error playing sound: ' + err);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return skinManager;
|
||||||
|
});
|
|
@ -113,7 +113,7 @@ define(['dialogHelper', 'inputManager', 'connectionManager', 'layoutManager', 'f
|
||||||
*/
|
*/
|
||||||
function setUserScalable(scalable) {
|
function setUserScalable(scalable) {
|
||||||
try {
|
try {
|
||||||
appHost.setUserScalable(scalable);
|
appHost.default.setUserScalable(scalable);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('error in appHost.setUserScalable: ' + err);
|
console.error('error in appHost.setUserScalable: ' + err);
|
||||||
}
|
}
|
||||||
|
@ -162,10 +162,10 @@ define(['dialogHelper', 'inputManager', 'connectionManager', 'layoutManager', 'f
|
||||||
|
|
||||||
html += '<div class="topActionButtons">';
|
html += '<div class="topActionButtons">';
|
||||||
if (actionButtonsOnTop) {
|
if (actionButtonsOnTop) {
|
||||||
if (appHost.supports('filedownload') && options.user && options.user.Policy.EnableContentDownloading) {
|
if (appHost.default.supports('filedownload') && options.user && options.user.Policy.EnableContentDownloading) {
|
||||||
html += getIcon('file_download', 'btnDownload slideshowButton', true);
|
html += getIcon('file_download', 'btnDownload slideshowButton', true);
|
||||||
}
|
}
|
||||||
if (appHost.supports('sharing')) {
|
if (appHost.default.supports('sharing')) {
|
||||||
html += getIcon('share', 'btnShare slideshowButton', true);
|
html += getIcon('share', 'btnShare slideshowButton', true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -176,10 +176,10 @@ define(['dialogHelper', 'inputManager', 'connectionManager', 'layoutManager', 'f
|
||||||
html += '<div class="slideshowBottomBar hide">';
|
html += '<div class="slideshowBottomBar hide">';
|
||||||
|
|
||||||
html += getIcon('play_arrow', 'btnSlideshowPause slideshowButton', true, true);
|
html += getIcon('play_arrow', 'btnSlideshowPause slideshowButton', true, true);
|
||||||
if (appHost.supports('filedownload') && options.user && options.user.Policy.EnableContentDownloading) {
|
if (appHost.default.supports('filedownload') && options.user && options.user.Policy.EnableContentDownloading) {
|
||||||
html += getIcon('file_download', 'btnDownload slideshowButton', true);
|
html += getIcon('file_download', 'btnDownload slideshowButton', true);
|
||||||
}
|
}
|
||||||
if (appHost.supports('sharing')) {
|
if (appHost.default.supports('sharing')) {
|
||||||
html += getIcon('share', 'btnShare slideshowButton', true);
|
html += getIcon('share', 'btnShare slideshowButton', true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -105,7 +105,7 @@ export default function(view, params) {
|
||||||
});
|
});
|
||||||
|
|
||||||
view.querySelector('.btnNewRepository').addEventListener('click', () => {
|
view.querySelector('.btnNewRepository').addEventListener('click', () => {
|
||||||
let dialog = dialogHelper.createDialog({
|
const dialog = dialogHelper.createDialog({
|
||||||
scrollY: false,
|
scrollY: false,
|
||||||
size: 'large',
|
size: 'large',
|
||||||
modal: false,
|
modal: false,
|
||||||
|
|
|
@ -104,7 +104,6 @@ import 'flexStyles';
|
||||||
}
|
}
|
||||||
|
|
||||||
var itemsContainer = elem.querySelector('.itemsContainer');
|
var itemsContainer = elem.querySelector('.itemsContainer');
|
||||||
|
|
||||||
itemsContainer.innerHTML = cardBuilder.getCardsHtml({
|
itemsContainer.innerHTML = cardBuilder.getCardsHtml({
|
||||||
items: result.Items,
|
items: result.Items,
|
||||||
showUnplayedIndicator: false,
|
showUnplayedIndicator: false,
|
||||||
|
|
|
@ -898,7 +898,7 @@ import 'css!assets/css/videoosd';
|
||||||
showVolumeSlider = false;
|
showVolumeSlider = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (player.isLocalPlayer && appHost.supports('physicalvolumecontrol')) {
|
if (player.isLocalPlayer && appHost.default.supports('physicalvolumecontrol')) {
|
||||||
showMuteButton = false;
|
showMuteButton = false;
|
||||||
showVolumeSlider = false;
|
showVolumeSlider = false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -199,7 +199,7 @@ import 'emby-checkbox';
|
||||||
loading.show();
|
loading.show();
|
||||||
libraryMenu.setTransparentMenu(true);
|
libraryMenu.setTransparentMenu(true);
|
||||||
|
|
||||||
if (!appHost.supports('multiserver')) {
|
if (!appHost.default.supports('multiserver')) {
|
||||||
view.querySelector('.btnSelectServer').classList.add('hide');
|
view.querySelector('.btnSelectServer').classList.add('hide');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
58
src/controllers/user/menu.js
Normal file
58
src/controllers/user/menu.js
Normal file
|
@ -0,0 +1,58 @@
|
||||||
|
define(['apphost', 'connectionManager', 'layoutManager', 'listViewStyle', 'emby-button'], function(appHost, connectionManager, layoutManager) {
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
return function(view, params) {
|
||||||
|
view.querySelector('.btnLogout').addEventListener('click', function() {
|
||||||
|
Dashboard.logout();
|
||||||
|
});
|
||||||
|
|
||||||
|
view.querySelector('.selectServer').addEventListener('click', function () {
|
||||||
|
Dashboard.selectServer();
|
||||||
|
});
|
||||||
|
|
||||||
|
view.querySelector('.clientSettings').addEventListener('click', function () {
|
||||||
|
window.NativeShell.openClientSettings();
|
||||||
|
});
|
||||||
|
|
||||||
|
view.addEventListener('viewshow', function() {
|
||||||
|
// this page can also be used by admins to change user preferences from the user edit page
|
||||||
|
var userId = params.userId || Dashboard.getCurrentUserId();
|
||||||
|
var page = this;
|
||||||
|
|
||||||
|
page.querySelector('.lnkMyProfile').setAttribute('href', 'myprofile.html?userId=' + userId);
|
||||||
|
page.querySelector('.lnkDisplayPreferences').setAttribute('href', 'mypreferencesdisplay.html?userId=' + userId);
|
||||||
|
page.querySelector('.lnkHomePreferences').setAttribute('href', 'mypreferenceshome.html?userId=' + userId);
|
||||||
|
page.querySelector('.lnkPlaybackPreferences').setAttribute('href', 'mypreferencesplayback.html?userId=' + userId);
|
||||||
|
page.querySelector('.lnkSubtitlePreferences').setAttribute('href', 'mypreferencessubtitles.html?userId=' + userId);
|
||||||
|
|
||||||
|
if (window.NativeShell && window.NativeShell.AppHost.supports('clientsettings')) {
|
||||||
|
page.querySelector('.clientSettings').classList.remove('hide');
|
||||||
|
} else {
|
||||||
|
page.querySelector('.clientSettings').classList.add('hide');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (appHost.default.supports('multiserver')) {
|
||||||
|
page.querySelector('.selectServer').classList.remove('hide');
|
||||||
|
} else {
|
||||||
|
page.querySelector('.selectServer').classList.add('hide');
|
||||||
|
}
|
||||||
|
|
||||||
|
// hide the actions if user preferences are being edited for a different user
|
||||||
|
if (params.userId && params.userId !== Dashboard.getCurrentUserId) {
|
||||||
|
page.querySelector('.userSection').classList.add('hide');
|
||||||
|
page.querySelector('.adminSection').classList.add('hide');
|
||||||
|
}
|
||||||
|
|
||||||
|
ApiClient.getUser(userId).then(function(user) {
|
||||||
|
page.querySelector('.headerUsername').innerHTML = user.Name;
|
||||||
|
if (!user.Policy.IsAdministrator) {
|
||||||
|
page.querySelector('.adminSection').classList.add('hide');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
require(['autoFocuser'], function (autoFocuser) {
|
||||||
|
autoFocuser.autoFocus(view);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
});
|
106
src/controllers/user/profile.js
Normal file
106
src/controllers/user/profile.js
Normal file
|
@ -0,0 +1,106 @@
|
||||||
|
define(['controllers/dashboard/users/userpasswordpage', 'loading', 'libraryMenu', 'apphost', 'globalize', 'emby-button'], function (UserPasswordPage, loading, libraryMenu, appHost, globalize) {
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
function reloadUser(page) {
|
||||||
|
var userId = getParameterByName('userId');
|
||||||
|
loading.show();
|
||||||
|
ApiClient.getUser(userId).then(function (user) {
|
||||||
|
page.querySelector('.username').innerHTML = user.Name;
|
||||||
|
libraryMenu.setTitle(user.Name);
|
||||||
|
|
||||||
|
var imageUrl = 'assets/img/avatar.png';
|
||||||
|
if (user.PrimaryImageTag) {
|
||||||
|
imageUrl = ApiClient.getUserImageUrl(user.Id, {
|
||||||
|
tag: user.PrimaryImageTag,
|
||||||
|
type: 'Primary'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
var userImage = page.querySelector('#image');
|
||||||
|
userImage.style.backgroundImage = 'url(' + imageUrl + ')';
|
||||||
|
|
||||||
|
Dashboard.getCurrentUser().then(function (loggedInUser) {
|
||||||
|
if (user.PrimaryImageTag) {
|
||||||
|
page.querySelector('#btnAddImage').classList.add('hide');
|
||||||
|
page.querySelector('#btnDeleteImage').classList.remove('hide');
|
||||||
|
} else if (appHost.default.supports('fileinput') && (loggedInUser.Policy.IsAdministrator || user.Policy.EnableUserPreferenceAccess)) {
|
||||||
|
page.querySelector('#btnDeleteImage').classList.add('hide');
|
||||||
|
page.querySelector('#btnAddImage').classList.remove('hide');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
loading.hide();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function onFileReaderError(evt) {
|
||||||
|
loading.hide();
|
||||||
|
switch (evt.target.error.code) {
|
||||||
|
case evt.target.error.NOT_FOUND_ERR:
|
||||||
|
require(['toast'], function (toast) {
|
||||||
|
toast(globalize.translate('FileNotFound'));
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case evt.target.error.ABORT_ERR:
|
||||||
|
onFileReaderAbort();
|
||||||
|
break;
|
||||||
|
case evt.target.error.NOT_READABLE_ERR:
|
||||||
|
default:
|
||||||
|
require(['toast'], function (toast) {
|
||||||
|
toast(globalize.translate('FileReadError'));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function onFileReaderAbort(evt) {
|
||||||
|
loading.hide();
|
||||||
|
require(['toast'], function (toast) {
|
||||||
|
toast(globalize.translate('FileReadCancelled'));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function setFiles(page, files) {
|
||||||
|
var userImage = page.querySelector('#image');
|
||||||
|
var file = files[0];
|
||||||
|
|
||||||
|
if (!file || !file.type.match('image.*')) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
var reader = new FileReader();
|
||||||
|
reader.onerror = onFileReaderError;
|
||||||
|
reader.onabort = onFileReaderAbort;
|
||||||
|
reader.onload = function (evt) {
|
||||||
|
userImage.style.backgroundImage = 'url(' + evt.target.result + ')';
|
||||||
|
var userId = getParameterByName('userId');
|
||||||
|
ApiClient.uploadUserImage(userId, 'Primary', file).then(function () {
|
||||||
|
loading.hide();
|
||||||
|
reloadUser(page);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
reader.readAsDataURL(file);
|
||||||
|
}
|
||||||
|
|
||||||
|
return function (view, params) {
|
||||||
|
reloadUser(view);
|
||||||
|
new UserPasswordPage(view, params);
|
||||||
|
view.querySelector('#btnDeleteImage').addEventListener('click', function () {
|
||||||
|
require(['confirm'], function (confirm) {
|
||||||
|
confirm(globalize.translate('DeleteImageConfirmation'), globalize.translate('DeleteImage')).then(function () {
|
||||||
|
loading.show();
|
||||||
|
var userId = getParameterByName('userId');
|
||||||
|
ApiClient.deleteUserImage(userId, 'primary').then(function () {
|
||||||
|
loading.hide();
|
||||||
|
reloadUser(view);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
view.querySelector('#btnAddImage').addEventListener('click', function (evt) {
|
||||||
|
view.querySelector('#uploadImage').click();
|
||||||
|
});
|
||||||
|
view.querySelector('#uploadImage').addEventListener('change', function (evt) {
|
||||||
|
setFiles(view, evt.target.files);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
});
|
|
@ -27,16 +27,16 @@ export class BookPlayer {
|
||||||
this._loaded = false;
|
this._loaded = false;
|
||||||
|
|
||||||
loading.show();
|
loading.show();
|
||||||
let elem = this.createMediaElement();
|
const elem = this.createMediaElement();
|
||||||
return this.setCurrentSrc(elem, options);
|
return this.setCurrentSrc(elem, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
stop() {
|
stop() {
|
||||||
this.unbindEvents();
|
this.unbindEvents();
|
||||||
|
|
||||||
let elem = this._mediaElement;
|
const elem = this._mediaElement;
|
||||||
let tocElement = this._tocElement;
|
const tocElement = this._tocElement;
|
||||||
let rendition = this._rendition;
|
const rendition = this._rendition;
|
||||||
|
|
||||||
if (elem) {
|
if (elem) {
|
||||||
dialogHelper.close(elem);
|
dialogHelper.close(elem);
|
||||||
|
@ -93,11 +93,9 @@ export class BookPlayer {
|
||||||
}
|
}
|
||||||
|
|
||||||
onWindowKeyUp(e) {
|
onWindowKeyUp(e) {
|
||||||
let key = keyboardnavigation.getKeyName(e);
|
const key = keyboardnavigation.getKeyName(e);
|
||||||
|
const rendition = this._rendition;
|
||||||
// TODO: depending on the event this can be the document or the rendition itself
|
const book = rendition.book;
|
||||||
let rendition = this._rendition || this;
|
|
||||||
let book = rendition.book;
|
|
||||||
|
|
||||||
if (this._loaded === false) return;
|
if (this._loaded === false) return;
|
||||||
switch (key) {
|
switch (key) {
|
||||||
|
@ -147,7 +145,7 @@ export class BookPlayer {
|
||||||
}
|
}
|
||||||
|
|
||||||
bindMediaElementEvents() {
|
bindMediaElementEvents() {
|
||||||
let elem = this._mediaElement;
|
const elem = this._mediaElement;
|
||||||
|
|
||||||
elem.addEventListener('close', this.onDialogClosed, {once: true});
|
elem.addEventListener('close', this.onDialogClosed, {once: true});
|
||||||
elem.querySelector('.btnBookplayerExit').addEventListener('click', this.onDialogClosed, {once: true});
|
elem.querySelector('.btnBookplayerExit').addEventListener('click', this.onDialogClosed, {once: true});
|
||||||
|
@ -166,7 +164,7 @@ export class BookPlayer {
|
||||||
}
|
}
|
||||||
|
|
||||||
unbindMediaElementEvents() {
|
unbindMediaElementEvents() {
|
||||||
let elem = this._mediaElement;
|
const elem = this._mediaElement;
|
||||||
|
|
||||||
elem.removeEventListener('close', this.onDialogClosed);
|
elem.removeEventListener('close', this.onDialogClosed);
|
||||||
elem.querySelector('.btnBookplayerExit').removeEventListener('click', this.onDialogClosed);
|
elem.querySelector('.btnBookplayerExit').removeEventListener('click', this.onDialogClosed);
|
||||||
|
@ -231,7 +229,7 @@ export class BookPlayer {
|
||||||
}
|
}
|
||||||
|
|
||||||
setCurrentSrc(elem, options) {
|
setCurrentSrc(elem, options) {
|
||||||
let item = options.items[0];
|
const item = options.items[0];
|
||||||
this._currentItem = item;
|
this._currentItem = item;
|
||||||
this.streamInfo = {
|
this.streamInfo = {
|
||||||
started: true,
|
started: true,
|
||||||
|
@ -241,25 +239,25 @@ export class BookPlayer {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let serverId = item.ServerId;
|
const serverId = item.ServerId;
|
||||||
let apiClient = connectionManager.getApiClient(serverId);
|
const apiClient = connectionManager.getApiClient(serverId);
|
||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
import('epubjs').then(({default: epubjs}) => {
|
import('epubjs').then(({default: epubjs}) => {
|
||||||
let downloadHref = apiClient.getItemDownloadUrl(item.Id);
|
const downloadHref = apiClient.getItemDownloadUrl(item.Id);
|
||||||
let book = epubjs(downloadHref, {openAs: 'epub'});
|
const book = epubjs(downloadHref, {openAs: 'epub'});
|
||||||
let rendition = book.renderTo(elem, {width: '100%', height: '97%'});
|
const rendition = book.renderTo(elem, {width: '100%', height: '97%'});
|
||||||
|
|
||||||
this._currentSrc = downloadHref;
|
this._currentSrc = downloadHref;
|
||||||
this._rendition = rendition;
|
this._rendition = rendition;
|
||||||
let cancellationToken = {
|
const cancellationToken = {
|
||||||
shouldCancel: false
|
shouldCancel: false
|
||||||
};
|
};
|
||||||
|
|
||||||
this._cancellationToken = cancellationToken;
|
this._cancellationToken = cancellationToken;
|
||||||
|
|
||||||
return rendition.display().then(() => {
|
return rendition.display().then(() => {
|
||||||
let epubElem = document.querySelector('.epub-container');
|
const epubElem = document.querySelector('.epub-container');
|
||||||
epubElem.style.display = 'none';
|
epubElem.style.display = 'none';
|
||||||
|
|
||||||
this.bindEvents();
|
this.bindEvents();
|
||||||
|
|
|
@ -11,7 +11,7 @@ export default class TableOfContents {
|
||||||
}
|
}
|
||||||
|
|
||||||
destroy() {
|
destroy() {
|
||||||
let elem = this._elem;
|
const elem = this._elem;
|
||||||
if (elem) {
|
if (elem) {
|
||||||
this.unbindEvents();
|
this.unbindEvents();
|
||||||
dialogHelper.close(elem);
|
dialogHelper.close(elem);
|
||||||
|
@ -21,14 +21,14 @@ export default class TableOfContents {
|
||||||
}
|
}
|
||||||
|
|
||||||
bindEvents() {
|
bindEvents() {
|
||||||
let elem = this._elem;
|
const elem = this._elem;
|
||||||
|
|
||||||
elem.addEventListener('close', this.onDialogClosed, {once: true});
|
elem.addEventListener('close', this.onDialogClosed, {once: true});
|
||||||
elem.querySelector('.btnBookplayerTocClose').addEventListener('click', this.onDialogClosed, {once: true});
|
elem.querySelector('.btnBookplayerTocClose').addEventListener('click', this.onDialogClosed, {once: true});
|
||||||
}
|
}
|
||||||
|
|
||||||
unbindEvents() {
|
unbindEvents() {
|
||||||
let elem = this._elem;
|
const elem = this._elem;
|
||||||
|
|
||||||
elem.removeEventListener('close', this.onDialogClosed);
|
elem.removeEventListener('close', this.onDialogClosed);
|
||||||
elem.querySelector('.btnBookplayerTocClose').removeEventListener('click', this.onDialogClosed);
|
elem.querySelector('.btnBookplayerTocClose').removeEventListener('click', this.onDialogClosed);
|
||||||
|
@ -39,10 +39,10 @@ export default class TableOfContents {
|
||||||
}
|
}
|
||||||
|
|
||||||
replaceLinks(contents, f) {
|
replaceLinks(contents, f) {
|
||||||
let links = contents.querySelectorAll('a[href]');
|
const links = contents.querySelectorAll('a[href]');
|
||||||
|
|
||||||
links.forEach((link) => {
|
links.forEach((link) => {
|
||||||
let href = link.getAttribute('href');
|
const href = link.getAttribute('href');
|
||||||
|
|
||||||
link.onclick = () => {
|
link.onclick = () => {
|
||||||
f(href);
|
f(href);
|
||||||
|
@ -52,9 +52,9 @@ export default class TableOfContents {
|
||||||
}
|
}
|
||||||
|
|
||||||
createMediaElement() {
|
createMediaElement() {
|
||||||
let rendition = this._rendition;
|
const rendition = this._rendition;
|
||||||
|
|
||||||
let elem = dialogHelper.createDialog({
|
const elem = dialogHelper.createDialog({
|
||||||
size: 'small',
|
size: 'small',
|
||||||
autoFocus: false,
|
autoFocus: false,
|
||||||
removeOnClose: true
|
removeOnClose: true
|
||||||
|
@ -69,7 +69,7 @@ export default class TableOfContents {
|
||||||
rendition.book.navigation.forEach((chapter) => {
|
rendition.book.navigation.forEach((chapter) => {
|
||||||
tocHtml += '<li>';
|
tocHtml += '<li>';
|
||||||
// Remove '../' from href
|
// Remove '../' from href
|
||||||
let link = chapter.href.startsWith('../') ? chapter.href.substr(3) : chapter.href;
|
const link = chapter.href.startsWith('../') ? chapter.href.substr(3) : chapter.href;
|
||||||
tocHtml += `<a href="${rendition.book.path.directory + link}">${chapter.label}</a>`;
|
tocHtml += `<a href="${rendition.book.path.directory + link}">${chapter.label}</a>`;
|
||||||
tocHtml += '</li>';
|
tocHtml += '</li>';
|
||||||
});
|
});
|
||||||
|
@ -78,7 +78,7 @@ export default class TableOfContents {
|
||||||
elem.innerHTML = tocHtml;
|
elem.innerHTML = tocHtml;
|
||||||
|
|
||||||
this.replaceLinks(elem, (href) => {
|
this.replaceLinks(elem, (href) => {
|
||||||
let relative = rendition.book.path.relative(href);
|
const relative = rendition.book.path.relative(href);
|
||||||
rendition.display(relative);
|
rendition.display(relative);
|
||||||
this.destroy();
|
this.destroy();
|
||||||
});
|
});
|
||||||
|
|
|
@ -12,7 +12,7 @@ define(['connectionManager', 'globalize', 'userSettings', 'apphost'], function (
|
||||||
}
|
}
|
||||||
|
|
||||||
function showMessage(text, userSettingsKey, appHostFeature) {
|
function showMessage(text, userSettingsKey, appHostFeature) {
|
||||||
if (appHost.supports(appHostFeature)) {
|
if (appHost.default.supports(appHostFeature)) {
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -334,8 +334,8 @@ define(['events', 'browser', 'require', 'apphost', 'appSettings', 'htmlMediaHelp
|
||||||
};
|
};
|
||||||
|
|
||||||
HtmlAudioPlayer.prototype.getDeviceProfile = function (item) {
|
HtmlAudioPlayer.prototype.getDeviceProfile = function (item) {
|
||||||
if (appHost.getDeviceProfile) {
|
if (appHost.default.getDeviceProfile) {
|
||||||
return appHost.getDeviceProfile(item);
|
return appHost.default.getDeviceProfile(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
return getDefaultProfile();
|
return getDefaultProfile();
|
||||||
|
|
|
@ -105,7 +105,7 @@ function tryRemoveElement(elem) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function hidePrePlaybackPage() {
|
function hidePrePlaybackPage() {
|
||||||
let animatedPage = document.querySelector('.page:not(.hide)');
|
const animatedPage = document.querySelector('.page:not(.hide)');
|
||||||
animatedPage.classList.add('hide');
|
animatedPage.classList.add('hide');
|
||||||
// At this point, we must hide the scrollbar placeholder, so it's not being displayed while the item is being loaded
|
// At this point, we must hide the scrollbar placeholder, so it's not being displayed while the item is being loaded
|
||||||
document.body.classList.remove('force-scroll');
|
document.body.classList.remove('force-scroll');
|
||||||
|
@ -1288,7 +1288,7 @@ function tryRemoveElement(elem) {
|
||||||
}
|
}
|
||||||
|
|
||||||
let html = '';
|
let html = '';
|
||||||
let cssClass = 'htmlvideoplayer';
|
const cssClass = 'htmlvideoplayer';
|
||||||
|
|
||||||
// Can't autoplay in these browsers so we need to use the full controls, at least until playback starts
|
// Can't autoplay in these browsers so we need to use the full controls, at least until playback starts
|
||||||
if (!appHost.supports('htmlvideoautoplay')) {
|
if (!appHost.supports('htmlvideoautoplay')) {
|
||||||
|
|
|
@ -1,52 +1,48 @@
|
||||||
(function() {
|
function injectScriptElement(src, onload) {
|
||||||
'use strict';
|
if (!src) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
function injectScriptElement(src, onload) {
|
const script = document.createElement('script');
|
||||||
if (!src) {
|
if (self.dashboardVersion) {
|
||||||
return;
|
src += `?v=${self.dashboardVersion}`;
|
||||||
|
}
|
||||||
|
script.src = src;
|
||||||
|
script.setAttribute('async', '');
|
||||||
|
|
||||||
|
if (onload) {
|
||||||
|
script.onload = onload;
|
||||||
|
}
|
||||||
|
|
||||||
|
document.head.appendChild(script);
|
||||||
|
}
|
||||||
|
|
||||||
|
function loadSite() {
|
||||||
|
injectScriptElement(
|
||||||
|
'./libraries/alameda.js',
|
||||||
|
function() {
|
||||||
|
// onload of require library
|
||||||
|
injectScriptElement('./scripts/site.js');
|
||||||
}
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
var script = document.createElement('script');
|
try {
|
||||||
if (self.dashboardVersion) {
|
Promise.resolve();
|
||||||
src += `?v=${self.dashboardVersion}`;
|
} catch (ex) {
|
||||||
}
|
// this checks for several cases actually, typical is
|
||||||
script.src = src;
|
// Promise() being missing on some legacy browser, and a funky one
|
||||||
script.setAttribute('async', '');
|
// is Promise() present but buggy on WebOS 2
|
||||||
|
window.Promise = undefined;
|
||||||
|
self.Promise = undefined;
|
||||||
|
}
|
||||||
|
|
||||||
if (onload) {
|
if (!self.Promise) {
|
||||||
script.onload = onload;
|
// Load Promise polyfill if they are not natively supported
|
||||||
}
|
injectScriptElement(
|
||||||
|
'./libraries/npo.js',
|
||||||
document.head.appendChild(script);
|
loadSite
|
||||||
}
|
);
|
||||||
|
} else {
|
||||||
function loadSite() {
|
loadSite();
|
||||||
injectScriptElement(
|
}
|
||||||
'./libraries/alameda.js',
|
|
||||||
function() {
|
|
||||||
// onload of require library
|
|
||||||
injectScriptElement('./scripts/site.js');
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
Promise.resolve();
|
|
||||||
} catch (ex) {
|
|
||||||
// this checks for several cases actually, typical is
|
|
||||||
// Promise() being missing on some legacy browser, and a funky one
|
|
||||||
// is Promise() present but buggy on WebOS 2
|
|
||||||
window.Promise = undefined;
|
|
||||||
self.Promise = undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!self.Promise) {
|
|
||||||
// Load Promise polyfill if they are not natively supported
|
|
||||||
injectScriptElement(
|
|
||||||
'./libraries/npo.js',
|
|
||||||
loadSite
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
loadSite();
|
|
||||||
}
|
|
||||||
})();
|
|
||||||
|
|
|
@ -15,7 +15,7 @@ export function deleteItem(options) {
|
||||||
const item = options.item;
|
const item = options.item;
|
||||||
const parentId = item.SeasonId || item.SeriesId || item.ParentId;
|
const parentId = item.SeasonId || item.SeriesId || item.ParentId;
|
||||||
|
|
||||||
let apiClient = connectionManager.getApiClient(item.ServerId);
|
const apiClient = connectionManager.getApiClient(item.ServerId);
|
||||||
|
|
||||||
return confirm({
|
return confirm({
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ export function deleteItem(options) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, function (err) {
|
}, function (err) {
|
||||||
let result = function () {
|
const result = function () {
|
||||||
return Promise.reject(err);
|
return Promise.reject(err);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -187,7 +187,7 @@ require(['apphost'], function (appHost) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (appHost.getWindowState() === 'Minimized') {
|
if (appHost.default.getWindowState() === 'Minimized') {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,7 @@ import appHost from 'apphost';
|
||||||
dom.removeEventListener(scope, 'command', fn, {});
|
dom.removeEventListener(scope, 'command', fn, {});
|
||||||
}
|
}
|
||||||
|
|
||||||
let commandTimes = {};
|
const commandTimes = {};
|
||||||
|
|
||||||
function checkCommandTime(command) {
|
function checkCommandTime(command) {
|
||||||
const last = commandTimes[command] || 0;
|
const last = commandTimes[command] || 0;
|
||||||
|
@ -113,7 +113,7 @@ import appHost from 'apphost';
|
||||||
'back': () => {
|
'back': () => {
|
||||||
if (appRouter.canGoBack()) {
|
if (appRouter.canGoBack()) {
|
||||||
appRouter.back();
|
appRouter.back();
|
||||||
} else if (appHost.supports('exit')) {
|
} else if (appHost.default.supports('exit')) {
|
||||||
appHost.exit();
|
appHost.exit();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -277,7 +277,7 @@ define(['dom', 'layoutManager', 'inputManager', 'connectionManager', 'events', '
|
||||||
html += globalize.translate('HeaderUser');
|
html += globalize.translate('HeaderUser');
|
||||||
html += '</h3>';
|
html += '</h3>';
|
||||||
|
|
||||||
if (appHost.supports('multiserver')) {
|
if (appHost.default.supports('multiserver')) {
|
||||||
html += '<a is="emby-linkbutton" class="navMenuOption lnkMediaFolder" data-itemid="selectserver" href="selectserver.html?showuser=1"><span class="material-icons navMenuOptionIcon wifi"></span><span class="navMenuOptionText">' + globalize.translate('ButtonSelectServer') + '</span></a>';
|
html += '<a is="emby-linkbutton" class="navMenuOption lnkMediaFolder" data-itemid="selectserver" href="selectserver.html?showuser=1"><span class="material-icons navMenuOptionIcon wifi"></span><span class="navMenuOptionText">' + globalize.translate('ButtonSelectServer') + '</span></a>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -589,7 +589,7 @@ define(['dom', 'layoutManager', 'inputManager', 'connectionManager', 'events', '
|
||||||
showBySelector('.lnkSyncToOtherDevices', false);
|
showBySelector('.lnkSyncToOtherDevices', false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (user.Policy.EnableContentDownloading && appHost.supports('sync')) {
|
if (user.Policy.EnableContentDownloading && appHost.default.supports('sync')) {
|
||||||
showBySelector('.libraryMenuDownloads', true);
|
showBySelector('.libraryMenuDownloads', true);
|
||||||
} else {
|
} else {
|
||||||
showBySelector('.libraryMenuDownloads', false);
|
showBySelector('.libraryMenuDownloads', false);
|
||||||
|
|
|
@ -200,8 +200,8 @@ var Dashboard = {
|
||||||
SupportsPersistentIdentifier: self.appMode === 'cordova' || self.appMode === 'android',
|
SupportsPersistentIdentifier: self.appMode === 'cordova' || self.appMode === 'android',
|
||||||
SupportsMediaControl: true
|
SupportsMediaControl: true
|
||||||
};
|
};
|
||||||
appHost.getPushTokenInfo();
|
appHost.default.getPushTokenInfo();
|
||||||
return capabilities = Object.assign(capabilities, appHost.getPushTokenInfo());
|
return capabilities = Object.assign(capabilities, appHost.default.getPushTokenInfo());
|
||||||
},
|
},
|
||||||
selectServer: function () {
|
selectServer: function () {
|
||||||
if (window.NativeShell && typeof window.NativeShell.selectServer === 'function') {
|
if (window.NativeShell && typeof window.NativeShell.selectServer === 'function') {
|
||||||
|
@ -271,17 +271,17 @@ function initClient() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function createConnectionManager() {
|
function createConnectionManager() {
|
||||||
return require(['connectionManagerFactory', 'apphost', 'credentialprovider', 'events', 'userSettings'], function (ConnectionManager, apphost, credentialProvider, events, userSettings) {
|
return require(['connectionManagerFactory', 'apphost', 'credentialprovider', 'events', 'userSettings'], function (ConnectionManager, appHost, credentialProvider, events, userSettings) {
|
||||||
var credentialProviderInstance = new credentialProvider();
|
var credentialProviderInstance = new credentialProvider();
|
||||||
var promises = [apphost.getSyncProfile(), apphost.init()];
|
var promises = [appHost.default.getSyncProfile(), appHost.default.init()];
|
||||||
|
|
||||||
return Promise.all(promises).then(function (responses) {
|
return Promise.all(promises).then(function (responses) {
|
||||||
var deviceProfile = responses[0];
|
var deviceProfile = responses[0];
|
||||||
var capabilities = Dashboard.capabilities(apphost);
|
var capabilities = Dashboard.capabilities(appHost);
|
||||||
|
|
||||||
capabilities.DeviceProfile = deviceProfile;
|
capabilities.DeviceProfile = deviceProfile;
|
||||||
|
|
||||||
var connectionManager = new ConnectionManager(credentialProviderInstance, apphost.appName(), apphost.appVersion(), apphost.deviceName(), apphost.deviceId(), capabilities);
|
var connectionManager = new ConnectionManager(credentialProviderInstance, appHost.default.appName(), appHost.default.appVersion(), appHost.default.deviceName(), appHost.default.deviceId(), capabilities);
|
||||||
|
|
||||||
defineConnectionManager(connectionManager);
|
defineConnectionManager(connectionManager);
|
||||||
bindConnectionManagerEvents(connectionManager, events, userSettings);
|
bindConnectionManagerEvents(connectionManager, events, userSettings);
|
||||||
|
@ -292,7 +292,7 @@ function initClient() {
|
||||||
return require(['apiclient'], function (apiClientFactory) {
|
return require(['apiclient'], function (apiClientFactory) {
|
||||||
console.debug('creating ApiClient singleton');
|
console.debug('creating ApiClient singleton');
|
||||||
|
|
||||||
var apiClient = new apiClientFactory(Dashboard.serverAddress(), apphost.appName(), apphost.appVersion(), apphost.deviceName(), apphost.deviceId());
|
var apiClient = new apiClientFactory(Dashboard.serverAddress(), appHost.default.appName(), appHost.default.appVersion(), appHost.default.deviceName(), appHost.default.deviceId());
|
||||||
|
|
||||||
apiClient.enableAutomaticNetworking = false;
|
apiClient.enableAutomaticNetworking = false;
|
||||||
apiClient.manualAddressOnly = true;
|
apiClient.manualAddressOnly = true;
|
||||||
|
@ -350,8 +350,8 @@ function initClient() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function getLayoutManager(layoutManager, appHost) {
|
function getLayoutManager(layoutManager, appHost) {
|
||||||
if (appHost.getDefaultLayout) {
|
if (appHost.default.getDefaultLayout) {
|
||||||
layoutManager.defaultLayout = appHost.getDefaultLayout();
|
layoutManager.defaultLayout = appHost.default.getDefaultLayout();
|
||||||
}
|
}
|
||||||
|
|
||||||
layoutManager.init();
|
layoutManager.init();
|
||||||
|
@ -538,13 +538,13 @@ function initClient() {
|
||||||
require(['components/nowPlayingBar/nowPlayingBar']);
|
require(['components/nowPlayingBar/nowPlayingBar']);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (appHost.supports('remotecontrol')) {
|
if (appHost.default.supports('remotecontrol')) {
|
||||||
require(['playerSelectionMenu', 'components/playback/remotecontrolautoplay']);
|
require(['playerSelectionMenu', 'components/playback/remotecontrolautoplay']);
|
||||||
}
|
}
|
||||||
|
|
||||||
require(['libraries/screensavermanager']);
|
require(['libraries/screensavermanager']);
|
||||||
|
|
||||||
if (!appHost.supports('physicalvolumecontrol') || browser.touch) {
|
if (!appHost.default.supports('physicalvolumecontrol') || browser.touch) {
|
||||||
require(['components/playback/volumeosd']);
|
require(['components/playback/volumeosd']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue