remove useless autoplay script and add folder for settings

This commit is contained in:
dkanada 2020-01-24 02:57:29 +09:00
parent 33ed166ec9
commit 6728f5b718
8 changed files with 27 additions and 106 deletions

View File

@ -167,24 +167,24 @@ define(["appSettings", "browser", "events", "htmlMediaHelper"], function (appSet
if (browser.mobile) {
return false;
}
var savedResult = appSettings.get(htmlMediaAutoplayAppStorageKey);
return "true" === savedResult || "false" !== savedResult && null;
}
function cueSupported() {
function supportsCue() {
try {
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.log("Error detecting cue support:" + err);
console.log("error detecting cue support: " + err);
return false;
}
}
@ -204,8 +204,6 @@ define(["appSettings", "browser", "events", "htmlMediaHelper"], function (appSet
}
}
var htmlMediaAutoplayAppStorageKey = "supportshtmlmediaautoplay0";
var supportedFeatures = function () {
var features = [];
@ -280,7 +278,7 @@ define(["appSettings", "browser", "events", "htmlMediaHelper"], function (appSet
//features.push("multiserver");
features.push("screensaver");
if (!browser.orsay && !browser.tizen && !browser.msie && (browser.firefox || browser.ps4 || browser.edge || cueSupported())) {
if (!browser.orsay && !browser.tizen && !browser.msie && (browser.firefox || browser.ps4 || browser.edge || supportsCue())) {
features.push("subtitleappearancesettings");
}
@ -299,18 +297,6 @@ define(["appSettings", "browser", "events", "htmlMediaHelper"], function (appSet
return features;
}();
if (supportedFeatures.indexOf("htmlvideoautoplay") === -1 && supportsHtmlMediaAutoplay() !== false) {
require(["autoPlayDetect"], function (autoPlayDetect) {
autoPlayDetect.supportsHtmlMediaAutoplay().then(function () {
appSettings.set(htmlMediaAutoplayAppStorageKey, "true");
supportedFeatures.push("htmlvideoautoplay");
supportedFeatures.push("htmlaudioautoplay");
}, function () {
appSettings.set(htmlMediaAutoplayAppStorageKey, "false");
});
});
}
var deviceId;
var deviceName;
var appName = "Jellyfin Web";
@ -395,7 +381,9 @@ define(["appSettings", "browser", "events", "htmlMediaHelper"], function (appSet
}
}
};
var doc = self.document;
var isHidden = false;
if (doc) {
if (void 0 !== doc.visibilityState) {
@ -419,8 +407,6 @@ define(["appSettings", "browser", "events", "htmlMediaHelper"], function (appSet
}
}
var isHidden = false;
if (doc) {
doc.addEventListener(visibilityChange, function () {
if (document[visibilityState]) {

View File

@ -1401,7 +1401,6 @@ define(['browser', 'require', 'events', 'apphost', 'loading', 'dom', 'playbackMa
dlg.classList.add('videoPlayerContainer');
if (options.backdropUrl) {
dlg.classList.add('videoPlayerContainer-withBackdrop');
dlg.style.backgroundImage = "url('" + options.backdropUrl + "')";
}
@ -1410,11 +1409,7 @@ define(['browser', 'require', 'events', 'apphost', 'loading', 'dom', 'playbackMa
dlg.classList.add('videoPlayerContainer-onTop');
}
// playsinline new for iOS 10
// https://developer.apple.com/library/content/releasenotes/General/WhatsNewInSafari/Articles/Safari_10_0.html
var html = '';
var cssClass = 'htmlvideoplayer';
if (!browser.chromecast) {
@ -1449,7 +1444,6 @@ define(['browser', 'require', 'events', 'apphost', 'loading', 'dom', 'playbackMa
self._mediaElement = videoElement;
if (mediaManager) {
if (!mediaManager.embyInit) {
initMediaManager();
mediaManager.embyInit = true;
@ -1465,9 +1459,7 @@ define(['browser', 'require', 'events', 'apphost', 'loading', 'dom', 'playbackMa
} else {
resolve(videoElement);
}
});
} else {
if (options.backdropUrl) {
dlg.classList.add('videoPlayerContainer-withBackdrop');

View File

@ -2,7 +2,6 @@ define(['browser', 'appSettings', 'events'], function (browser, appSettings, eve
'use strict';
function setLayout(instance, layout, selectedLayout) {
if (layout === selectedLayout) {
instance[layout] = true;
document.documentElement.classList.add('layout-' + layout);
@ -38,7 +37,6 @@ define(['browser', 'appSettings', 'events'], function (browser, appSettings, eve
};
LayoutManager.prototype.getSavedLayout = function (layout) {
return appSettings.get('layout');
};
@ -64,4 +62,4 @@ define(['browser', 'appSettings', 'events'], function (browser, appSettings, eve
};
return new LayoutManager();
});
});

View File

@ -1,61 +0,0 @@
define([], function () {
'use strict';
function supportsHtmlMediaAutoplay() {
return new Promise(function (resolve, reject) {
var timeout;
var elem = document.createElement('video');
var elemStyle = elem.style;
//skip the test if video itself, or the autoplay
//element on it isn't supported
if (!('autoplay' in elem)) {
reject();
return;
}
elemStyle.position = 'absolute';
elemStyle.height = 0;
elemStyle.width = 0;
elem.setAttribute('autoplay', 'autoplay');
elem.style.display = 'none';
document.body.appendChild(elem);
var testAutoplay = function (arg) {
clearTimeout(timeout);
elem.removeEventListener('playing', testAutoplay);
elem.removeEventListener('play', testAutoplay);
var supported = (arg && arg.type === 'playing') || (arg && arg.type === 'play') || elem.currentTime !== 0;
elem.parentNode.removeChild(elem);
if (supported) {
resolve();
} else {
reject();
}
};
// play needed for firefox
elem.addEventListener('play', testAutoplay);
elem.addEventListener('playing', testAutoplay);
try {
elem.src = 'data:video/mp4;base64,AAAAHGZ0eXBtcDQyAAAAAG1wNDJpc29tYXZjMQAAAz5tb292AAAAbG12aGQAAAAAzaNacc2jWnEAAV+QAAFfkAABAAABAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAGGlvZHMAAAAAEICAgAcAT////3//AAACQ3RyYWsAAABcdGtoZAAAAAHNo1pxzaNacQAAAAEAAAAAAAFfkAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAEAAAAAAEAAAABAAAAAAAd9tZGlhAAAAIG1kaGQAAAAAzaNacc2jWnEAAV+QAAFfkFXEAAAAAAAhaGRscgAAAAAAAAAAdmlkZQAAAAAAAAAAAAAAAAAAAAGWbWluZgAAABR2bWhkAAAAAQAAAAAAAAAAAAAAJGRpbmYAAAAcZHJlZgAAAAAAAAABAAAADHVybCAAAAABAAABVnN0YmwAAACpc3RzZAAAAAAAAAABA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JsdXJheV9jb21wYXQ9MCBjb25zdHJhaW5lZF9pbnRyYT0wIGJmcmFtZXM9MCB3ZWlnaHRwPTAga2V5aW50PTUwIGtleWludF9taW49NSBzY2VuZWN1dD00MCBpbnRyYV9yZWZyZXNoPTAgcmM9Y3FwIG1idHJlZT0wIHFwPTAAgAAAAD5liISscR8A+E4ACAACFoAAITAAAgsAAPgYCoKgoC+L4vi+KAvi+L4YfAEAACMzgABF9AAEUGUgABDJiXnf4AAAAARBmiKUAAAABEGaQpQAAAAEQZpilAAAAARBmoKU';
var promise = elem.play();
if (promise && promise.catch) {
promise.catch(reject);
}
timeout = setTimeout(testAutoplay, 500);
} catch (e) {
reject();
return;
}
});
}
return {
supportsHtmlMediaAutoplay: supportsHtmlMediaAutoplay
};
});

View File

@ -1,5 +0,0 @@
define(['userSettingsBuilder'], function (userSettingsBuilder) {
'use strict';
return new userSettingsBuilder();
});

View File

@ -10,13 +10,13 @@ define(['appStorage', 'events'], function (appStorage, events) {
}
function AppSettings() {
}
AppSettings.prototype.enableAutoLogin = function (val) {
if (val != null) {
this.set('enableAutoLogin', val.toString());
}
return this.get('enableAutoLogin') !== 'false';
};
@ -132,4 +132,4 @@ define(['appStorage', 'events'], function (appStorage, events) {
};
return new AppSettings();
});
});

View File

@ -242,5 +242,5 @@ define(['appSettings', 'events'], function (appSettings, events) {
return this.get(key, true);
};
return UserSettings;
return new UserSettings();
});

View File

@ -315,6 +315,14 @@ var AppInfo = {};
return "components";
}
function getElementsPath() {
return "elements"
}
function getScriptsPath() {
return "scripts"
}
function getPlaybackManager(playbackManager) {
window.addEventListener("beforeunload", function () {
try {
@ -650,8 +658,12 @@ var AppInfo = {};
(function () {
var urlArgs = "v=" + (window.dashboardVersion || new Date().getDate());
var bowerPath = getBowerPath();
var componentsPath = getComponentsPath();
var elementsPath = getElementsPath();
var scriptsPath = getScriptsPath();
var paths = {
browserdeviceprofile: "scripts/browserdeviceprofile",
browser: "scripts/browser",
@ -672,7 +684,6 @@ var AppInfo = {};
itemHelper: componentsPath + "/itemhelper",
itemShortcuts: componentsPath + "/shortcuts",
playQueueManager: componentsPath + "/playback/playqueuemanager",
autoPlayDetect: componentsPath + "/playback/autoplaydetect",
nowPlayingHelper: componentsPath + "/playback/nowplayinghelper",
pluginManager: componentsPath + "/pluginManager",
packageManager: componentsPath + "/packagemanager",
@ -765,7 +776,6 @@ var AppInfo = {};
return queryString;
});
var elementsPath = "elements"
define("emby-button", [elementsPath + "/emby-button/emby-button"], returnFirstDependency);
define("paper-icon-button-light", [elementsPath + "/emby-button/paper-icon-button-light"], returnFirstDependency);
define("emby-checkbox", [elementsPath + "/emby-checkbox/emby-checkbox"], returnFirstDependency);
@ -778,6 +788,9 @@ var AppInfo = {};
define("emby-textarea", [elementsPath + "/emby-textarea/emby-textarea"], returnFirstDependency);
define("emby-toggle", [elementsPath + "/emby-toggle/emby-toggle"], returnFirstDependency);
define("appSettings", [scriptsPath + "/settings/appSettings"], returnFirstDependency);
define("userSettings", [scriptsPath + "/settings/userSettings"], returnFirstDependency);
define("chromecastHelper", [componentsPath + "/chromecast/chromecasthelpers"], returnFirstDependency);
define("mediaSession", [componentsPath + "/playback/mediasession"], returnFirstDependency);
define("actionsheet", [componentsPath + "/actionsheet/actionsheet"], returnFirstDependency);
@ -865,8 +878,6 @@ var AppInfo = {};
define("toast", [componentsPath + "/toast/toast"], returnFirstDependency);
define("scrollHelper", [componentsPath + "/scrollhelper"], returnFirstDependency);
define("touchHelper", [componentsPath + "/touchhelper"], returnFirstDependency);
define("appSettings", [componentsPath + "/appSettings"], returnFirstDependency);
define("userSettings", [componentsPath + "/usersettings/usersettings"], returnFirstDependency);
define("userSettingsBuilder", [componentsPath + "/usersettings/usersettingsbuilder", "layoutManager", "browser"], returnFirstDependency);
define("imageUploader", [componentsPath + "/imageuploader/imageuploader"], returnFirstDependency);
define("htmlMediaHelper", [componentsPath + "/htmlMediaHelper"], returnFirstDependency);