';
- imgUrl || (cardImageContainer += '
local_movies ');
- var nameHtml = "";
- nameHtml += '
' + chapter.Name + "
", nameHtml += '
' + datetime.getDisplayRunningTime(chapter.StartPositionTicks) + "
";
- var cardBoxCssClass = "cardBox",
- cardScalableClass = "cardScalable";
+
+ var imgUrl = getImgUrl(item, chapter, index, options.width || 400, apiClient);
+
+ var cardImageContainerClass = 'cardContent cardContent-shadow cardImageContainer chapterCardImageContainer';
+ if (options.coverImage) {
+ cardImageContainerClass += ' coveredImage';
+ }
+ var dataAttributes = ' data-action="play" data-isfolder="' + item.IsFolder + '" data-id="' + item.Id + '" data-serverid="' + item.ServerId + '" data-type="' + item.Type + '" data-mediatype="' + item.MediaType + '" data-positionticks="' + chapter.StartPositionTicks + '"';
+ var cardImageContainer = imgUrl ? ('
') : ('
');
+
+ if (!imgUrl) {
+ cardImageContainer += '
local_movies ';
+ }
+
+ var nameHtml = '';
+ nameHtml += '
' + chapter.Name + '
';
+ nameHtml += '
' + datetime.getDisplayRunningTime(chapter.StartPositionTicks) + '
';
+
+ var cardBoxCssClass = 'cardBox';
+ var cardScalableClass = 'cardScalable';
+
if (layoutManager.tv) {
var enableFocusTransfrom = !browser.slow && !browser.edge;
- cardScalableClass += " card-focuscontent", enableFocusTransfrom ? cardBoxCssClass += " cardBox-focustransform cardBox-withfocuscontent" : (cardBoxCssClass += " cardBox-withfocuscontent-large", cardScalableClass += " card-focuscontent-large")
+
+ cardScalableClass += ' card-focuscontent';
+
+ if (enableFocusTransfrom) {
+ cardBoxCssClass += ' cardBox-focustransform cardBox-withfocuscontent';
+ } else {
+ cardBoxCssClass += ' cardBox-withfocuscontent-large';
+ cardScalableClass += ' card-focuscontent-large';
+ }
}
- return '
' + cardImageContainer + '
"
+
+ var html = '
' + cardImageContainer + '
';
+
+ return html;
}
function buildChapterCards(item, chapters, options) {
+
if (options.parentContainer) {
- if (!document.body.contains(options.parentContainer)) return;
- if (!chapters.length) return void options.parentContainer.classList.add("hide");
- options.parentContainer.classList.remove("hide")
+ // Abort if the container has been disposed
+ if (!document.body.contains(options.parentContainer)) {
+ return;
+ }
+
+ if (chapters.length) {
+ options.parentContainer.classList.remove('hide');
+ } else {
+ options.parentContainer.classList.add('hide');
+ return;
+ }
}
+
var html = buildChapterCardsHtml(item, chapters, options);
- options.itemsContainer.innerHTML = html, imageLoader.lazyChildren(options.itemsContainer)
+
+ options.itemsContainer.innerHTML = html;
+
+ imageLoader.lazyChildren(options.itemsContainer);
}
+
return {
buildChapterCards: buildChapterCards
- }
+ };
+
});
\ No newline at end of file
diff --git a/src/bower_components/emby-webcomponents/cardbuilder/peoplecardbuilder.js b/src/bower_components/emby-webcomponents/cardbuilder/peoplecardbuilder.js
index 4dc70f7ed4..e0a5050dc5 100644
--- a/src/bower_components/emby-webcomponents/cardbuilder/peoplecardbuilder.js
+++ b/src/bower_components/emby-webcomponents/cardbuilder/peoplecardbuilder.js
@@ -1,18 +1,22 @@
-define(["cardBuilder"], function(cardBuilder) {
- "use strict";
+define(['cardBuilder'], function (cardBuilder) {
+ 'use strict';
function buildPeopleCards(items, options) {
+
options = Object.assign(options || {}, {
- cardLayout: !1,
- centerText: !0,
- showTitle: !0,
- cardFooterAside: "none",
- showPersonRoleOrType: !0,
- cardCssClass: "personCard",
- defaultCardImageIcon: ""
- }), cardBuilder.buildCards(items, options)
+ cardLayout: false,
+ centerText: true,
+ showTitle: true,
+ cardFooterAside: 'none',
+ showPersonRoleOrType: true,
+ cardCssClass: 'personCard',
+ defaultCardImageIcon: ''
+ });
+ cardBuilder.buildCards(items, options);
}
+
return {
buildPeopleCards: buildPeopleCards
- }
+ };
+
});
\ No newline at end of file
diff --git a/src/bower_components/emby-webcomponents/cardbuilder/roundcard.css b/src/bower_components/emby-webcomponents/cardbuilder/roundcard.css
index dec5e8d58f..d0bd950972 100644
--- a/src/bower_components/emby-webcomponents/cardbuilder/roundcard.css
+++ b/src/bower_components/emby-webcomponents/cardbuilder/roundcard.css
@@ -1,10 +1,7 @@
-.card-round:focus>.cardBox-focustransform {
- -webkit-transform: scale(1.26, 1.26);
- transform: scale(1.26, 1.26)
+.card-round:focus > .cardBox-focustransform {
+ transform: scale(1.26, 1.26);
}
-.cardImage-round,
-.cardImageContainer-round {
- -webkit-border-radius: 1000px;
- border-radius: 1000px
-}
\ No newline at end of file
+.cardImageContainer-round, .cardImage-round {
+ border-radius: 1000px;
+}
diff --git a/src/bower_components/emby-webcomponents/chromecast/chromecasthelpers.js b/src/bower_components/emby-webcomponents/chromecast/chromecasthelpers.js
index e3330bf37e..4950f6540e 100644
--- a/src/bower_components/emby-webcomponents/chromecast/chromecasthelpers.js
+++ b/src/bower_components/emby-webcomponents/chromecast/chromecasthelpers.js
@@ -1,67 +1,228 @@
-define(["events"], function(events) {
- "use strict";
+define(['events'], function (events) {
+ 'use strict';
+
+ // LinkParser
+ //
+ // https://github.com/ravisorg/LinkParser
+ //
+ // Locate and extract almost any URL within a string. Handles protocol-less domains, IPv4 and
+ // IPv6, unrecognised TLDs, and more.
+ //
+ // This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.
+ // http://creativecommons.org/licenses/by-sa/4.0/
+ (function () {
+
+ // Original URL regex from the Android android.text.util.Linkify function, found here:
+ // http://stackoverflow.com/a/19696443
+ //
+ // However there were problems with it, most probably related to the fact it was
+ // written in 2007, and it's been highly modified.
+ //
+ // 1) I didn't like the fact that it was tied to specific TLDs, since new ones
+ // are being added all the time it wouldn't be reasonable to expect developer to
+ // be continually updating their regular expressions.
+ //
+ // 2) It didn't allow unicode characters in the domains which are now allowed in
+ // many languages, (including some IDN TLDs). Again these are constantly being
+ // added to and it doesn't seem reasonable to hard-code them. Note this ended up
+ // not being possible in standard JS due to the way it handles multibyte strings.
+ // It is possible using XRegExp, however a big performance hit results. Disabled
+ // for now.
+ //
+ // 3) It didn't allow for IPv6 hostnames
+ // IPv6 regex from http://stackoverflow.com/a/17871737
+ //
+ // 4) It was very poorly commented
+ //
+ // 5) It wasn't as smart as it could have been about what should be part of a
+ // URL and what should be part of human language.
+
+ var protocols = "(?:(?:http|https|rtsp|ftp):\\/\\/)";
+ var credentials = "(?:(?:[a-z0-9\\$\\-\\_\\.\\+\\!\\*\\'\\(\\)\\,\\;\\?\\&\\=]|(?:\\%[a-f0-9]{2})){1,64}" // username (1-64 normal or url escaped characters)
+ + "(?:\\:(?:[a-z0-9\\$\\-\\_\\.\\+\\!\\*\\'\\(\\)\\,\\;\\?\\&\\=]|(?:\\%[a-f0-9]{2})){1,25})?" // followed by optional password (: + 1-25 normal or url escaped characters)
+ + "\\@)";
+
+ // IPv6 Regex http://forums.intermapper.com/viewtopic.php?t=452
+ // by Dartware, LLC is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License
+ // http://intermapper.com/
+ var ipv6 = "("
+ + "(([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))"
+ + "|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))"
+ + "|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))"
+ + "|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))"
+ + "|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))"
+ + "|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))"
+ + "|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))"
+ + "|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))"
+ + ")(%.+)?";
+
+ var ipv4 = "(?:25[0-5]|2[0-4][0-9]|[0-1][0-9]{2}|[1-9][0-9]|[1-9])\\."
+ + "(?:25[0-5]|2[0-4][0-9]|[0-1][0-9]{2}|[1-9][0-9]|[1-9]|0)\\."
+ + "(?:25[0-5]|2[0-4][0-9]|[0-1][0-9]{2}|[1-9][0-9]|[1-9]|0)\\."
+ + "(?:25[0-5]|2[0-4][0-9]|[0-1][0-9]{2}|[1-9][0-9]|[0-9])";
+
+ // This would have been a lot cleaner if JS RegExp supported conditionals...
+ var linkRegExpString =
+
+ // begin match for protocol / username / password / host
+ "(?:"
+
+ // ============================
+ // If we have a recognized protocol at the beginning of the URL, we're
+ // more relaxed about what we accept, because we assume the user wants
+ // this to be a URL, and we're not accidentally matching human language
+ + protocols + "?"
+
+ // optional username:password@
+ + credentials + "?"
+
+ // IP address (both v4 and v6)
+ + "(?:"
+
+ // IPv6
+ + ipv6
+
+ // IPv4
+ + "|" + ipv4
+
+ + ")"
+
+ // end match for protocol / username / password / host
+ + ")"
+
+ // optional port number
+ + "(?:\\:\\d{1,5})?"
+
+ // plus optional path and query params (no unicode allowed here?)
+ + "(?:"
+ + "\\/(?:"
+ // some characters we'll accept because it's unlikely human language
+ // would use them after a URL unless they were part of the url
+ + "(?:[a-z0-9\\/\\@\\&\\#\\~\\*\\_\\-\\+])"
+ + "|(?:\\%[a-f0-9]{2})"
+ // some characters are much more likely to be used AFTER a url and
+ // were not intended to be included in the url itself. Mostly end
+ // of sentence type things. It's also likely that the URL would
+ // still work if any of these characters were missing from the end
+ // because we parsed it incorrectly. For these characters to be accepted
+ // they must be followed by another character that we're reasonably
+ // sure is part of the url
+ + "|(?:[\\;\\?\\:\\.\\!\\'\\(\\)\\,\\=]+(?=(?:[a-z0-9\\/\\@\\&\\#\\~\\*\\_\\-\\+])|(?:\\%[a-f0-9]{2})))"
+ + ")*"
+ + "|\\b|\$"
+ + ")";
+
+ // regex = XRegExp(regex,'gi');
+ var linkRegExp = RegExp(linkRegExpString, 'gi');
+
+ var protocolRegExp = RegExp('^' + protocols, 'i');
+
+ // if url doesn't begin with a known protocol, add http by default
+ function ensureProtocol(url) {
+ if (!url.match(protocolRegExp)) {
+ url = "http://" + url;
+ }
+ return url;
+ }
+
+ // look for links in the text
+ var LinkParser = {
+ parse: function (text) {
+ var links = [];
+ var match;
+
+ while (match = linkRegExp.exec(text)) {
+ // console.log(matches);
+ var txt = match[0];
+ var pos = match.index;
+ var len = txt.length;
+ var url = ensureProtocol(text);
+ links.push({ 'pos': pos, 'text': txt, 'len': len, 'url': url });
+ }
+
+ return links;
+ }
+
+ };
+
+ window.LinkParser = LinkParser;
+ })();
+
+ var cache = {};
function isValidIpAddress(address) {
- return 1 == LinkParser.parse(address).length
+
+ var links = LinkParser.parse(address);
+
+ return links.length == 1;
}
function isLocalIpAddress(address) {
- return address = address.toLowerCase(), -1 !== address.indexOf("127.0.0.1") || -1 !== address.indexOf("localhost")
+
+ address = address.toLowerCase();
+
+ if (address.indexOf('127.0.0.1') !== -1) {
+ return true;
+ }
+ if (address.indexOf('localhost') !== -1) {
+ return true;
+ }
+
+ return false;
}
function getServerAddress(apiClient) {
+
var serverAddress = apiClient.serverAddress();
- if (isValidIpAddress(serverAddress) && !isLocalIpAddress(serverAddress)) return Promise.resolve(serverAddress);
+
+ if (isValidIpAddress(serverAddress) && !isLocalIpAddress(serverAddress)) {
+ return Promise.resolve(serverAddress);
+ }
+
var cachedValue = getCachedValue(serverAddress);
- return cachedValue ? Promise.resolve(cachedValue) : apiClient.getEndpointInfo().then(function(endpoint) {
- return endpoint.IsInNetwork ? apiClient.getPublicSystemInfo().then(function(info) {
- return addToCache(serverAddress, info.LocalAddress), info.LocalAddress
- }) : (addToCache(serverAddress, serverAddress), serverAddress)
- })
+ if (cachedValue) {
+ return Promise.resolve(cachedValue);
+ }
+
+ return apiClient.getEndpointInfo().then(function (endpoint) {
+ if (endpoint.IsInNetwork) {
+ return apiClient.getPublicSystemInfo().then(function (info) {
+ addToCache(serverAddress, info.LocalAddress);
+ return info.LocalAddress;
+ });
+ } else {
+ addToCache(serverAddress, serverAddress);
+ return serverAddress;
+ }
+ });
}
function clearCache() {
- cache = {}
+ cache = {};
}
function addToCache(key, value) {
cache[key] = {
value: value,
- time: (new Date).getTime()
- }
+ time: new Date().getTime()
+ };
}
function getCachedValue(key) {
+
var obj = cache[key];
- return obj && (new Date).getTime() - obj.time < 18e4 ? obj.value : null
- }! function() {
- function ensureProtocol(url) {
- return url.match(protocolRegExp) || (url = "http://" + url), url
+
+ if (obj && (new Date().getTime() - obj.time) < 180000) {
+ return obj.value;
}
- var protocols = "(?:(?:http|https|rtsp|ftp):\\/\\/)",
- linkRegExp = RegExp("(?:(?:(?:http|https|rtsp|ftp):\\/\\/)?(?:(?:[a-z0-9\\$\\-\\_\\.\\+\\!\\*\\'\\(\\)\\,\\;\\?\\&\\=]|(?:\\%[a-f0-9]{2})){1,64}(?:\\:(?:[a-z0-9\\$\\-\\_\\.\\+\\!\\*\\'\\(\\)\\,\\;\\?\\&\\=]|(?:\\%[a-f0-9]{2})){1,25})?\\@)?(?:((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:)))(%.+)?|(?:25[0-5]|2[0-4][0-9]|[0-1][0-9]{2}|[1-9][0-9]|[1-9])\\.(?:25[0-5]|2[0-4][0-9]|[0-1][0-9]{2}|[1-9][0-9]|[1-9]|0)\\.(?:25[0-5]|2[0-4][0-9]|[0-1][0-9]{2}|[1-9][0-9]|[1-9]|0)\\.(?:25[0-5]|2[0-4][0-9]|[0-1][0-9]{2}|[1-9][0-9]|[0-9])))(?:\\:\\d{1,5})?(?:\\/(?:(?:[a-z0-9\\/\\@\\&\\#\\~\\*\\_\\-\\+])|(?:\\%[a-f0-9]{2})|(?:[\\;\\?\\:\\.\\!\\'\\(\\)\\,\\=]+(?=(?:[a-z0-9\\/\\@\\&\\#\\~\\*\\_\\-\\+])|(?:\\%[a-f0-9]{2}))))*|\\b|$)", "gi"),
- protocolRegExp = RegExp("^" + protocols, "i"),
- LinkParser = {
- parse: function(text) {
- for (var match, links = []; match = linkRegExp.exec(text);) {
- var txt = match[0],
- pos = match.index,
- len = txt.length,
- url = ensureProtocol(text);
- links.push({
- pos: pos,
- text: txt,
- len: len,
- url: url
- })
- }
- return links
- }
- };
- window.LinkParser = LinkParser
- }();
- var cache = {};
- return events.on(ConnectionManager, "localusersignedin", clearCache), events.on(ConnectionManager, "localusersignedout", clearCache), {
- getServerAddress: getServerAddress
+
+ return null;
}
+
+ events.on(ConnectionManager, 'localusersignedin', clearCache);
+ events.on(ConnectionManager, 'localusersignedout', clearCache);
+
+ return {
+ getServerAddress: getServerAddress
+ };
});
\ No newline at end of file
diff --git a/src/bower_components/emby-webcomponents/chromecast/chromecastplayer.js b/src/bower_components/emby-webcomponents/chromecast/chromecastplayer.js
index 08b28d1aec..4f8b4cf952 100644
--- a/src/bower_components/emby-webcomponents/chromecast/chromecastplayer.js
+++ b/src/bower_components/emby-webcomponents/chromecast/chromecastplayer.js
@@ -1,139 +1,329 @@
-define(["appSettings", "userSettings", "playbackManager", "connectionManager", "globalize", "events", "require", "castSenderApiLoader"], function(appSettings, userSettings, playbackManager, connectionManager, globalize, events, require, castSenderApiLoader) {
- "use strict";
+define(['appSettings', 'userSettings', 'playbackManager', 'connectionManager', 'globalize', 'events', 'require', 'castSenderApiLoader'], function (appSettings, userSettings, playbackManager, connectionManager, globalize, events, require, castSenderApiLoader) {
+ 'use strict';
+
+ // Based on https://github.com/googlecast/CastVideos-chrome/blob/master/CastVideos.js
+ var currentResolve;
+ var currentReject;
+
+ var PlayerName = 'Chromecast';
function sendConnectionResult(isOk) {
- var resolve = currentResolve,
- reject = currentReject;
- currentResolve = null, currentReject = null, isOk ? resolve && resolve() : reject ? reject() : playbackManager.removeActivePlayer(PlayerName)
+
+ var resolve = currentResolve;
+ var reject = currentReject;
+
+ currentResolve = null;
+ currentReject = null;
+
+ if (isOk) {
+ if (resolve) {
+ resolve();
+ }
+ } else {
+ if (reject) {
+ reject();
+ } else {
+ playbackManager.removeActivePlayer(PlayerName);
+ }
+ }
}
+ /**
+ * Constants of states for Chromecast device
+ **/
+ var DEVICE_STATE = {
+ 'IDLE': 0,
+ 'ACTIVE': 1,
+ 'WARNING': 2,
+ 'ERROR': 3
+ };
+
+ /**
+ * Constants of states for CastPlayer
+ **/
+ var PLAYER_STATE = {
+ 'IDLE': 'IDLE',
+ 'LOADING': 'LOADING',
+ 'LOADED': 'LOADED',
+ 'PLAYING': 'PLAYING',
+ 'PAUSED': 'PAUSED',
+ 'STOPPED': 'STOPPED',
+ 'SEEKING': 'SEEKING',
+ 'ERROR': 'ERROR'
+ };
+
+ var applicationID = "F007D354";
+
+ // This is the beta version used for testing new changes
+
+ //applicationID = '27C4EB5B';
+
+ var messageNamespace = 'urn:x-cast:com.connectsdk';
+
+ var CastPlayer = function () {
+
+ /* device variables */
+ // @type {DEVICE_STATE} A state for device
+ this.deviceState = DEVICE_STATE.IDLE;
+
+ /* Cast player variables */
+ // @type {Object} a chrome.cast.media.Media object
+ this.currentMediaSession = null;
+
+ // @type {string} a chrome.cast.Session object
+ this.session = null;
+ // @type {PLAYER_STATE} A state for Cast media player
+ this.castPlayerState = PLAYER_STATE.IDLE;
+
+ this.hasReceivers = false;
+
+ // bind once - commit 2ebffc2271da0bc5e8b13821586aee2a2e3c7753
+ this.errorHandler = this.onError.bind(this);
+ this.mediaStatusUpdateHandler = this.onMediaStatusUpdate.bind(this);
+
+ this.initializeCastPlayer();
+ };
+
+ /**
+ * Initialize Cast media player
+ * Initializes the API. Note that either successCallback and errorCallback will be
+ * invoked once the API has finished initialization. The sessionListener and
+ * receiverListener may be invoked at any time afterwards, and possibly more than once.
+ */
+ CastPlayer.prototype.initializeCastPlayer = function () {
+
+ var chrome = window.chrome;
+
+ if (!chrome) {
+ return;
+ }
+
+ if (!chrome.cast || !chrome.cast.isAvailable) {
+
+ setTimeout(this.initializeCastPlayer.bind(this), 1000);
+ return;
+ }
+
+ // request session
+ var sessionRequest = new chrome.cast.SessionRequest(applicationID);
+ var apiConfig = new chrome.cast.ApiConfig(sessionRequest,
+ this.sessionListener.bind(this),
+ this.receiverListener.bind(this),
+ "origin_scoped");
+
+ console.log('chromecast.initialize');
+
+ chrome.cast.initialize(apiConfig, this.onInitSuccess.bind(this), this.errorHandler);
+
+ };
+
+ /**
+ * Callback function for init success
+ */
+ CastPlayer.prototype.onInitSuccess = function () {
+ this.isInitialized = true;
+ console.log("chromecast init success");
+ };
+
+ /**
+ * Generic error callback function
+ */
+ CastPlayer.prototype.onError = function () {
+ console.log("chromecast error");
+ };
+
+ /**
+ * @param {!Object} e A new session
+ * This handles auto-join when a page is reloaded
+ * When active session is detected, playback will automatically
+ * join existing session and occur in Cast mode and media
+ * status gets synced up with current media of the session
+ */
+ CastPlayer.prototype.sessionListener = function (e) {
+
+ this.session = e;
+ if (this.session) {
+
+ //console.log('sessionListener ' + JSON.stringify(e));
+
+ if (this.session.media[0]) {
+ this.onMediaDiscovered('activeSession', this.session.media[0]);
+ }
+
+ this.onSessionConnected(e);
+ }
+ };
+
function alertText(text, title) {
- require(["alert"], function(alert) {
+ require(['alert'], function (alert) {
alert({
text: text,
title: title
- })
- })
+ });
+ });
}
- function normalizeImages(state) {
- if (state && state.NowPlayingItem) {
- var item = state.NowPlayingItem;
- item.ImageTags && item.ImageTags.Primary || item.PrimaryImageTag && (item.ImageTags = item.ImageTags || {}, item.ImageTags.Primary = item.PrimaryImageTag), item.BackdropImageTag && item.BackdropItemId === item.Id && (item.BackdropImageTags = [item.BackdropImageTag]), item.BackdropImageTag && item.BackdropItemId !== item.Id && (item.ParentBackdropImageTags = [item.BackdropImageTag], item.ParentBackdropItemId = item.BackdropItemId)
+ CastPlayer.prototype.messageListener = function (namespace, message) {
+
+ if (typeof (message) === 'string') {
+ message = JSON.parse(message);
}
- }
- function getItemsForPlayback(apiClient, query) {
- var userId = apiClient.getCurrentUserId();
- return query.Ids && 1 === query.Ids.split(",").length ? apiClient.getItem(userId, query.Ids.split(",")).then(function(item) {
- return {
- Items: [item],
- TotalRecordCount: 1
- }
- }) : (query.Limit = query.Limit || 100, query.ExcludeLocationTypes = "Virtual", query.EnableTotalRecordCount = !1, apiClient.getItems(userId, query))
- }
+ if (message.type === 'playbackerror') {
- function bindEventForRelay(instance, eventName) {
- events.on(instance._castPlayer, eventName, function(e, data) {
- var state = instance.getPlayerStateInternal(data);
- events.trigger(instance, eventName, [state])
- })
- }
-
- function initializeChromecast() {
- var instance = this;
- instance._castPlayer = new CastPlayer, document.dispatchEvent(new CustomEvent("chromecastloaded", {
- detail: {
- player: instance
- }
- })), events.on(instance._castPlayer, "connect", function(e) {
- currentResolve ? sendConnectionResult(!0) : playbackManager.setActivePlayer(PlayerName, instance.getCurrentTargetInfo()), console.log("cc: connect"), instance.lastPlayerData = null
- }), events.on(instance._castPlayer, "playbackstart", function(e, data) {
- console.log("cc: playbackstart"), instance._castPlayer.initializeCastPlayer();
- var state = instance.getPlayerStateInternal(data);
- events.trigger(instance, "playbackstart", [state])
- }), events.on(instance._castPlayer, "playbackstop", function(e, data) {
- console.log("cc: playbackstop");
- var state = instance.getPlayerStateInternal(data);
- events.trigger(instance, "playbackstop", [state]), instance.lastPlayerData = {}
- }), events.on(instance._castPlayer, "playbackprogress", function(e, data) {
- var state = instance.getPlayerStateInternal(data);
- events.trigger(instance, "timeupdate", [state])
- }), bindEventForRelay(instance, "timeupdate"), bindEventForRelay(instance, "pause"), bindEventForRelay(instance, "unpause"), bindEventForRelay(instance, "volumechange"), bindEventForRelay(instance, "repeatmodechange"), events.on(instance._castPlayer, "playstatechange", function(e, data) {
- var state = instance.getPlayerStateInternal(data);
- events.trigger(instance, "pause", [state])
- })
- }
-
- function ChromecastPlayer() {
- this.name = PlayerName, this.type = "mediaplayer", this.id = "chromecast", this.isLocalPlayer = !1, this.lastPlayerData = {}, castSenderApiLoader.load().then(initializeChromecast.bind(this))
- }
- var currentResolve, currentReject, PlayerName = "Chromecast",
- DEVICE_STATE = {
- IDLE: 0,
- ACTIVE: 1,
- WARNING: 2,
- ERROR: 3
- },
- PLAYER_STATE = {
- IDLE: "IDLE",
- LOADING: "LOADING",
- LOADED: "LOADED",
- PLAYING: "PLAYING",
- PAUSED: "PAUSED",
- STOPPED: "STOPPED",
- SEEKING: "SEEKING",
- ERROR: "ERROR"
- },
- CastPlayer = function() {
- this.deviceState = DEVICE_STATE.IDLE, this.currentMediaSession = null, this.session = null, this.castPlayerState = PLAYER_STATE.IDLE, this.hasReceivers = !1, this.errorHandler = this.onError.bind(this), this.mediaStatusUpdateHandler = this.onMediaStatusUpdate.bind(this), this.initializeCastPlayer()
- };
- return CastPlayer.prototype.initializeCastPlayer = function() {
- var chrome = window.chrome;
- if (chrome) {
- if (!chrome.cast || !chrome.cast.isAvailable) return void setTimeout(this.initializeCastPlayer.bind(this), 1e3);
- var sessionRequest = new chrome.cast.SessionRequest("2D4B1DA3"),
- apiConfig = new chrome.cast.ApiConfig(sessionRequest, this.sessionListener.bind(this), this.receiverListener.bind(this), "origin_scoped");
- console.log("chromecast.initialize"), chrome.cast.initialize(apiConfig, this.onInitSuccess.bind(this), this.errorHandler)
- }
- }, CastPlayer.prototype.onInitSuccess = function() {
- this.isInitialized = !0, console.log("chromecast init success")
- }, CastPlayer.prototype.onError = function() {
- console.log("chromecast error")
- }, CastPlayer.prototype.sessionListener = function(e) {
- this.session = e, this.session && (this.session.media[0] && this.onMediaDiscovered("activeSession", this.session.media[0]), this.onSessionConnected(e))
- }, CastPlayer.prototype.messageListener = function(namespace, message) {
- if ("string" == typeof message && (message = JSON.parse(message)), "playbackerror" === message.type) {
var errorCode = message.data;
- setTimeout(function() {
- alertText(globalize.translate("MessagePlaybackError" + errorCode), globalize.translate("HeaderPlaybackError"))
- }, 300)
- } else "connectionerror" === message.type ? setTimeout(function() {
- alertText(globalize.translate("MessageChromecastConnectionError"), globalize.translate("HeaderError"))
- }, 300) : message.type && events.trigger(this, message.type, [message.data])
- }, CastPlayer.prototype.receiverListener = function(e) {
- this.hasReceivers = "available" === e
- }, CastPlayer.prototype.sessionUpdateListener = function(isAlive) {
- isAlive || (this.session = null, this.deviceState = DEVICE_STATE.IDLE, this.castPlayerState = PLAYER_STATE.IDLE, this.currentMediaSession = null, sendConnectionResult(!1))
- }, CastPlayer.prototype.launchApp = function() {
- chrome.cast.requestSession(this.onRequestSessionSuccess.bind(this), this.onLaunchError.bind(this))
- }, CastPlayer.prototype.onRequestSessionSuccess = function(e) {
- this.onSessionConnected(e)
- }, CastPlayer.prototype.onSessionConnected = function(session) {
- this.session = session, this.deviceState = DEVICE_STATE.ACTIVE, this.session.addMessageListener("urn:x-cast:com.connectsdk", this.messageListener.bind(this)), this.session.addMediaListener(this.sessionMediaListener.bind(this)), this.session.addUpdateListener(this.sessionUpdateListener.bind(this)), events.trigger(this, "connect"), this.sendMessage({
+
+ setTimeout(function () {
+ alertText(globalize.translate('MessagePlaybackError' + errorCode), globalize.translate('HeaderPlaybackError'));
+ }, 300);
+
+ }
+ else if (message.type === 'connectionerror') {
+
+ setTimeout(function () {
+ alertText(globalize.translate('MessageChromecastConnectionError'), globalize.translate('HeaderError'));
+ }, 300);
+
+ }
+ else if (message.type) {
+ events.trigger(this, message.type, [message.data]);
+ }
+ };
+
+ /**
+ * @param {string} e Receiver availability
+ * This indicates availability of receivers but
+ * does not provide a list of device IDs
+ */
+ CastPlayer.prototype.receiverListener = function (e) {
+
+ if (e === 'available') {
+ //console.log("chromecast receiver found");
+ this.hasReceivers = true;
+ }
+ else {
+ //console.log("chromecast receiver list empty");
+ this.hasReceivers = false;
+ }
+ };
+
+ /**
+ * session update listener
+ */
+ CastPlayer.prototype.sessionUpdateListener = function (isAlive) {
+
+ //console.log('sessionUpdateListener alive: ' + isAlive);
+
+ if (isAlive) {
+ }
+ else {
+ this.session = null;
+ this.deviceState = DEVICE_STATE.IDLE;
+ this.castPlayerState = PLAYER_STATE.IDLE;
+
+ //console.log('sessionUpdateListener: setting currentMediaSession to null');
+ this.currentMediaSession = null;
+
+ sendConnectionResult(false);
+ }
+ };
+
+ /**
+ * Requests that a receiver application session be created or joined. By default, the SessionRequest
+ * passed to the API at initialization time is used; this may be overridden by passing a different
+ * session request in opt_sessionRequest.
+ */
+ CastPlayer.prototype.launchApp = function () {
+ //console.log("chromecast launching app...");
+ chrome.cast.requestSession(this.onRequestSessionSuccess.bind(this), this.onLaunchError.bind(this));
+ };
+
+ /**
+ * Callback function for request session success
+ * @param {Object} e A chrome.cast.Session object
+ */
+ CastPlayer.prototype.onRequestSessionSuccess = function (e) {
+
+ //console.log("chromecast session success: " + e.sessionId);
+ this.onSessionConnected(e);
+ };
+
+ CastPlayer.prototype.onSessionConnected = function (session) {
+
+ this.session = session;
+
+ this.deviceState = DEVICE_STATE.ACTIVE;
+
+ this.session.addMessageListener(messageNamespace, this.messageListener.bind(this));
+ this.session.addMediaListener(this.sessionMediaListener.bind(this));
+ this.session.addUpdateListener(this.sessionUpdateListener.bind(this));
+
+ events.trigger(this, 'connect');
+
+ this.sendMessage({
options: {},
- command: "Identify"
- })
- }, CastPlayer.prototype.sessionMediaListener = function(e) {
- this.currentMediaSession = e, this.currentMediaSession.addUpdateListener(this.mediaStatusUpdateHandler)
- }, CastPlayer.prototype.onLaunchError = function() {
- this.deviceState = DEVICE_STATE.ERROR, sendConnectionResult(!1)
- }, CastPlayer.prototype.stopApp = function() {
- this.session && this.session.stop(this.onStopAppSuccess.bind(this, "Session stopped"), this.errorHandler)
- }, CastPlayer.prototype.onStopAppSuccess = function(message) {
- this.deviceState = DEVICE_STATE.IDLE, this.castPlayerState = PLAYER_STATE.IDLE, this.currentMediaSession = null
- }, CastPlayer.prototype.loadMedia = function(options, command) {
- return this.session ? (options.items = options.items.map(function(i) {
+ command: 'Identify'
+ });
+ };
+
+ /**
+ * session update listener
+ */
+ CastPlayer.prototype.sessionMediaListener = function (e) {
+
+ //console.log('sessionMediaListener');
+ this.currentMediaSession = e;
+ this.currentMediaSession.addUpdateListener(this.mediaStatusUpdateHandler);
+ };
+
+ /**
+ * Callback function for launch error
+ */
+ CastPlayer.prototype.onLaunchError = function () {
+ //console.log("chromecast launch error");
+ this.deviceState = DEVICE_STATE.ERROR;
+
+ sendConnectionResult(false);
+ };
+
+ /**
+ * Stops the running receiver application associated with the session.
+ */
+ CastPlayer.prototype.stopApp = function () {
+
+ if (this.session) {
+ this.session.stop(this.onStopAppSuccess.bind(this, 'Session stopped'),
+ this.errorHandler);
+ }
+
+ };
+
+ /**
+ * Callback function for stop app success
+ */
+ CastPlayer.prototype.onStopAppSuccess = function (message) {
+ //console.log(message);
+ this.deviceState = DEVICE_STATE.IDLE;
+ this.castPlayerState = PLAYER_STATE.IDLE;
+
+ //console.log('onStopAppSuccess: setting currentMediaSession to null');
+ this.currentMediaSession = null;
+ };
+
+ /**
+ * Loads media into a running receiver application
+ * @param {Number} mediaIndex An index number to indicate current media content
+ */
+ CastPlayer.prototype.loadMedia = function (options, command) {
+
+ if (!this.session) {
+ //console.log("no session");
+ return Promise.reject();
+ }
+
+ // Convert the items to smaller stubs to send the minimal amount of information
+ options.items = options.items.map(function (i) {
+
return {
Id: i.Id,
ServerId: i.ServerId,
@@ -141,18 +331,37 @@ define(["appSettings", "userSettings", "playbackManager", "connectionManager", "
Type: i.Type,
MediaType: i.MediaType,
IsFolder: i.IsFolder
- }
- }), this.sendMessage({
+ };
+ });
+
+ return this.sendMessage({
options: options,
command: command
- })) : Promise.reject()
- }, CastPlayer.prototype.sendMessage = function(message) {
- var player = this,
- receiverName = null,
- session = player.session;
- session && session.receiver && session.receiver.friendlyName && (receiverName = session.receiver.friendlyName);
+ });
+ };
+
+ CastPlayer.prototype.sendMessage = function (message) {
+
+ var player = this;
+
+ var receiverName = null;
+
+ var session = player.session;
+
+ if (session && session.receiver && session.receiver.friendlyName) {
+ receiverName = session.receiver.friendlyName;
+ }
+
var apiClient;
- apiClient = message.options && message.options.ServerId ? connectionManager.getApiClient(message.options.ServerId) : message.options && message.options.items && message.options.items.length ? connectionManager.getApiClient(message.options.items[0].ServerId) : connectionManager.currentApiClient(), message = Object.assign(message, {
+ if (message.options && message.options.ServerId) {
+ apiClient = connectionManager.getApiClient(message.options.ServerId);
+ } else if (message.options && message.options.items && message.options.items.length) {
+ apiClient = connectionManager.getApiClient(message.options.items[0].ServerId);
+ } else {
+ apiClient = connectionManager.currentApiClient();
+ }
+
+ message = Object.assign(message, {
userId: apiClient.getCurrentUserId(),
deviceId: apiClient.deviceId(),
accessToken: apiClient.accessToken(),
@@ -161,265 +370,755 @@ define(["appSettings", "userSettings", "playbackManager", "connectionManager", "
serverVersion: apiClient.serverVersion(),
receiverName: receiverName
});
+
var bitrateSetting = appSettings.maxChromecastBitrate();
- return bitrateSetting && (message.maxBitrate = bitrateSetting), message.options && message.options.items && (message.subtitleAppearance = userSettings.getSubtitleAppearanceSettings(), message.subtitleBurnIn = appSettings.get("subtitleburnin") || ""), new Promise(function(resolve, reject) {
- require(["chromecastHelper"], function(chromecastHelper) {
- chromecastHelper.getServerAddress(apiClient).then(function(serverAddress) {
- message.serverAddress = serverAddress, player.sendMessageInternal(message).then(resolve, reject)
- }, reject)
- })
- })
- }, CastPlayer.prototype.sendMessageInternal = function(message) {
- return message = JSON.stringify(message), this.session.sendMessage("urn:x-cast:com.connectsdk", message, this.onPlayCommandSuccess.bind(this), this.errorHandler), Promise.resolve()
- }, CastPlayer.prototype.onPlayCommandSuccess = function() {}, CastPlayer.prototype.onMediaDiscovered = function(how, mediaSession) {
- this.currentMediaSession = mediaSession, "loadMedia" === how && (this.castPlayerState = PLAYER_STATE.PLAYING), "activeSession" === how && (this.castPlayerState = mediaSession.playerState), this.currentMediaSession.addUpdateListener(this.mediaStatusUpdateHandler)
- }, CastPlayer.prototype.onMediaStatusUpdate = function(e) {
- !1 === e && (this.castPlayerState = PLAYER_STATE.IDLE)
- }, CastPlayer.prototype.setReceiverVolume = function(mute, vol) {
- this.currentMediaSession && (mute ? this.session.setReceiverMuted(!0, this.mediaCommandSuccessCallback.bind(this), this.errorHandler) : this.session.setReceiverVolumeLevel(vol || 1, this.mediaCommandSuccessCallback.bind(this), this.errorHandler))
- }, CastPlayer.prototype.mute = function() {
- this.setReceiverVolume(!0)
- }, CastPlayer.prototype.mediaCommandSuccessCallback = function(info, e) {}, ChromecastPlayer.prototype.tryPair = function(target) {
+ if (bitrateSetting) {
+ message.maxBitrate = bitrateSetting;
+ }
+
+ if (message.options && message.options.items) {
+ message.subtitleAppearance = userSettings.getSubtitleAppearanceSettings();
+ message.subtitleBurnIn = appSettings.get('subtitleburnin') || '';
+ }
+
+ return new Promise(function (resolve, reject) {
+
+ require(['chromecastHelper'], function (chromecastHelper) {
+
+ chromecastHelper.getServerAddress(apiClient).then(function (serverAddress) {
+ message.serverAddress = serverAddress;
+ player.sendMessageInternal(message).then(resolve, reject);
+
+ }, reject);
+ });
+ });
+ };
+
+ CastPlayer.prototype.sendMessageInternal = function (message) {
+
+ message = JSON.stringify(message);
+ //console.log(message);
+
+ this.session.sendMessage(messageNamespace, message, this.onPlayCommandSuccess.bind(this), this.errorHandler);
+ return Promise.resolve();
+ };
+
+ CastPlayer.prototype.onPlayCommandSuccess = function () {
+ //console.log('Message was sent to receiver ok.');
+ };
+
+ /**
+ * Callback function for loadMedia success
+ * @param {Object} mediaSession A new media object.
+ */
+ CastPlayer.prototype.onMediaDiscovered = function (how, mediaSession) {
+
+ //console.log("chromecast new media session ID:" + mediaSession.mediaSessionId + ' (' + how + ')');
+ this.currentMediaSession = mediaSession;
+
+ if (how === 'loadMedia') {
+ this.castPlayerState = PLAYER_STATE.PLAYING;
+ }
+
+ if (how === 'activeSession') {
+ this.castPlayerState = mediaSession.playerState;
+ }
+
+ this.currentMediaSession.addUpdateListener(this.mediaStatusUpdateHandler);
+ };
+
+ /**
+ * Callback function for media status update from receiver
+ * @param {!Boolean} e true/false
+ */
+ CastPlayer.prototype.onMediaStatusUpdate = function (e) {
+
+ if (e === false) {
+ this.castPlayerState = PLAYER_STATE.IDLE;
+ }
+ //console.log("chromecast updating media: " + e);
+ };
+
+ /**
+ * Set media volume in Cast mode
+ * @param {Boolean} mute A boolean
+ */
+ CastPlayer.prototype.setReceiverVolume = function (mute, vol) {
+
+ if (!this.currentMediaSession) {
+ //console.log('this.currentMediaSession is null');
+ return;
+ }
+
+ if (!mute) {
+
+ this.session.setReceiverVolumeLevel((vol || 1),
+ this.mediaCommandSuccessCallback.bind(this),
+ this.errorHandler);
+ }
+ else {
+ this.session.setReceiverMuted(true,
+ this.mediaCommandSuccessCallback.bind(this),
+ this.errorHandler);
+ }
+ };
+
+ /**
+ * Mute CC
+ */
+ CastPlayer.prototype.mute = function () {
+ this.setReceiverVolume(true);
+ };
+
+ /**
+ * Callback function for media command success
+ */
+ CastPlayer.prototype.mediaCommandSuccessCallback = function (info, e) {
+ //console.log(info);
+ };
+
+ function normalizeImages(state) {
+
+ if (state && state.NowPlayingItem) {
+
+ var item = state.NowPlayingItem;
+
+ if (!item.ImageTags || !item.ImageTags.Primary) {
+ if (item.PrimaryImageTag) {
+ item.ImageTags = item.ImageTags || {};
+ item.ImageTags.Primary = item.PrimaryImageTag;
+ }
+ }
+ if (item.BackdropImageTag && item.BackdropItemId === item.Id) {
+ item.BackdropImageTags = [item.BackdropImageTag];
+ }
+ if (item.BackdropImageTag && item.BackdropItemId !== item.Id) {
+ item.ParentBackdropImageTags = [item.BackdropImageTag];
+ item.ParentBackdropItemId = item.BackdropItemId;
+ }
+ }
+ }
+
+ function getItemsForPlayback(apiClient, query) {
+
+ var userId = apiClient.getCurrentUserId();
+
+ if (query.Ids && query.Ids.split(',').length === 1) {
+ return apiClient.getItem(userId, query.Ids.split(',')).then(function (item) {
+ return {
+ Items: [item],
+ TotalRecordCount: 1
+ };
+ });
+ }
+ else {
+
+ query.Limit = query.Limit || 100;
+ query.ExcludeLocationTypes = "Virtual";
+ query.EnableTotalRecordCount = false;
+
+ return apiClient.getItems(userId, query);
+ }
+ }
+
+ function bindEventForRelay(instance, eventName) {
+
+ events.on(instance._castPlayer, eventName, function (e, data) {
+
+ //console.log('cc: ' + eventName);
+ var state = instance.getPlayerStateInternal(data);
+
+ events.trigger(instance, eventName, [state]);
+ });
+ }
+
+ function initializeChromecast() {
+
+ var instance = this;
+ instance._castPlayer = new CastPlayer();
+
+ // To allow the native android app to override
+ document.dispatchEvent(new CustomEvent("chromecastloaded", {
+ detail: {
+ player: instance
+ }
+ }));
+
+ events.on(instance._castPlayer, "connect", function (e) {
+
+ if (currentResolve) {
+ sendConnectionResult(true);
+ } else {
+ playbackManager.setActivePlayer(PlayerName, instance.getCurrentTargetInfo());
+ }
+
+ console.log('cc: connect');
+ // Reset this so that statechange will fire
+ instance.lastPlayerData = null;
+ });
+
+ events.on(instance._castPlayer, "playbackstart", function (e, data) {
+
+ console.log('cc: playbackstart');
+
+ instance._castPlayer.initializeCastPlayer();
+
+ var state = instance.getPlayerStateInternal(data);
+ events.trigger(instance, "playbackstart", [state]);
+ });
+
+ events.on(instance._castPlayer, "playbackstop", function (e, data) {
+
+ console.log('cc: playbackstop');
+ var state = instance.getPlayerStateInternal(data);
+
+ events.trigger(instance, "playbackstop", [state]);
+
+ // Reset this so the next query doesn't make it appear like content is playing.
+ instance.lastPlayerData = {};
+ });
+
+ events.on(instance._castPlayer, "playbackprogress", function (e, data) {
+
+ //console.log('cc: positionchange');
+ var state = instance.getPlayerStateInternal(data);
+
+ events.trigger(instance, "timeupdate", [state]);
+ });
+
+ bindEventForRelay(instance, 'timeupdate');
+ bindEventForRelay(instance, 'pause');
+ bindEventForRelay(instance, 'unpause');
+ bindEventForRelay(instance, 'volumechange');
+ bindEventForRelay(instance, 'repeatmodechange');
+
+ events.on(instance._castPlayer, "playstatechange", function (e, data) {
+
+ //console.log('cc: playstatechange');
+ var state = instance.getPlayerStateInternal(data);
+
+ events.trigger(instance, "pause", [state]);
+ });
+ }
+
+ function ChromecastPlayer() {
+
+ // playbackManager needs this
+ this.name = PlayerName;
+ this.type = 'mediaplayer';
+ this.id = 'chromecast';
+ this.isLocalPlayer = false;
+ this.lastPlayerData = {};
+
+ castSenderApiLoader.load().then(initializeChromecast.bind(this));
+ }
+
+ ChromecastPlayer.prototype.tryPair = function (target) {
+
var castPlayer = this._castPlayer;
- return castPlayer.deviceState !== DEVICE_STATE.ACTIVE && castPlayer.isInitialized ? new Promise(function(resolve, reject) {
- currentResolve = resolve, currentReject = reject, castPlayer.launchApp()
- }) : (currentResolve = null, currentReject = null, Promise.reject())
- }, ChromecastPlayer.prototype.getTargets = function() {
+
+ if (castPlayer.deviceState !== DEVICE_STATE.ACTIVE && castPlayer.isInitialized) {
+
+ return new Promise(function (resolve, reject) {
+ currentResolve = resolve;
+ currentReject = reject;
+
+ castPlayer.launchApp();
+ });
+ } else {
+
+ currentResolve = null;
+ currentReject = null;
+
+ return Promise.reject();
+ }
+ };
+
+ ChromecastPlayer.prototype.getTargets = function () {
+
var targets = [];
- return this._castPlayer && this._castPlayer.hasReceivers && targets.push(this.getCurrentTargetInfo()), Promise.resolve(targets)
- }, ChromecastPlayer.prototype.getCurrentTargetInfo = function() {
- var appName = null,
- castPlayer = this._castPlayer;
- return castPlayer.session && castPlayer.session.receiver && castPlayer.session.receiver.friendlyName && (appName = castPlayer.session.receiver.friendlyName), {
+
+ if (this._castPlayer && this._castPlayer.hasReceivers) {
+ targets.push(this.getCurrentTargetInfo());
+ }
+
+ return Promise.resolve(targets);
+ };
+
+ // This is a privately used method
+ ChromecastPlayer.prototype.getCurrentTargetInfo = function () {
+
+ var appName = null;
+
+ var castPlayer = this._castPlayer;
+
+ if (castPlayer.session && castPlayer.session.receiver && castPlayer.session.receiver.friendlyName) {
+ appName = castPlayer.session.receiver.friendlyName;
+ }
+
+ return {
name: PlayerName,
id: PlayerName,
playerName: PlayerName,
playableMediaTypes: ["Audio", "Video"],
- isLocalPlayer: !1,
+ isLocalPlayer: false,
appName: PlayerName,
deviceName: appName,
- supportedCommands: ["VolumeUp", "VolumeDown", "Mute", "Unmute", "ToggleMute", "SetVolume", "SetAudioStreamIndex", "SetSubtitleStreamIndex", "DisplayContent", "SetRepeatMode", "EndSession", "PlayMediaSource", "PlayTrailers"]
+ supportedCommands: [
+ "VolumeUp",
+ "VolumeDown",
+ "Mute",
+ "Unmute",
+ "ToggleMute",
+ "SetVolume",
+ "SetAudioStreamIndex",
+ "SetSubtitleStreamIndex",
+ "DisplayContent",
+ "SetRepeatMode",
+ "EndSession",
+ "PlayMediaSource",
+ "PlayTrailers"
+ ]
+ };
+ };
+
+ ChromecastPlayer.prototype.getPlayerStateInternal = function (data) {
+
+ var triggerStateChange = false;
+ if (data && !this.lastPlayerData) {
+ triggerStateChange = true;
}
- }, ChromecastPlayer.prototype.getPlayerStateInternal = function(data) {
- var triggerStateChange = !1;
- return data && !this.lastPlayerData && (triggerStateChange = !0), data = data || this.lastPlayerData, this.lastPlayerData = data, normalizeImages(data), triggerStateChange && events.trigger(this, "statechange", [data]), data
- }, ChromecastPlayer.prototype.playWithCommand = function(options, command) {
+
+ data = data || this.lastPlayerData;
+ this.lastPlayerData = data;
+
+ normalizeImages(data);
+
+ //console.log(JSON.stringify(data));
+
+ if (triggerStateChange) {
+ events.trigger(this, "statechange", [data]);
+ }
+
+ return data;
+ };
+
+ ChromecastPlayer.prototype.playWithCommand = function (options, command) {
+
if (!options.items) {
- var apiClient = connectionManager.getApiClient(options.serverId),
- instance = this;
- return apiClient.getItem(apiClient.getCurrentUserId(), options.ids[0]).then(function(item) {
- return options.items = [item], instance.playWithCommand(options, command)
- })
+ var apiClient = connectionManager.getApiClient(options.serverId);
+ var instance = this;
+
+ return apiClient.getItem(apiClient.getCurrentUserId(), options.ids[0]).then(function (item) {
+
+ options.items = [item];
+ return instance.playWithCommand(options, command);
+ });
}
- return this._castPlayer.loadMedia(options, command)
- }, ChromecastPlayer.prototype.seek = function(position) {
- position = parseInt(position), position /= 1e7, this._castPlayer.sendMessage({
+
+ return this._castPlayer.loadMedia(options, command);
+ };
+
+ ChromecastPlayer.prototype.seek = function (position) {
+
+ position = parseInt(position);
+
+ position = position / 10000000;
+
+ this._castPlayer.sendMessage({
options: {
position: position
},
- command: "Seek"
- })
- }, ChromecastPlayer.prototype.setAudioStreamIndex = function(index) {
+ command: 'Seek'
+ });
+ };
+
+ ChromecastPlayer.prototype.setAudioStreamIndex = function (index) {
this._castPlayer.sendMessage({
options: {
index: index
},
- command: "SetAudioStreamIndex"
- })
- }, ChromecastPlayer.prototype.setSubtitleStreamIndex = function(index) {
+ command: 'SetAudioStreamIndex'
+ });
+ };
+
+ ChromecastPlayer.prototype.setSubtitleStreamIndex = function (index) {
this._castPlayer.sendMessage({
options: {
index: index
},
- command: "SetSubtitleStreamIndex"
- })
- }, ChromecastPlayer.prototype.setMaxStreamingBitrate = function(options) {
+ command: 'SetSubtitleStreamIndex'
+ });
+ };
+
+ ChromecastPlayer.prototype.setMaxStreamingBitrate = function (options) {
+
this._castPlayer.sendMessage({
options: options,
- command: "SetMaxStreamingBitrate"
- })
- }, ChromecastPlayer.prototype.isFullscreen = function() {
+ command: 'SetMaxStreamingBitrate'
+ });
+ };
+
+ ChromecastPlayer.prototype.isFullscreen = function () {
var state = this.lastPlayerData || {};
- return state = state.PlayState || {}, state.IsFullscreen
- }, ChromecastPlayer.prototype.nextTrack = function() {
+ state = state.PlayState || {};
+ return state.IsFullscreen;
+ };
+
+ ChromecastPlayer.prototype.nextTrack = function () {
this._castPlayer.sendMessage({
options: {},
- command: "NextTrack"
- })
- }, ChromecastPlayer.prototype.previousTrack = function() {
+ command: 'NextTrack'
+ });
+ };
+
+ ChromecastPlayer.prototype.previousTrack = function () {
this._castPlayer.sendMessage({
options: {},
- command: "PreviousTrack"
- })
- }, ChromecastPlayer.prototype.volumeDown = function() {
+ command: 'PreviousTrack'
+ });
+ };
+
+ ChromecastPlayer.prototype.volumeDown = function () {
+
this._castPlayer.sendMessage({
options: {},
- command: "VolumeDown"
- })
- }, ChromecastPlayer.prototype.endSession = function() {
+ command: 'VolumeDown'
+ });
+ };
+
+ ChromecastPlayer.prototype.endSession = function () {
+
var instance = this;
- this.stop().then(function() {
- setTimeout(function() {
- instance._castPlayer.stopApp()
- }, 1e3)
- })
- }, ChromecastPlayer.prototype.volumeUp = function() {
+
+ this.stop().then(function () {
+ setTimeout(function () {
+ instance._castPlayer.stopApp();
+ }, 1000);
+ });
+ };
+
+ ChromecastPlayer.prototype.volumeUp = function () {
+
this._castPlayer.sendMessage({
options: {},
- command: "VolumeUp"
- })
- }, ChromecastPlayer.prototype.setVolume = function(vol) {
- vol = Math.min(vol, 100), vol = Math.max(vol, 0), this._castPlayer.sendMessage({
+ command: 'VolumeUp'
+ });
+ };
+
+ ChromecastPlayer.prototype.setVolume = function (vol) {
+
+ vol = Math.min(vol, 100);
+ vol = Math.max(vol, 0);
+
+ this._castPlayer.sendMessage({
options: {
volume: vol
},
- command: "SetVolume"
- })
- }, ChromecastPlayer.prototype.unpause = function() {
+ command: 'SetVolume'
+ });
+ };
+
+ ChromecastPlayer.prototype.unpause = function () {
this._castPlayer.sendMessage({
options: {},
- command: "Unpause"
- })
- }, ChromecastPlayer.prototype.playPause = function() {
+ command: 'Unpause'
+ });
+ };
+
+ ChromecastPlayer.prototype.playPause = function () {
this._castPlayer.sendMessage({
options: {},
- command: "PlayPause"
- })
- }, ChromecastPlayer.prototype.pause = function() {
+ command: 'PlayPause'
+ });
+ };
+
+ ChromecastPlayer.prototype.pause = function () {
this._castPlayer.sendMessage({
options: {},
- command: "Pause"
- })
- }, ChromecastPlayer.prototype.stop = function() {
+ command: 'Pause'
+ });
+ };
+
+ ChromecastPlayer.prototype.stop = function () {
return this._castPlayer.sendMessage({
options: {},
- command: "Stop"
- })
- }, ChromecastPlayer.prototype.displayContent = function(options) {
+ command: 'Stop'
+ });
+ };
+
+ ChromecastPlayer.prototype.displayContent = function (options) {
+
this._castPlayer.sendMessage({
options: options,
- command: "DisplayContent"
- })
- }, ChromecastPlayer.prototype.setMute = function(isMuted) {
+ command: 'DisplayContent'
+ });
+ };
+
+ ChromecastPlayer.prototype.setMute = function (isMuted) {
+
var castPlayer = this._castPlayer;
- isMuted ? castPlayer.sendMessage({
- options: {},
- command: "Mute"
- }) : castPlayer.sendMessage({
- options: {},
- command: "Unmute"
- })
- }, ChromecastPlayer.prototype.getRepeatMode = function() {
+
+ if (isMuted) {
+ castPlayer.sendMessage({
+ options: {},
+ command: 'Mute'
+ });
+ } else {
+ castPlayer.sendMessage({
+ options: {},
+ command: 'Unmute'
+ });
+ }
+ };
+
+ ChromecastPlayer.prototype.getRepeatMode = function () {
var state = this.lastPlayerData || {};
- return state = state.PlayState || {}, state.RepeatMode
- }, ChromecastPlayer.prototype.playTrailers = function(item) {
+ state = state.PlayState || {};
+ return state.RepeatMode;
+ };
+
+ ChromecastPlayer.prototype.playTrailers = function (item) {
+
this._castPlayer.sendMessage({
options: {
ItemId: item.Id,
ServerId: item.ServerId
},
- command: "PlayTrailers"
- })
- }, ChromecastPlayer.prototype.setRepeatMode = function(mode) {
+ command: 'PlayTrailers'
+ });
+ };
+
+ ChromecastPlayer.prototype.setRepeatMode = function (mode) {
this._castPlayer.sendMessage({
options: {
RepeatMode: mode
},
- command: "SetRepeatMode"
- })
- }, ChromecastPlayer.prototype.toggleMute = function() {
+ command: 'SetRepeatMode'
+ });
+ };
+
+ ChromecastPlayer.prototype.toggleMute = function () {
+
this._castPlayer.sendMessage({
options: {},
- command: "ToggleMute"
- })
- }, ChromecastPlayer.prototype.audioTracks = function() {
+ command: 'ToggleMute'
+ });
+ };
+
+ ChromecastPlayer.prototype.audioTracks = function () {
var state = this.lastPlayerData || {};
- return state = state.NowPlayingItem || {}, (state.MediaStreams || []).filter(function(s) {
- return "Audio" === s.Type
- })
- }, ChromecastPlayer.prototype.getAudioStreamIndex = function() {
+ state = state.NowPlayingItem || {};
+ var streams = state.MediaStreams || [];
+ return streams.filter(function (s) {
+ return s.Type === 'Audio';
+ });
+ };
+
+ ChromecastPlayer.prototype.getAudioStreamIndex = function () {
var state = this.lastPlayerData || {};
- return state = state.PlayState || {}, state.AudioStreamIndex
- }, ChromecastPlayer.prototype.subtitleTracks = function() {
+ state = state.PlayState || {};
+ return state.AudioStreamIndex;
+ };
+
+ ChromecastPlayer.prototype.subtitleTracks = function () {
var state = this.lastPlayerData || {};
- return state = state.NowPlayingItem || {}, (state.MediaStreams || []).filter(function(s) {
- return "Subtitle" === s.Type
- })
- }, ChromecastPlayer.prototype.getSubtitleStreamIndex = function() {
+ state = state.NowPlayingItem || {};
+ var streams = state.MediaStreams || [];
+ return streams.filter(function (s) {
+ return s.Type === 'Subtitle';
+ });
+ };
+
+ ChromecastPlayer.prototype.getSubtitleStreamIndex = function () {
var state = this.lastPlayerData || {};
- return state = state.PlayState || {}, state.SubtitleStreamIndex
- }, ChromecastPlayer.prototype.getMaxStreamingBitrate = function() {
+ state = state.PlayState || {};
+ return state.SubtitleStreamIndex;
+ };
+
+ ChromecastPlayer.prototype.getMaxStreamingBitrate = function () {
var state = this.lastPlayerData || {};
- return state = state.PlayState || {}, state.MaxStreamingBitrate
- }, ChromecastPlayer.prototype.getVolume = function() {
+ state = state.PlayState || {};
+ return state.MaxStreamingBitrate;
+ };
+
+ ChromecastPlayer.prototype.getVolume = function () {
+
var state = this.lastPlayerData || {};
- return state = state.PlayState || {}, null == state.VolumeLevel ? 100 : state.VolumeLevel
- }, ChromecastPlayer.prototype.isPlaying = function() {
- return null != (this.lastPlayerData || {}).NowPlayingItem
- }, ChromecastPlayer.prototype.isPlayingVideo = function() {
+ state = state.PlayState || {};
+
+ return state.VolumeLevel == null ? 100 : state.VolumeLevel;
+ };
+
+ ChromecastPlayer.prototype.isPlaying = function () {
var state = this.lastPlayerData || {};
- return state = state.NowPlayingItem || {}, "Video" === state.MediaType
- }, ChromecastPlayer.prototype.isPlayingAudio = function() {
+ return state.NowPlayingItem != null;
+ };
+
+ ChromecastPlayer.prototype.isPlayingVideo = function () {
var state = this.lastPlayerData || {};
- return state = state.NowPlayingItem || {}, "Audio" === state.MediaType
- }, ChromecastPlayer.prototype.currentTime = function(val) {
- if (null != val) return this.seek(val);
+ state = state.NowPlayingItem || {};
+ return state.MediaType === 'Video';
+ };
+
+ ChromecastPlayer.prototype.isPlayingAudio = function () {
var state = this.lastPlayerData || {};
- return state = state.PlayState || {}, state.PositionTicks
- }, ChromecastPlayer.prototype.duration = function() {
+ state = state.NowPlayingItem || {};
+ return state.MediaType === 'Audio';
+ };
+
+ ChromecastPlayer.prototype.currentTime = function (val) {
+
+ if (val != null) {
+ return this.seek(val);
+ }
+
var state = this.lastPlayerData || {};
- return state = state.NowPlayingItem || {}, state.RunTimeTicks
- }, ChromecastPlayer.prototype.getBufferedRanges = function() {
+ state = state.PlayState || {};
+ return state.PositionTicks;
+ };
+
+ ChromecastPlayer.prototype.duration = function () {
var state = this.lastPlayerData || {};
- return state = state.PlayState || {}, state.BufferedRanges || []
- }, ChromecastPlayer.prototype.paused = function() {
+ state = state.NowPlayingItem || {};
+ return state.RunTimeTicks;
+ };
+
+ ChromecastPlayer.prototype.getBufferedRanges = function () {
var state = this.lastPlayerData || {};
- return state = state.PlayState || {}, state.IsPaused
- }, ChromecastPlayer.prototype.isMuted = function() {
+ state = state.PlayState || {};
+ return state.BufferedRanges || [];
+ };
+
+ ChromecastPlayer.prototype.paused = function () {
var state = this.lastPlayerData || {};
- return state = state.PlayState || {}, state.IsMuted
- }, ChromecastPlayer.prototype.shuffle = function(item) {
- var apiClient = connectionManager.getApiClient(item.ServerId),
- userId = apiClient.getCurrentUserId(),
- instance = this;
- apiClient.getItem(userId, item.Id).then(function(item) {
- instance.playWithCommand({
- items: [item]
- }, "Shuffle")
- })
- }, ChromecastPlayer.prototype.instantMix = function(item) {
- var apiClient = connectionManager.getApiClient(item.ServerId),
- userId = apiClient.getCurrentUserId(),
- instance = this;
- apiClient.getItem(userId, item.Id).then(function(item) {
- instance.playWithCommand({
- items: [item]
- }, "InstantMix")
- })
- }, ChromecastPlayer.prototype.canPlayMediaType = function(mediaType) {
- return "audio" === (mediaType = (mediaType || "").toLowerCase()) || "video" === mediaType
- }, ChromecastPlayer.prototype.canQueueMediaType = function(mediaType) {
- return this.canPlayMediaType(mediaType)
- }, ChromecastPlayer.prototype.queue = function(options) {
- this.playWithCommand(options, "PlayLast")
- }, ChromecastPlayer.prototype.queueNext = function(options) {
- this.playWithCommand(options, "PlayNext")
- }, ChromecastPlayer.prototype.play = function(options) {
- if (options.items) return this.playWithCommand(options, "PlayNow");
- if (!options.serverId) throw new Error("serverId required!");
+ state = state.PlayState || {};
+
+ return state.IsPaused;
+ };
+
+ ChromecastPlayer.prototype.isMuted = function () {
+ var state = this.lastPlayerData || {};
+ state = state.PlayState || {};
+
+ return state.IsMuted;
+ };
+
+ ChromecastPlayer.prototype.shuffle = function (item) {
+
+ var apiClient = connectionManager.getApiClient(item.ServerId);
+ var userId = apiClient.getCurrentUserId();
+
var instance = this;
- return getItemsForPlayback(connectionManager.getApiClient(options.serverId), {
- Ids: options.ids.join(",")
- }).then(function(result) {
- return options.items = result.Items, instance.playWithCommand(options, "PlayNow")
- })
- }, ChromecastPlayer.prototype.toggleFullscreen = function() {}, ChromecastPlayer.prototype.beginPlayerUpdates = function() {}, ChromecastPlayer.prototype.endPlayerUpdates = function() {}, ChromecastPlayer.prototype.getPlaylist = function() {
- return Promise.resolve([])
- }, ChromecastPlayer.prototype.getCurrentPlaylistItemId = function() {}, ChromecastPlayer.prototype.setCurrentPlaylistItem = function(playlistItemId) {
- return Promise.resolve()
- }, ChromecastPlayer.prototype.removeFromPlaylist = function(playlistItemIds) {
- return Promise.resolve()
- }, ChromecastPlayer.prototype.getPlayerState = function() {
- return this.getPlayerStateInternal() || {}
- }, ChromecastPlayer
-});
\ No newline at end of file
+
+ apiClient.getItem(userId, item.Id).then(function (item) {
+
+ instance.playWithCommand({
+
+ items: [item]
+
+ }, 'Shuffle');
+
+ });
+
+ };
+
+ ChromecastPlayer.prototype.instantMix = function (item) {
+
+ var apiClient = connectionManager.getApiClient(item.ServerId);
+ var userId = apiClient.getCurrentUserId();
+
+ var instance = this;
+
+ apiClient.getItem(userId, item.Id).then(function (item) {
+
+ instance.playWithCommand({
+
+ items: [item]
+
+ }, 'InstantMix');
+
+ });
+
+ };
+
+ ChromecastPlayer.prototype.canPlayMediaType = function (mediaType) {
+
+ mediaType = (mediaType || '').toLowerCase();
+ return mediaType === 'audio' || mediaType === 'video';
+ };
+
+ ChromecastPlayer.prototype.canQueueMediaType = function (mediaType) {
+ return this.canPlayMediaType(mediaType);
+ };
+
+ ChromecastPlayer.prototype.queue = function (options) {
+ this.playWithCommand(options, 'PlayLast');
+ };
+
+ ChromecastPlayer.prototype.queueNext = function (options) {
+ this.playWithCommand(options, 'PlayNext');
+ };
+
+ ChromecastPlayer.prototype.play = function (options) {
+
+ if (options.items) {
+
+ return this.playWithCommand(options, 'PlayNow');
+
+ } else {
+
+ if (!options.serverId) {
+ throw new Error('serverId required!');
+ }
+
+ var instance = this;
+ var apiClient = connectionManager.getApiClient(options.serverId);
+
+ return getItemsForPlayback(apiClient, {
+
+ Ids: options.ids.join(',')
+
+ }).then(function (result) {
+
+ options.items = result.Items;
+ return instance.playWithCommand(options, 'PlayNow');
+
+ });
+ }
+ };
+
+ ChromecastPlayer.prototype.toggleFullscreen = function () {
+ // not supported
+ };
+
+ ChromecastPlayer.prototype.beginPlayerUpdates = function () {
+ // Setup polling here
+ };
+
+ ChromecastPlayer.prototype.endPlayerUpdates = function () {
+ // Stop polling here
+ };
+
+ ChromecastPlayer.prototype.getPlaylist = function () {
+ return Promise.resolve([]);
+ };
+
+ ChromecastPlayer.prototype.getCurrentPlaylistItemId = function () {
+ };
+
+ ChromecastPlayer.prototype.setCurrentPlaylistItem = function (playlistItemId) {
+ return Promise.resolve();
+ };
+
+ ChromecastPlayer.prototype.removeFromPlaylist = function (playlistItemIds) {
+ return Promise.resolve();
+ };
+
+ ChromecastPlayer.prototype.getPlayerState = function () {
+
+ return this.getPlayerStateInternal() || {};
+ };
+
+ return ChromecastPlayer;
+});
diff --git a/src/bower_components/emby-webcomponents/clearbutton.css b/src/bower_components/emby-webcomponents/clearbutton.css
index e41da78a3e..2d3f8d6800 100644
--- a/src/bower_components/emby-webcomponents/clearbutton.css
+++ b/src/bower_components/emby-webcomponents/clearbutton.css
@@ -1,12 +1,12 @@
.clearButton {
- background: 0 0;
+ background: transparent;
border: 0 !important;
padding: 0 !important;
cursor: pointer;
- outline: 0 !important;
+ outline: none !important;
color: inherit;
width: 100%;
vertical-align: middle;
font-family: inherit;
- font-size: inherit
+ font-size: inherit;
}
\ No newline at end of file
diff --git a/src/bower_components/emby-webcomponents/collectioneditor/collectioneditor.js b/src/bower_components/emby-webcomponents/collectioneditor/collectioneditor.js
index d1aeec3c8e..8e526fa114 100644
--- a/src/bower_components/emby-webcomponents/collectioneditor/collectioneditor.js
+++ b/src/bower_components/emby-webcomponents/collectioneditor/collectioneditor.js
@@ -1,119 +1,287 @@
-define(["dialogHelper", "loading", "apphost", "layoutManager", "connectionManager", "appRouter", "globalize", "emby-checkbox", "emby-input", "paper-icon-button-light", "emby-select", "material-icons", "css!./../formdialog", "emby-button", "emby-linkbutton", "flexStyles"], function(dialogHelper, loading, appHost, layoutManager, connectionManager, appRouter, globalize) {
- "use strict";
+define(['dialogHelper', 'loading', 'apphost', 'layoutManager', 'connectionManager', 'appRouter', 'globalize', 'emby-checkbox', 'emby-input', 'paper-icon-button-light', 'emby-select', 'material-icons', 'css!./../formdialog', 'emby-button', 'emby-linkbutton', 'flexStyles'], function (dialogHelper, loading, appHost, layoutManager, connectionManager, appRouter, globalize) {
+ 'use strict';
+
+ var currentServerId;
function parentWithClass(elem, className) {
- for (; !elem.classList || !elem.classList.contains(className);)
- if (!(elem = elem.parentNode)) return null;
- return elem
+
+ while (!elem.classList || !elem.classList.contains(className)) {
+ elem = elem.parentNode;
+
+ if (!elem) {
+ return null;
+ }
+ }
+
+ return elem;
}
function onSubmit(e) {
loading.show();
- var panel = parentWithClass(this, "dialog"),
- collectionId = panel.querySelector("#selectCollectionToAddTo").value,
- apiClient = connectionManager.getApiClient(currentServerId);
- return collectionId ? addToCollection(apiClient, panel, collectionId) : createCollection(apiClient, panel), e.preventDefault(), !1
+
+ var panel = parentWithClass(this, 'dialog');
+
+ var collectionId = panel.querySelector('#selectCollectionToAddTo').value;
+
+ var apiClient = connectionManager.getApiClient(currentServerId);
+
+ if (collectionId) {
+ addToCollection(apiClient, panel, collectionId);
+ } else {
+ createCollection(apiClient, panel);
+ }
+
+ e.preventDefault();
+ return false;
}
function createCollection(apiClient, dlg) {
+
var url = apiClient.getUrl("Collections", {
- Name: dlg.querySelector("#txtNewCollectionName").value,
- IsLocked: !dlg.querySelector("#chkEnableInternetMetadata").checked,
- Ids: dlg.querySelector(".fldSelectedItemIds").value || ""
+
+ Name: dlg.querySelector('#txtNewCollectionName').value,
+ IsLocked: !dlg.querySelector('#chkEnableInternetMetadata').checked,
+ Ids: dlg.querySelector('.fldSelectedItemIds').value || ''
});
+
apiClient.ajax({
type: "POST",
url: url,
dataType: "json"
- }).then(function(result) {
+
+ }).then(function (result) {
+
loading.hide();
+
var id = result.Id;
- dlg.submitted = !0, dialogHelper.close(dlg), redirectToCollection(apiClient, id)
- })
+
+ dlg.submitted = true;
+ dialogHelper.close(dlg);
+ redirectToCollection(apiClient, id);
+
+ });
}
function redirectToCollection(apiClient, id) {
- appRouter.showItem(id, apiClient.serverId())
+
+ appRouter.showItem(id, apiClient.serverId());
}
function addToCollection(apiClient, dlg, id) {
+
var url = apiClient.getUrl("Collections/" + id + "/Items", {
- Ids: dlg.querySelector(".fldSelectedItemIds").value || ""
+
+ Ids: dlg.querySelector('.fldSelectedItemIds').value || ''
});
+
apiClient.ajax({
type: "POST",
url: url
- }).then(function() {
- loading.hide(), dlg.submitted = !0, dialogHelper.close(dlg), require(["toast"], function(toast) {
- toast(globalize.translate("sharedcomponents#MessageItemsAdded"))
- })
- })
+
+ }).then(function () {
+
+ loading.hide();
+
+ dlg.submitted = true;
+ dialogHelper.close(dlg);
+
+ require(['toast'], function (toast) {
+ toast(globalize.translate('sharedcomponents#MessageItemsAdded'));
+ });
+ });
}
function triggerChange(select) {
- select.dispatchEvent(new CustomEvent("change", {}))
+ select.dispatchEvent(new CustomEvent('change', {}));
}
function populateCollections(panel) {
+
loading.show();
- var select = panel.querySelector("#selectCollectionToAddTo");
- panel.querySelector(".newCollectionInfo").classList.add("hide");
+
+ var select = panel.querySelector('#selectCollectionToAddTo');
+
+ panel.querySelector('.newCollectionInfo').classList.add('hide');
+
var options = {
- Recursive: !0,
- IncludeItemTypes: "BoxSet",
- SortBy: "SortName",
- EnableTotalRecordCount: !1
- },
- apiClient = connectionManager.getApiClient(currentServerId);
- apiClient.getItems(apiClient.getCurrentUserId(), options).then(function(result) {
- var html = "";
- html += '
' + globalize.translate("sharedcomponents#OptionNew") + " ", html += result.Items.map(function(i) {
- return '
' + i.Name + " "
- }), select.innerHTML = html, select.value = "", triggerChange(select), loading.hide()
- })
+
+ Recursive: true,
+ IncludeItemTypes: "BoxSet",
+ SortBy: "SortName",
+ EnableTotalRecordCount: false
+ };
+
+ var apiClient = connectionManager.getApiClient(currentServerId);
+ apiClient.getItems(apiClient.getCurrentUserId(), options).then(function (result) {
+
+ var html = '';
+
+ html += '
' + globalize.translate('sharedcomponents#OptionNew') + ' ';
+
+ html += result.Items.map(function (i) {
+
+ return '
' + i.Name + ' ';
+ });
+
+ select.innerHTML = html;
+ select.value = '';
+ triggerChange(select);
+
+ loading.hide();
+ });
}
function getEditorHtml() {
- var html = "";
- return html += '
"
+
+ var html = '';
+
+ html += '
';
+ html += '
';
+ html += '
';
+ html += '
';
+ html += '
';
+
+ return html;
}
function initEditor(content, items) {
- if (content.querySelector("#selectCollectionToAddTo").addEventListener("change", function() {
- this.value ? (content.querySelector(".newCollectionInfo").classList.add("hide"), content.querySelector("#txtNewCollectionName").removeAttribute("required")) : (content.querySelector(".newCollectionInfo").classList.remove("hide"), content.querySelector("#txtNewCollectionName").setAttribute("required", "required"))
- }), content.querySelector("form").addEventListener("submit", onSubmit), content.querySelector(".fldSelectedItemIds", content).value = items.join(","), items.length) content.querySelector(".fldSelectCollection").classList.remove("hide"), populateCollections(content);
- else {
- content.querySelector(".fldSelectCollection").classList.add("hide");
- var selectCollectionToAddTo = content.querySelector("#selectCollectionToAddTo");
- selectCollectionToAddTo.innerHTML = "", selectCollectionToAddTo.value = "", triggerChange(selectCollectionToAddTo)
+
+ content.querySelector('#selectCollectionToAddTo').addEventListener('change', function () {
+ if (this.value) {
+ content.querySelector('.newCollectionInfo').classList.add('hide');
+ content.querySelector('#txtNewCollectionName').removeAttribute('required');
+ } else {
+ content.querySelector('.newCollectionInfo').classList.remove('hide');
+ content.querySelector('#txtNewCollectionName').setAttribute('required', 'required');
+ }
+ });
+
+ content.querySelector('form').addEventListener('submit', onSubmit);
+
+ content.querySelector('.fldSelectedItemIds', content).value = items.join(',');
+
+ if (items.length) {
+ content.querySelector('.fldSelectCollection').classList.remove('hide');
+ populateCollections(content);
+ } else {
+ content.querySelector('.fldSelectCollection').classList.add('hide');
+
+ var selectCollectionToAddTo = content.querySelector('#selectCollectionToAddTo');
+ selectCollectionToAddTo.innerHTML = '';
+ selectCollectionToAddTo.value = '';
+ triggerChange(selectCollectionToAddTo);
}
}
function centerFocus(elem, horiz, on) {
- require(["scrollHelper"], function(scrollHelper) {
- var fn = on ? "on" : "off";
- scrollHelper.centerFocus[fn](elem, horiz)
- })
+ require(['scrollHelper'], function (scrollHelper) {
+ var fn = on ? 'on' : 'off';
+ scrollHelper.centerFocus[fn](elem, horiz);
+ });
}
- function CollectionEditor() {}
- var currentServerId;
- return CollectionEditor.prototype.show = function(options) {
+ function CollectionEditor() {
+
+ }
+
+ CollectionEditor.prototype.show = function (options) {
+
var items = options.items || {};
currentServerId = options.serverId;
+
var dialogOptions = {
- removeOnClose: !0,
- scrollY: !1
+ removeOnClose: true,
+ scrollY: false
};
- layoutManager.tv ? dialogOptions.size = "fullscreen" : dialogOptions.size = "small";
+
+ if (layoutManager.tv) {
+ dialogOptions.size = 'fullscreen';
+ } else {
+ dialogOptions.size = 'small';
+ }
+
var dlg = dialogHelper.createDialog(dialogOptions);
- dlg.classList.add("formDialog");
- var html = "",
- title = items.length ? globalize.translate("sharedcomponents#HeaderAddToCollection") : globalize.translate("sharedcomponents#NewCollection");
- return html += '", html += getEditorHtml(), dlg.innerHTML = html, initEditor(dlg, items), dlg.querySelector(".btnCancel").addEventListener("click", function() {
- dialogHelper.close(dlg)
- }), layoutManager.tv && centerFocus(dlg.querySelector(".formDialogContent"), !1, !0), dialogHelper.open(dlg).then(function() {
- return layoutManager.tv && centerFocus(dlg.querySelector(".formDialogContent"), !1, !1), dlg.submitted ? Promise.resolve() : Promise.reject()
- })
- }, CollectionEditor
+
+ dlg.classList.add('formDialog');
+
+ var html = '';
+ var title = items.length ? globalize.translate('sharedcomponents#HeaderAddToCollection') : globalize.translate('sharedcomponents#NewCollection');
+
+ html += '';
+
+ html += getEditorHtml();
+
+ dlg.innerHTML = html;
+
+ initEditor(dlg, items);
+
+ dlg.querySelector('.btnCancel').addEventListener('click', function () {
+
+ dialogHelper.close(dlg);
+ });
+
+ if (layoutManager.tv) {
+ centerFocus(dlg.querySelector('.formDialogContent'), false, true);
+ }
+
+ return dialogHelper.open(dlg).then(function () {
+
+ if (layoutManager.tv) {
+ centerFocus(dlg.querySelector('.formDialogContent'), false, false);
+ }
+
+ if (dlg.submitted) {
+ return Promise.resolve();
+ }
+
+ return Promise.reject();
+ });
+ };
+
+ return CollectionEditor;
});
\ No newline at end of file
diff --git a/src/bower_components/emby-webcomponents/confirm/confirm.js b/src/bower_components/emby-webcomponents/confirm/confirm.js
index 22890d52cb..877a0716e9 100644
--- a/src/bower_components/emby-webcomponents/confirm/confirm.js
+++ b/src/bower_components/emby-webcomponents/confirm/confirm.js
@@ -1,22 +1,40 @@
-define(["dialog", "globalize"], function(dialog, globalize) {
- "use strict";
- return function(text, title) {
+define(['dialog', 'globalize'], function (dialog, globalize) {
+ 'use strict';
+
+ return function (text, title) {
+
var options;
- options = "string" == typeof text ? {
- title: title,
- text: text
- } : text;
+ if (typeof text === 'string') {
+ options = {
+ title: title,
+ text: text
+ };
+ } else {
+ options = text;
+ }
+
var items = [];
- return items.push({
- name: options.cancelText || globalize.translate("sharedcomponents#ButtonCancel"),
- id: "cancel",
- type: "cancel" === options.primary ? "submit" : "cancel"
- }), items.push({
- name: options.confirmText || globalize.translate("sharedcomponents#ButtonOk"),
- id: "ok",
- type: "cancel" === options.primary ? "cancel" : "submit"
- }), options.buttons = items, dialog(options).then(function(result) {
- return "ok" === result ? Promise.resolve() : Promise.reject()
- })
- }
+
+ items.push({
+ name: options.cancelText || globalize.translate('sharedcomponents#ButtonCancel'),
+ id: 'cancel',
+ type: options.primary === 'cancel' ? 'submit' : 'cancel'
+ });
+
+ items.push({
+ name: options.confirmText || globalize.translate('sharedcomponents#ButtonOk'),
+ id: 'ok',
+ type: options.primary === 'cancel' ? 'cancel' : 'submit'
+ });
+
+ options.buttons = items;
+
+ return dialog(options).then(function (result) {
+ if (result === 'ok') {
+ return Promise.resolve();
+ }
+
+ return Promise.reject();
+ });
+ };
});
\ No newline at end of file
diff --git a/src/bower_components/emby-webcomponents/confirm/nativeconfirm.js b/src/bower_components/emby-webcomponents/confirm/nativeconfirm.js
index d909e687e8..fd586ad1d5 100644
--- a/src/bower_components/emby-webcomponents/confirm/nativeconfirm.js
+++ b/src/bower_components/emby-webcomponents/confirm/nativeconfirm.js
@@ -1,15 +1,27 @@
-define([], function() {
- "use strict";
+define([], function () {
+ 'use strict';
function replaceAll(str, find, replace) {
- return str.split(find).join(replace)
- }
- return function(options) {
- "string" == typeof options && (options = {
- title: "",
- text: options
- });
- var text = replaceAll(options.text || "", "
", "\n");
- return confirm(text) ? Promise.resolve() : Promise.reject()
+
+ return str.split(find).join(replace);
}
+
+ return function (options) {
+
+ if (typeof options === 'string') {
+ options = {
+ title: '',
+ text: options
+ };
+ }
+
+ var text = replaceAll(options.text || '', '
', '\n');
+ var result = confirm(text);
+
+ if (result) {
+ return Promise.resolve();
+ } else {
+ return Promise.reject();
+ }
+ };
});
\ No newline at end of file
diff --git a/src/bower_components/emby-webcomponents/datetime.js b/src/bower_components/emby-webcomponents/datetime.js
index 9d3edd6786..15d0c64865 100644
--- a/src/bower_components/emby-webcomponents/datetime.js
+++ b/src/bower_components/emby-webcomponents/datetime.js
@@ -1,113 +1,272 @@
-define(["globalize"], function(globalize) {
- "use strict";
+define(['globalize'], function (globalize) {
+ 'use strict';
function parseISO8601Date(s, toLocal) {
- var re = /(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(\.\d+)?(Z|([+-])(\d{2}):(\d{2}))?/,
- d = s.match(re);
- if (!d) throw "Couldn't parse ISO 8601 date string '" + s + "'";
+
+ // parenthese matches:
+ // year month day hours minutes seconds
+ // dotmilliseconds
+ // tzstring plusminus hours minutes
+ var re = /(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(\.\d+)?(Z|([+-])(\d{2}):(\d{2}))?/;
+
+ var d = s.match(re);
+
+ // "2010-12-07T11:00:00.000-09:00" parses to:
+ // ["2010-12-07T11:00:00.000-09:00", "2010", "12", "07", "11",
+ // "00", "00", ".000", "-09:00", "-", "09", "00"]
+ // "2010-12-07T11:00:00.000Z" parses to:
+ // ["2010-12-07T11:00:00.000Z", "2010", "12", "07", "11",
+ // "00", "00", ".000", "Z", undefined, undefined, undefined]
+
+ if (!d) {
+
+ throw "Couldn't parse ISO 8601 date string '" + s + "'";
+ }
+
+ // parse strings, leading zeros into proper ints
var a = [1, 2, 3, 4, 5, 6, 10, 11];
- for (var i in a) d[a[i]] = parseInt(d[a[i]], 10);
+ for (var i in a) {
+ d[a[i]] = parseInt(d[a[i]], 10);
+ }
d[7] = parseFloat(d[7]);
+
+ // Date.UTC(year, month[, date[, hrs[, min[, sec[, ms]]]]])
+ // note that month is 0-11, not 1-12
+ // see https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Date/UTC
var ms = Date.UTC(d[1], d[2] - 1, d[3], d[4], d[5], d[6]);
- if (d[7] > 0 && (ms += Math.round(1e3 * d[7])), "Z" !== d[8] && d[10]) {
- var offset = 60 * d[10] * 60 * 1e3;
- d[11] && (offset += 60 * d[11] * 1e3), "-" === d[9] ? ms -= offset : ms += offset
- } else !1 === toLocal && (ms += 6e4 * (new Date).getTimezoneOffset());
- return new Date(ms)
+
+ // if there are milliseconds, add them
+ if (d[7] > 0) {
+ ms += Math.round(d[7] * 1000);
+ }
+
+ // if there's a timezone, calculate it
+ if (d[8] !== "Z" && d[10]) {
+ var offset = d[10] * 60 * 60 * 1000;
+ if (d[11]) {
+ offset += d[11] * 60 * 1000;
+ }
+ if (d[9] === "-") {
+ ms -= offset;
+ } else {
+ ms += offset;
+ }
+ } else if (toLocal === false) {
+ ms += new Date().getTimezoneOffset() * 60000;
+ }
+
+ return new Date(ms);
}
function getDisplayRunningTime(ticks) {
- var parts = [],
- hours = ticks / 36e9;
- hours = Math.floor(hours), hours && parts.push(hours), ticks -= 36e9 * hours;
- var minutes = ticks / 6e8;
- minutes = Math.floor(minutes), ticks -= 6e8 * minutes, minutes < 10 && hours && (minutes = "0" + minutes), parts.push(minutes);
- var seconds = ticks / 1e7;
- return seconds = Math.floor(seconds), seconds < 10 && (seconds = "0" + seconds), parts.push(seconds), parts.join(":")
+ var ticksPerHour = 36000000000;
+ var ticksPerMinute = 600000000;
+ var ticksPerSecond = 10000000;
+
+ var parts = [];
+
+ var hours = ticks / ticksPerHour;
+ hours = Math.floor(hours);
+
+ if (hours) {
+ parts.push(hours);
+ }
+
+ ticks -= (hours * ticksPerHour);
+
+ var minutes = ticks / ticksPerMinute;
+ minutes = Math.floor(minutes);
+
+ ticks -= (minutes * ticksPerMinute);
+
+ if (minutes < 10 && hours) {
+ minutes = '0' + minutes;
+ }
+ parts.push(minutes);
+
+ var seconds = ticks / ticksPerSecond;
+ seconds = Math.floor(seconds);
+
+ if (seconds < 10) {
+ seconds = '0' + seconds;
+ }
+ parts.push(seconds);
+
+ return parts.join(':');
}
+ var toLocaleTimeStringSupportsLocales = function () {
+ try {
+ new Date().toLocaleTimeString('i');
+ } catch (e) {
+ return e.name === 'RangeError';
+ }
+ return false;
+ }();
+
function getOptionList(options) {
+
var list = [];
- for (var i in options) list.push({
- name: i,
- value: options[i]
- });
- return list
+
+ for (var i in options) {
+ list.push({
+ name: i,
+ value: options[i]
+ });
+ }
+
+ return list;
}
function toLocaleString(date, options) {
- if (!date) throw new Error("date cannot be null");
- if (options = options || {}, toLocaleTimeStringSupportsLocales) {
- var currentLocale = globalize.getCurrentDateTimeLocale();
- if (currentLocale) return date.toLocaleString(currentLocale, options)
+
+ if (!date) {
+ throw new Error('date cannot be null');
}
- return date.toLocaleString()
+
+ options = options || {};
+
+ if (toLocaleTimeStringSupportsLocales) {
+
+ var currentLocale = globalize.getCurrentDateTimeLocale();
+
+ if (currentLocale) {
+ return date.toLocaleString(currentLocale, options);
+ }
+ }
+
+ return date.toLocaleString();
}
function toLocaleDateString(date, options) {
- if (!date) throw new Error("date cannot be null");
- if (options = options || {}, toLocaleTimeStringSupportsLocales) {
+
+ if (!date) {
+ throw new Error('date cannot be null');
+ }
+
+ options = options || {};
+
+ if (toLocaleTimeStringSupportsLocales) {
+
var currentLocale = globalize.getCurrentDateTimeLocale();
- if (currentLocale) return date.toLocaleDateString(currentLocale, options)
+
+ if (currentLocale) {
+ return date.toLocaleDateString(currentLocale, options);
+ }
}
+
+ // This is essentially a hard-coded polyfill
var optionList = getOptionList(options);
- if (1 === optionList.length && "weekday" === optionList[0].name) {
+ if (optionList.length === 1 && optionList[0].name === 'weekday') {
var weekday = [];
- return weekday[0] = "Sun", weekday[1] = "Mon", weekday[2] = "Tue", weekday[3] = "Wed", weekday[4] = "Thu", weekday[5] = "Fri", weekday[6] = "Sat", weekday[date.getDay()]
+ weekday[0] = "Sun";
+ weekday[1] = "Mon";
+ weekday[2] = "Tue";
+ weekday[3] = "Wed";
+ weekday[4] = "Thu";
+ weekday[5] = "Fri";
+ weekday[6] = "Sat";
+ return weekday[date.getDay()];
}
- return date.toLocaleDateString()
+
+ return date.toLocaleDateString();
}
function toLocaleTimeString(date, options) {
- if (!date) throw new Error("date cannot be null");
- if (options = options || {}, toLocaleTimeStringSupportsLocales) {
- var currentLocale = globalize.getCurrentDateTimeLocale();
- if (currentLocale) return date.toLocaleTimeString(currentLocale, options)
+
+ if (!date) {
+ throw new Error('date cannot be null');
}
- return date.toLocaleTimeString()
+
+ options = options || {};
+
+ if (toLocaleTimeStringSupportsLocales) {
+
+ var currentLocale = globalize.getCurrentDateTimeLocale();
+
+ if (currentLocale) {
+ return date.toLocaleTimeString(currentLocale, options);
+ }
+ }
+
+ return date.toLocaleTimeString();
}
function getDisplayTime(date) {
- if (!date) throw new Error("date cannot be null");
- if ("string" === (typeof date).toString().toLowerCase()) try {
- date = parseISO8601Date(date, !0)
- } catch (err) {
- return date
+
+ if (!date) {
+ throw new Error('date cannot be null');
}
- if (toLocaleTimeStringSupportsLocales) return toLocaleTimeString(date, {
- hour: "numeric",
- minute: "2-digit"
- });
- var time = toLocaleTimeString(date),
- timeLower = time.toLowerCase();
- if (-1 !== timeLower.indexOf("am") || -1 !== timeLower.indexOf("pm")) {
+
+ if ((typeof date).toString().toLowerCase() === 'string') {
+ try {
+
+ date = parseISO8601Date(date, true);
+
+ } catch (err) {
+ return date;
+ }
+ }
+
+ if (toLocaleTimeStringSupportsLocales) {
+ return toLocaleTimeString(date, {
+
+ hour: 'numeric',
+ minute: '2-digit'
+
+ });
+ }
+
+ var time = toLocaleTimeString(date);
+
+ var timeLower = time.toLowerCase();
+
+ if (timeLower.indexOf('am') !== -1 || timeLower.indexOf('pm') !== -1) {
+
time = timeLower;
- var hour = date.getHours() % 12,
- suffix = date.getHours() > 11 ? "pm" : "am";
- hour || (hour = 12);
+ var hour = date.getHours() % 12;
+ var suffix = date.getHours() > 11 ? 'pm' : 'am';
+ if (!hour) {
+ hour = 12;
+ }
var minutes = date.getMinutes();
- minutes < 10 && (minutes = "0" + minutes), minutes = ":" + minutes, time = hour + minutes + suffix
+
+ if (minutes < 10) {
+ minutes = '0' + minutes;
+ }
+
+ minutes = ':' + minutes;
+ time = hour + minutes + suffix;
} else {
- var timeParts = time.split(":");
- timeParts.length > 2 && (timeParts.length = 2, time = timeParts.join(":"))
+
+ var timeParts = time.split(':');
+
+ // Trim off seconds
+ if (timeParts.length > 2) {
+
+ // setting to 2 also handles '21:00:28 GMT+9:30'
+ timeParts.length = 2;
+ time = timeParts.join(':');
+ }
}
- return time
+
+ return time;
}
function isRelativeDay(date, offsetInDays) {
- if (!date) throw new Error("date cannot be null");
- var yesterday = new Date,
- day = yesterday.getDate() + offsetInDays;
- return yesterday.setDate(day), date.getFullYear() === yesterday.getFullYear() && date.getMonth() === yesterday.getMonth() && date.getDate() === day
- }
- var toLocaleTimeStringSupportsLocales = function() {
- try {
- (new Date).toLocaleTimeString("i")
- } catch (e) {
- return "RangeError" === e.name
+
+ if (!date) {
+ throw new Error('date cannot be null');
}
- return !1
- }();
+
+ var yesterday = new Date();
+ var day = yesterday.getDate() + offsetInDays;
+
+ yesterday.setDate(day); // automatically adjusts month/year appropriately
+
+ return date.getFullYear() === yesterday.getFullYear() && date.getMonth() === yesterday.getMonth() && date.getDate() === day;
+ }
+
return {
parseISO8601Date: parseISO8601Date,
getDisplayRunningTime: getDisplayRunningTime,
@@ -116,8 +275,8 @@ define(["globalize"], function(globalize) {
getDisplayTime: getDisplayTime,
isRelativeDay: isRelativeDay,
toLocaleTimeString: toLocaleTimeString,
- supportsLocalization: function() {
- return toLocaleTimeStringSupportsLocales
+ supportsLocalization: function () {
+ return toLocaleTimeStringSupportsLocales;
}
- }
+ };
});
\ No newline at end of file
diff --git a/src/bower_components/emby-webcomponents/deletehelper.js b/src/bower_components/emby-webcomponents/deletehelper.js
index e31b9104e3..e8f3ad3d18 100644
--- a/src/bower_components/emby-webcomponents/deletehelper.js
+++ b/src/bower_components/emby-webcomponents/deletehelper.js
@@ -1,39 +1,57 @@
-define(["connectionManager", "confirm", "appRouter", "globalize"], function(connectionManager, confirm, appRouter, globalize) {
- "use strict";
+define(['connectionManager', 'confirm', 'appRouter', 'globalize'], function (connectionManager, confirm, appRouter, globalize) {
+ 'use strict';
function alertText(options) {
- return new Promise(function(resolve, reject) {
- require(["alert"], function(alert) {
- alert(options).then(resolve, resolve)
- })
- })
+
+ return new Promise(function (resolve, reject) {
+
+ require(['alert'], function (alert) {
+ alert(options).then(resolve, resolve);
+ });
+ });
}
function deleteItem(options) {
- var item = options.item,
- itemId = item.Id,
- parentId = item.SeasonId || item.SeriesId || item.ParentId,
- serverId = item.ServerId,
- msg = globalize.translate("sharedcomponents#ConfirmDeleteItem"),
- title = globalize.translate("sharedcomponents#HeaderDeleteItem"),
- apiClient = connectionManager.getApiClient(item.ServerId);
+
+ var item = options.item;
+ var itemId = item.Id;
+ var parentId = item.SeasonId || item.SeriesId || item.ParentId;
+ var serverId = item.ServerId;
+
+ var msg = globalize.translate('sharedcomponents#ConfirmDeleteItem');
+ var title = globalize.translate('sharedcomponents#HeaderDeleteItem');
+ var apiClient = connectionManager.getApiClient(item.ServerId);
+
return confirm({
+
title: title,
text: msg,
- confirmText: globalize.translate("sharedcomponents#Delete"),
- primary: "cancel"
- }).then(function() {
- return apiClient.deleteItem(itemId).then(function() {
- options.navigate && (parentId ? appRouter.showItem(parentId, serverId) : appRouter.goHome())
- }, function(err) {
- var result = function() {
- return Promise.reject(err)
+ confirmText: globalize.translate('sharedcomponents#Delete'),
+ primary: 'cancel'
+
+ }).then(function () {
+
+ return apiClient.deleteItem(itemId).then(function () {
+
+ if (options.navigate) {
+ if (parentId) {
+ appRouter.showItem(parentId, serverId);
+ } else {
+ appRouter.goHome();
+ }
+ }
+ }, function (err) {
+
+ var result = function () {
+ return Promise.reject(err);
};
- return alertText(globalize.translate("sharedcomponents#ErrorDeletingItem")).then(result, result)
- })
- })
+
+ return alertText(globalize.translate('sharedcomponents#ErrorDeletingItem')).then(result, result);
+ });
+ });
}
+
return {
deleteItem: deleteItem
- }
+ };
});
\ No newline at end of file
diff --git a/src/bower_components/emby-webcomponents/dialog/dialog.js b/src/bower_components/emby-webcomponents/dialog/dialog.js
index 1208719886..62faebd31e 100644
--- a/src/bower_components/emby-webcomponents/dialog/dialog.js
+++ b/src/bower_components/emby-webcomponents/dialog/dialog.js
@@ -1,46 +1,133 @@
-define(["dialogHelper", "dom", "layoutManager", "scrollHelper", "globalize", "require", "material-icons", "emby-button", "paper-icon-button-light", "emby-input", "formDialogStyle", "flexStyles"], function(dialogHelper, dom, layoutManager, scrollHelper, globalize, require) {
- "use strict";
+define(['dialogHelper', 'dom', 'layoutManager', 'scrollHelper', 'globalize', 'require', 'material-icons', 'emby-button', 'paper-icon-button-light', 'emby-input', 'formDialogStyle', 'flexStyles'], function (dialogHelper, dom, layoutManager, scrollHelper, globalize, require) {
+ 'use strict';
function showDialog(options, template) {
- function onButtonClick() {
- dialogResult = this.getAttribute("data-id"), dialogHelper.close(dlg)
- }
+
var dialogOptions = {
- removeOnClose: !0,
- scrollY: !1
- },
- enableTvLayout = layoutManager.tv;
- enableTvLayout && (dialogOptions.size = "fullscreen");
- var dlg = dialogHelper.createDialog(dialogOptions);
- dlg.classList.add("formDialog"), dlg.innerHTML = globalize.translateHtml(template, "sharedcomponents"), dlg.classList.add("align-items-center"), dlg.classList.add("justify-content-center");
- var formDialogContent = dlg.querySelector(".formDialogContent");
- formDialogContent.classList.add("no-grow"), enableTvLayout ? (formDialogContent.style["max-width"] = "50%", formDialogContent.style["max-height"] = "60%", scrollHelper.centerFocus.on(formDialogContent, !1)) : (formDialogContent.style.maxWidth = Math.min(150 * options.buttons.length + 200, dom.getWindowSize().innerWidth - 50) + "px", dlg.classList.add("dialog-fullscreen-lowres")), options.title ? dlg.querySelector(".formDialogHeaderTitle").innerHTML = options.title || "" : dlg.querySelector(".formDialogHeaderTitle").classList.add("hide");
- var displayText = options.html || options.text || "";
- dlg.querySelector(".text").innerHTML = displayText, displayText || dlg.querySelector(".dialogContentInner").classList.add("hide");
- var i, length, html = "",
- hasDescriptions = !1;
- for (i = 0, length = options.buttons.length; i < length; i++) {
- var item = options.buttons[i],
- autoFocus = 0 === i ? " autofocus" : "",
- buttonClass = "btnOption raised formDialogFooterItem formDialogFooterItem-autosize";
- item.type && (buttonClass += " button-" + item.type), item.description && (hasDescriptions = !0), hasDescriptions && (buttonClass += " formDialogFooterItem-vertical formDialogFooterItem-nomarginbottom"), html += '
" + item.name + " ", item.description && (html += '")
+ removeOnClose: true,
+ scrollY: false
+ };
+
+ var enableTvLayout = layoutManager.tv;
+
+ if (enableTvLayout) {
+ dialogOptions.size = 'fullscreen';
}
- dlg.querySelector(".formDialogFooter").innerHTML = html, hasDescriptions && dlg.querySelector(".formDialogFooter").classList.add("formDialogFooter-vertical");
- var dialogResult, buttons = dlg.querySelectorAll(".btnOption");
- for (i = 0, length = buttons.length; i < length; i++) buttons[i].addEventListener("click", onButtonClick);
- return dialogHelper.open(dlg).then(function() {
- return enableTvLayout && scrollHelper.centerFocus.off(dlg.querySelector(".formDialogContent"), !1), dialogResult || Promise.reject()
- })
+
+ var dlg = dialogHelper.createDialog(dialogOptions);
+
+ dlg.classList.add('formDialog');
+
+ dlg.innerHTML = globalize.translateHtml(template, 'sharedcomponents');
+
+ dlg.classList.add('align-items-center');
+ dlg.classList.add('justify-content-center');
+ var formDialogContent = dlg.querySelector('.formDialogContent');
+ formDialogContent.classList.add('no-grow');
+
+ if (enableTvLayout) {
+ formDialogContent.style['max-width'] = '50%';
+ formDialogContent.style['max-height'] = '60%';
+ scrollHelper.centerFocus.on(formDialogContent, false);
+ } else {
+ formDialogContent.style.maxWidth = (Math.min((options.buttons.length * 150) + 200, dom.getWindowSize().innerWidth - 50)) + 'px';
+ dlg.classList.add('dialog-fullscreen-lowres');
+ }
+
+ //dlg.querySelector('.btnCancel').addEventListener('click', function (e) {
+ // dialogHelper.close(dlg);
+ //});
+
+ if (options.title) {
+ dlg.querySelector('.formDialogHeaderTitle').innerHTML = options.title || '';
+ } else {
+ dlg.querySelector('.formDialogHeaderTitle').classList.add('hide');
+ }
+
+ var displayText = options.html || options.text || '';
+ dlg.querySelector('.text').innerHTML = displayText;
+
+ if (!displayText) {
+ dlg.querySelector('.dialogContentInner').classList.add('hide');
+ }
+
+ var i, length;
+ var html = '';
+ var hasDescriptions = false;
+
+ for (i = 0, length = options.buttons.length; i < length; i++) {
+
+ var item = options.buttons[i];
+ var autoFocus = i === 0 ? ' autofocus' : '';
+
+ var buttonClass = 'btnOption raised formDialogFooterItem formDialogFooterItem-autosize';
+
+ if (item.type) {
+ buttonClass += ' button-' + item.type;
+ }
+
+ if (item.description) {
+ hasDescriptions = true;
+ }
+
+ if (hasDescriptions) {
+ buttonClass += ' formDialogFooterItem-vertical formDialogFooterItem-nomarginbottom';
+ }
+
+ html += '
' + item.name + ' ';
+
+ if (item.description) {
+ html += '';
+ }
+ }
+
+ dlg.querySelector('.formDialogFooter').innerHTML = html;
+
+ if (hasDescriptions) {
+ dlg.querySelector('.formDialogFooter').classList.add('formDialogFooter-vertical');
+ }
+
+ var dialogResult;
+ function onButtonClick() {
+ dialogResult = this.getAttribute('data-id');
+ dialogHelper.close(dlg);
+ }
+
+ var buttons = dlg.querySelectorAll('.btnOption');
+ for (i = 0, length = buttons.length; i < length; i++) {
+ buttons[i].addEventListener('click', onButtonClick);
+ }
+
+ return dialogHelper.open(dlg).then(function () {
+
+ if (enableTvLayout) {
+ scrollHelper.centerFocus.off(dlg.querySelector('.formDialogContent'), false);
+ }
+
+ if (dialogResult) {
+ return dialogResult;
+ } else {
+ return Promise.reject();
+ }
+ });
}
- return function(text, title) {
+
+ return function (text, title) {
+
var options;
- return options = "string" == typeof text ? {
- title: title,
- text: text
- } : text, new Promise(function(resolve, reject) {
- require(["text!./dialog.template.html"], function(template) {
- showDialog(options, template).then(resolve, reject)
- })
- })
- }
+ if (typeof text === 'string') {
+ options = {
+ title: title,
+ text: text
+ };
+ } else {
+ options = text;
+ }
+
+ return new Promise(function (resolve, reject) {
+ require(['text!./dialog.template.html'], function (template) {
+ showDialog(options, template).then(resolve, reject);
+ });
+ });
+ };
});
\ No newline at end of file
diff --git a/src/bower_components/emby-webcomponents/dialoghelper/dialoghelper.css b/src/bower_components/emby-webcomponents/dialoghelper/dialoghelper.css
index c396dec604..2cc20b5ff2 100644
--- a/src/bower_components/emby-webcomponents/dialoghelper/dialoghelper.css
+++ b/src/bower_components/emby-webcomponents/dialoghelper/dialoghelper.css
@@ -1,12 +1,6 @@
.dialogContainer {
- display: -webkit-box;
- display: -webkit-flex;
display: flex;
- -webkit-box-align: center;
- -webkit-align-items: center;
align-items: center;
- -webkit-box-pack: center;
- -webkit-justify-content: center;
justify-content: center;
position: fixed;
top: 0;
@@ -16,234 +10,148 @@
z-index: 999999 !important;
contain: strict;
overflow: hidden;
- overscroll-behavior: contain
+ overscroll-behavior: contain;
}
.dialog {
margin: 0;
- -webkit-border-radius: .2em;
border-radius: .2em;
-webkit-font-smoothing: antialiased;
border: 0;
padding: 0;
will-change: transform, opacity;
+ /* Strict does not work well with actionsheet */
contain: style paint;
- -webkit-box-shadow: 0 16px 24px 2px rgba(0, 0, 0, .14), 0 6px 30px 5px rgba(0, 0, 0, .12), 0 8px 10px -5px rgba(0, 0, 0, .4);
- box-shadow: 0 16px 24px 2px rgba(0, 0, 0, .14), 0 6px 30px 5px rgba(0, 0, 0, .12), 0 8px 10px -5px rgba(0, 0, 0, .4)
+ box-shadow: 0 16px 24px 2px rgba(0, 0, 0, 0.14), 0 6px 30px 5px rgba(0, 0, 0, 0.12), 0 8px 10px -5px rgba(0, 0, 0, 0.4);
}
.dialog-fixedSize {
- -webkit-border-radius: 0;
border-radius: 0;
max-height: none;
max-width: none;
- contain: layout style paint
+ contain: layout style paint;
}
.dialog-fullscreen {
+ /* Needed due to formDialog style */
position: fixed !important;
top: 0;
bottom: 0;
left: 0;
right: 0;
margin: 0;
- -webkit-box-shadow: none;
- box-shadow: none
-}
-
-@-webkit-keyframes scaledown {
- from {
- opacity: 1;
- -webkit-transform: none;
- transform: none
- }
-
- to {
- opacity: 0;
- -webkit-transform: scale(.5);
- transform: scale(.5)
- }
+ box-shadow: none;
}
@keyframes scaledown {
from {
opacity: 1;
- -webkit-transform: none;
- transform: none
+ transform: none;
}
to {
opacity: 0;
- -webkit-transform: scale(.5);
- transform: scale(.5)
- }
-}
-
-@-webkit-keyframes scaleup {
- from {
- -webkit-transform: scale(.5);
transform: scale(.5);
- opacity: 0
- }
-
- to {
- -webkit-transform: none;
- transform: none;
- opacity: 1
}
}
@keyframes scaleup {
from {
- -webkit-transform: scale(.5);
transform: scale(.5);
- opacity: 0
+ opacity: 0;
}
to {
- -webkit-transform: none;
transform: none;
- opacity: 1
- }
-}
-
-@-webkit-keyframes fadein {
- from {
- opacity: 0
- }
-
- to {
- opacity: 1
+ opacity: 1;
}
}
@keyframes fadein {
- from {
- opacity: 0
- }
-
- to {
- opacity: 1
- }
-}
-
-@-webkit-keyframes fadeout {
- from {
- opacity: 1
- }
-
- to {
- opacity: 0
- }
-}
-
-@keyframes fadeout {
- from {
- opacity: 1
- }
-
- to {
- opacity: 0
- }
-}
-
-@-webkit-keyframes slideup {
from {
opacity: 0;
- -webkit-transform: translate3d(0, 30%, 0);
- transform: translate3d(0, 30%, 0)
}
to {
opacity: 1;
- -webkit-transform: none;
- transform: none
+ }
+}
+
+@keyframes fadeout {
+
+ from {
+ opacity: 1;
+ }
+
+ to {
+ opacity: 0;
}
}
@keyframes slideup {
from {
opacity: 0;
- -webkit-transform: translate3d(0, 30%, 0);
- transform: translate3d(0, 30%, 0)
+ transform: translate3d(0, 30%, 0);
}
to {
opacity: 1;
- -webkit-transform: none;
- transform: none
- }
-}
-
-@-webkit-keyframes slidedown {
- from {
- opacity: 1;
- -webkit-transform: none;
- transform: none
- }
-
- to {
- opacity: 0;
- -webkit-transform: translate3d(0, 20%, 0);
- transform: translate3d(0, 20%, 0)
+ transform: none;
}
}
@keyframes slidedown {
+
from {
opacity: 1;
- -webkit-transform: none;
- transform: none
+ transform: none;
}
to {
opacity: 0;
- -webkit-transform: translate3d(0, 20%, 0);
- transform: translate3d(0, 20%, 0)
+ transform: translate3d(0, 20%, 0);
}
}
-@media all and (max-width:80em),
-all and (max-height:45em) {
+@media all and (max-width: 80em), all and (max-height: 45em) {
- .dialog-fixedSize,
- .dialog-fullscreen-lowres {
+ .dialog-fixedSize, .dialog-fullscreen-lowres {
position: fixed !important;
top: 0 !important;
bottom: 0 !important;
left: 0 !important;
right: 0 !important;
margin: 0 !important;
- -webkit-box-shadow: none;
- box-shadow: none
+ box-shadow: none;
}
}
-@media all and (min-width:80em) and (min-height:45em) {
+@media all and (min-width: 80em) and (min-height: 45em) {
+
.dialog-medium {
width: 80%;
- height: 80%
+ height: 80%;
}
.dialog-medium-tall {
width: 80%;
- height: 90%
+ height: 90%;
}
.dialog-small {
width: 60%;
- height: 80%
+ height: 80%;
}
.dialog-fullscreen-border {
width: 90%;
- height: 90%
+ height: 90%;
}
}
.noScroll {
overflow-x: hidden !important;
- overflow-y: hidden !important
+ overflow-y: hidden !important;
}
.dialogBackdrop {
@@ -256,12 +164,10 @@ all and (max-height:45em) {
right: 0 !important;
margin: 0 !important;
z-index: 999999 !important;
- -webkit-transition: opacity ease-out .2s;
- -o-transition: opacity ease-out .2s;
- transition: opacity ease-out .2s;
- will-change: opacity
+ transition: opacity ease-out 0.2s;
+ will-change: opacity;
}
.dialogBackdropOpened {
- opacity: .5
-}
\ No newline at end of file
+ opacity: .5;
+}
diff --git a/src/bower_components/emby-webcomponents/dialoghelper/dialoghelper.js b/src/bower_components/emby-webcomponents/dialoghelper/dialoghelper.js
index 9c5f6b0064..48aa006215 100644
--- a/src/bower_components/emby-webcomponents/dialoghelper/dialoghelper.js
+++ b/src/bower_components/emby-webcomponents/dialoghelper/dialoghelper.js
@@ -1,225 +1,486 @@
-define(["appRouter", "focusManager", "browser", "layoutManager", "inputManager", "dom", "css!./dialoghelper.css", "scrollStyles"], function(appRouter, focusManager, browser, layoutManager, inputManager, dom) {
- "use strict";
+define(['appRouter', 'focusManager', 'browser', 'layoutManager', 'inputManager', 'dom', 'css!./dialoghelper.css', 'scrollStyles'], function (appRouter, focusManager, browser, layoutManager, inputManager, dom) {
+ 'use strict';
+
+ var globalOnOpenCallback;
function enableAnimation() {
- return !browser.tv && browser.supportsCssAnimation()
+
+ // too slow
+ if (browser.tv) {
+ return false;
+ }
+
+ return browser.supportsCssAnimation();
}
function removeCenterFocus(dlg) {
- layoutManager.tv && (dlg.classList.contains("scrollX") ? centerFocus(dlg, !0, !1) : dlg.classList.contains("smoothScrollY") && centerFocus(dlg, !1, !1))
+
+ if (layoutManager.tv) {
+ if (dlg.classList.contains('scrollX')) {
+ centerFocus(dlg, true, false);
+ }
+ else if (dlg.classList.contains('smoothScrollY')) {
+ centerFocus(dlg, false, false);
+ }
+ }
}
function tryRemoveElement(elem) {
var parentNode = elem.parentNode;
- if (parentNode) try {
- parentNode.removeChild(elem)
- } catch (err) {
- console.log("Error removing dialog element: " + err)
+ if (parentNode) {
+
+ // Seeing crashes in edge webview
+ try {
+ parentNode.removeChild(elem);
+ } catch (err) {
+ console.log('Error removing dialog element: ' + err);
+ }
}
}
function DialogHashHandler(dlg, hash, resolve) {
+
+ var self = this;
+ self.originalUrl = window.location.href;
+ var activeElement = document.activeElement;
+ var removeScrollLockOnClose = false;
+
function onHashChange(e) {
+
var isBack = self.originalUrl === window.location.href;
- !isBack && isOpened(dlg) || window.removeEventListener("popstate", onHashChange), isBack && (self.closedByBack = !0, closeDialog(dlg))
+
+ if (isBack || !isOpened(dlg)) {
+ window.removeEventListener('popstate', onHashChange);
+ }
+
+ if (isBack) {
+ self.closedByBack = true;
+ closeDialog(dlg);
+ }
}
function onBackCommand(e) {
- "back" === e.detail.command && (self.closedByBack = !0, e.preventDefault(), e.stopPropagation(), closeDialog(dlg))
+
+ if (e.detail.command === 'back') {
+ self.closedByBack = true;
+ e.preventDefault();
+ e.stopPropagation();
+ closeDialog(dlg);
+ }
}
function onDialogClosed() {
- if (isHistoryEnabled(dlg) || inputManager.off(dlg, onBackCommand), window.removeEventListener("popstate", onHashChange), removeBackdrop(dlg), dlg.classList.remove("opened"), removeScrollLockOnClose && document.body.classList.remove("noScroll"), !self.closedByBack && isHistoryEnabled(dlg)) {
- (history.state || {}).dialogId === hash && history.back()
+
+ if (!isHistoryEnabled(dlg)) {
+ inputManager.off(dlg, onBackCommand);
}
- if (layoutManager.tv && focusManager.focus(activeElement), "false" !== dlg.getAttribute("data-removeonclose")) {
+
+ window.removeEventListener('popstate', onHashChange);
+
+ removeBackdrop(dlg);
+ dlg.classList.remove('opened');
+
+ if (removeScrollLockOnClose) {
+ document.body.classList.remove('noScroll');
+ }
+
+ if (!self.closedByBack && isHistoryEnabled(dlg)) {
+ var state = history.state || {};
+ if (state.dialogId === hash) {
+ history.back();
+ }
+ }
+
+ if (layoutManager.tv) {
+ focusManager.focus(activeElement);
+ }
+
+ if (dlg.getAttribute('data-removeonclose') !== 'false') {
removeCenterFocus(dlg);
+
var dialogContainer = dlg.dialogContainer;
- dialogContainer ? (tryRemoveElement(dialogContainer), dlg.dialogContainer = null) : tryRemoveElement(dlg)
+ if (dialogContainer) {
+ tryRemoveElement(dialogContainer);
+ dlg.dialogContainer = null;
+ } else {
+ tryRemoveElement(dlg);
+ }
}
- setTimeout(function() {
+
+ //resolve();
+ // if we just called history.back(), then use a timeout to allow the history events to fire first
+ setTimeout(function () {
resolve({
element: dlg,
closedByBack: self.closedByBack
- })
- }, 1)
+ });
+ }, 1);
+ }
+
+ dlg.addEventListener('close', onDialogClosed);
+
+ var center = !dlg.classList.contains('dialog-fixedSize');
+ if (center) {
+ dlg.classList.add('centeredDialog');
+ }
+
+ dlg.classList.remove('hide');
+
+ addBackdropOverlay(dlg);
+
+ dlg.classList.add('opened');
+ dlg.dispatchEvent(new CustomEvent('open', {
+ bubbles: false,
+ cancelable: false
+ }));
+
+ if (dlg.getAttribute('data-lockscroll') === 'true' && !document.body.classList.contains('noScroll')) {
+ document.body.classList.add('noScroll');
+ removeScrollLockOnClose = true;
+ }
+
+ animateDialogOpen(dlg);
+
+ if (isHistoryEnabled(dlg)) {
+ appRouter.pushState({ dialogId: hash }, "Dialog", '#' + hash);
+
+ window.addEventListener('popstate', onHashChange);
+ } else {
+ inputManager.on(dlg, onBackCommand);
}
- var self = this;
- self.originalUrl = window.location.href;
- var activeElement = document.activeElement,
- removeScrollLockOnClose = !1;
- dlg.addEventListener("close", onDialogClosed), !dlg.classList.contains("dialog-fixedSize") && dlg.classList.add("centeredDialog"), dlg.classList.remove("hide"), addBackdropOverlay(dlg), dlg.classList.add("opened"), dlg.dispatchEvent(new CustomEvent("open", {
- bubbles: !1,
- cancelable: !1
- })), "true" !== dlg.getAttribute("data-lockscroll") || document.body.classList.contains("noScroll") || (document.body.classList.add("noScroll"), removeScrollLockOnClose = !0), animateDialogOpen(dlg), isHistoryEnabled(dlg) ? (appRouter.pushState({
- dialogId: hash
- }, "Dialog", "#" + hash), window.addEventListener("popstate", onHashChange)) : inputManager.on(dlg, onBackCommand)
}
function addBackdropOverlay(dlg) {
- var backdrop = document.createElement("div");
- backdrop.classList.add("dialogBackdrop");
+
+ var backdrop = document.createElement('div');
+ backdrop.classList.add('dialogBackdrop');
+
var backdropParent = dlg.dialogContainer || dlg;
- backdropParent.parentNode.insertBefore(backdrop, backdropParent), dlg.backdrop = backdrop, backdrop.offsetWidth, backdrop.classList.add("dialogBackdropOpened"), dom.addEventListener(dlg.dialogContainer || backdrop, "click", function(e) {
- e.target === dlg.dialogContainer && close(dlg)
+ backdropParent.parentNode.insertBefore(backdrop, backdropParent);
+ dlg.backdrop = backdrop;
+
+ // trigger reflow or the backdrop will not animate
+ void backdrop.offsetWidth;
+ backdrop.classList.add('dialogBackdropOpened');
+
+ dom.addEventListener((dlg.dialogContainer || backdrop), 'click', function (e) {
+ if (e.target === dlg.dialogContainer) {
+ close(dlg);
+ }
}, {
- passive: !0
- })
+ passive: true
+ });
}
function isHistoryEnabled(dlg) {
- return "true" === dlg.getAttribute("data-history")
+ return dlg.getAttribute('data-history') === 'true';
}
function open(dlg) {
- globalOnOpenCallback && globalOnOpenCallback(dlg);
+
+ if (globalOnOpenCallback) {
+ globalOnOpenCallback(dlg);
+ }
+
var parent = dlg.parentNode;
- parent && parent.removeChild(dlg);
- var dialogContainer = document.createElement("div");
- return dialogContainer.classList.add("dialogContainer"), dialogContainer.appendChild(dlg), dlg.dialogContainer = dialogContainer, document.body.appendChild(dialogContainer), new Promise(function(resolve, reject) {
- new DialogHashHandler(dlg, "dlg" + (new Date).getTime(), resolve)
- })
+ if (parent) {
+ parent.removeChild(dlg);
+ }
+
+ var dialogContainer = document.createElement('div');
+ dialogContainer.classList.add('dialogContainer');
+ dialogContainer.appendChild(dlg);
+ dlg.dialogContainer = dialogContainer;
+ document.body.appendChild(dialogContainer);
+
+ return new Promise(function (resolve, reject) {
+
+ new DialogHashHandler(dlg, 'dlg' + new Date().getTime(), resolve);
+ });
}
function isOpened(dlg) {
- return !dlg.classList.contains("hide")
+
+ //return dlg.opened;
+ return !dlg.classList.contains('hide');
}
function close(dlg) {
- isOpened(dlg) && (isHistoryEnabled(dlg) ? history.back() : closeDialog(dlg))
+
+ if (isOpened(dlg)) {
+ if (isHistoryEnabled(dlg)) {
+ history.back();
+ } else {
+ closeDialog(dlg);
+ }
+ }
}
function closeDialog(dlg) {
- if (!dlg.classList.contains("hide")) {
- dlg.dispatchEvent(new CustomEvent("closing", {
- bubbles: !1,
- cancelable: !1
+
+ if (!dlg.classList.contains('hide')) {
+
+ dlg.dispatchEvent(new CustomEvent('closing', {
+ bubbles: false,
+ cancelable: false
}));
- animateDialogClose(dlg, function() {
- focusManager.popScope(dlg), dlg.classList.add("hide"), dlg.dispatchEvent(new CustomEvent("close", {
- bubbles: !1,
- cancelable: !1
- }))
- })
+
+ var onAnimationFinish = function () {
+ focusManager.popScope(dlg);
+
+ dlg.classList.add('hide');
+ dlg.dispatchEvent(new CustomEvent('close', {
+ bubbles: false,
+ cancelable: false
+ }));
+ };
+
+ animateDialogClose(dlg, onAnimationFinish);
}
}
function animateDialogOpen(dlg) {
- var onAnimationFinish = function() {
- focusManager.pushScope(dlg), "true" === dlg.getAttribute("data-autofocus") && focusManager.autoFocus(dlg)
+
+ var onAnimationFinish = function () {
+ focusManager.pushScope(dlg);
+ if (dlg.getAttribute('data-autofocus') === 'true') {
+ focusManager.autoFocus(dlg);
+ }
};
+
if (enableAnimation()) {
- var onFinish = function() {
+
+ var onFinish = function () {
dom.removeEventListener(dlg, dom.whichAnimationEvent(), onFinish, {
- once: !0
- }), onAnimationFinish()
+ once: true
+ });
+ onAnimationFinish();
};
- return void dom.addEventListener(dlg, dom.whichAnimationEvent(), onFinish, {
- once: !0
- })
+ dom.addEventListener(dlg, dom.whichAnimationEvent(), onFinish, {
+ once: true
+ });
+ return;
}
- onAnimationFinish()
+
+ onAnimationFinish();
}
function animateDialogClose(dlg, onAnimationFinish) {
+
if (enableAnimation()) {
- var animated = !0;
+
+ var animated = true;
+
switch (dlg.animationConfig.exit.name) {
- case "fadeout":
- dlg.style.animation = "fadeout " + dlg.animationConfig.exit.timing.duration + "ms ease-out normal both";
+
+ case 'fadeout':
+ dlg.style.animation = 'fadeout ' + dlg.animationConfig.exit.timing.duration + 'ms ease-out normal both';
break;
- case "scaledown":
- dlg.style.animation = "scaledown " + dlg.animationConfig.exit.timing.duration + "ms ease-out normal both";
+ case 'scaledown':
+ dlg.style.animation = 'scaledown ' + dlg.animationConfig.exit.timing.duration + 'ms ease-out normal both';
break;
- case "slidedown":
- dlg.style.animation = "slidedown " + dlg.animationConfig.exit.timing.duration + "ms ease-out normal both";
+ case 'slidedown':
+ dlg.style.animation = 'slidedown ' + dlg.animationConfig.exit.timing.duration + 'ms ease-out normal both';
break;
default:
- animated = !1
+ animated = false;
+ break;
}
- var onFinish = function() {
+ var onFinish = function () {
dom.removeEventListener(dlg, dom.whichAnimationEvent(), onFinish, {
- once: !0
- }), onAnimationFinish()
+ once: true
+ });
+ onAnimationFinish();
};
- if (dom.addEventListener(dlg, dom.whichAnimationEvent(), onFinish, {
- once: !0
- }), animated) return
+ dom.addEventListener(dlg, dom.whichAnimationEvent(), onFinish, {
+ once: true
+ });
+
+ if (animated) {
+ return;
+ }
}
- onAnimationFinish()
+
+ onAnimationFinish();
}
+ var supportsOverscrollBehavior = 'overscroll-behavior-y' in document.body.style;
+
function shouldLockDocumentScroll(options) {
- return !(supportsOverscrollBehavior && (options.size || !browser.touch)) && (null != options.lockScroll ? options.lockScroll : "fullscreen" === options.size || (!!options.size || browser.touch))
+
+ if (supportsOverscrollBehavior && (options.size || !browser.touch)) {
+ return false;
+ }
+
+ if (options.lockScroll != null) {
+ return options.lockScroll;
+ }
+
+ if (options.size === 'fullscreen') {
+ return true;
+ }
+
+ if (options.size) {
+ return true;
+ }
+
+ return browser.touch;
}
function removeBackdrop(dlg) {
+
var backdrop = dlg.backdrop;
- if (backdrop) {
- dlg.backdrop = null;
- var onAnimationFinish = function() {
- tryRemoveElement(backdrop)
- };
- if (enableAnimation()) return backdrop.classList.remove("dialogBackdropOpened"), void setTimeout(onAnimationFinish, 300);
- onAnimationFinish()
+
+ if (!backdrop) {
+ return;
}
+
+ dlg.backdrop = null;
+
+ var onAnimationFinish = function () {
+ tryRemoveElement(backdrop);
+ };
+
+ if (enableAnimation()) {
+
+ backdrop.classList.remove('dialogBackdropOpened');
+
+ // this is not firing animatonend
+ setTimeout(onAnimationFinish, 300);
+ return;
+ }
+
+ onAnimationFinish();
}
function centerFocus(elem, horiz, on) {
- require(["scrollHelper"], function(scrollHelper) {
- var fn = on ? "on" : "off";
- scrollHelper.centerFocus[fn](elem, horiz)
- })
+ require(['scrollHelper'], function (scrollHelper) {
+ var fn = on ? 'on' : 'off';
+ scrollHelper.centerFocus[fn](elem, horiz);
+ });
}
function createDialog(options) {
+
options = options || {};
- var dlg = document.createElement("div");
- dlg.classList.add("focuscontainer"), dlg.classList.add("hide"), shouldLockDocumentScroll(options) && dlg.setAttribute("data-lockscroll", "true"), !1 !== options.enableHistory && appRouter.enableNativeHistory() && dlg.setAttribute("data-history", "true"), !1 !== options.modal && dlg.setAttribute("modal", "modal"), !1 !== options.autoFocus && dlg.setAttribute("data-autofocus", "true");
- var defaultEntryAnimation, defaultExitAnimation;
- defaultEntryAnimation = "scaleup", defaultExitAnimation = "scaledown";
- var entryAnimation = options.entryAnimation || defaultEntryAnimation,
- exitAnimation = options.exitAnimation || defaultExitAnimation,
- entryAnimationDuration = options.entryAnimationDuration || ("fullscreen" !== options.size ? 180 : 280),
- exitAnimationDuration = options.exitAnimationDuration || ("fullscreen" !== options.size ? 120 : 220);
- if (dlg.animationConfig = {
- entry: {
- name: entryAnimation,
- timing: {
- duration: entryAnimationDuration,
- easing: "ease-out"
- }
- },
- exit: {
- name: exitAnimation,
- timing: {
- duration: exitAnimationDuration,
- easing: "ease-out",
- fill: "both"
- }
- }
- }, dlg.classList.add("dialog"), options.scrollX ? (dlg.classList.add("scrollX"), dlg.classList.add("smoothScrollX"), layoutManager.tv && centerFocus(dlg, !0, !0)) : !1 !== options.scrollY && (dlg.classList.add("smoothScrollY"), layoutManager.tv && centerFocus(dlg, !1, !0)), options.removeOnClose && dlg.setAttribute("data-removeonclose", "true"), options.size && (dlg.classList.add("dialog-fixedSize"), dlg.classList.add("dialog-" + options.size)), enableAnimation()) switch (dlg.animationConfig.entry.name) {
- case "fadein":
- dlg.style.animation = "fadein " + entryAnimationDuration + "ms ease-out normal";
- break;
- case "scaleup":
- dlg.style.animation = "scaleup " + entryAnimationDuration + "ms ease-out normal both";
- break;
- case "slideup":
- dlg.style.animation = "slideup " + entryAnimationDuration + "ms ease-out normal";
- break;
- case "slidedown":
- dlg.style.animation = "slidedown " + entryAnimationDuration + "ms ease-out normal"
+
+ // If there's no native dialog support, use a plain div
+ // Also not working well in samsung tizen browser, content inside not clickable
+ // Just go ahead and always use a plain div because we're seeing issues overlaying absoltutely positioned content over a modal dialog
+ var dlg = document.createElement('div');
+
+ dlg.classList.add('focuscontainer');
+ dlg.classList.add('hide');
+
+ if (shouldLockDocumentScroll(options)) {
+ dlg.setAttribute('data-lockscroll', 'true');
}
- return dlg
+
+ if (options.enableHistory !== false && appRouter.enableNativeHistory()) {
+ dlg.setAttribute('data-history', 'true');
+ }
+
+ // without this safari will scroll the background instead of the dialog contents
+ // but not needed here since this is already on top of an existing dialog
+ // but skip it in IE because it's causing the entire browser to hang
+ // Also have to disable for firefox because it's causing select elements to not be clickable
+ if (options.modal !== false) {
+ dlg.setAttribute('modal', 'modal');
+ }
+
+ if (options.autoFocus !== false) {
+ dlg.setAttribute('data-autofocus', 'true');
+ }
+
+ var defaultEntryAnimation;
+ var defaultExitAnimation;
+
+ defaultEntryAnimation = 'scaleup';
+ defaultExitAnimation = 'scaledown';
+ var entryAnimation = options.entryAnimation || defaultEntryAnimation;
+ var exitAnimation = options.exitAnimation || defaultExitAnimation;
+
+ // If it's not fullscreen then lower the default animation speed to make it open really fast
+ var entryAnimationDuration = options.entryAnimationDuration || (options.size !== 'fullscreen' ? 180 : 280);
+ var exitAnimationDuration = options.exitAnimationDuration || (options.size !== 'fullscreen' ? 120 : 220);
+
+ dlg.animationConfig = {
+ // scale up
+ 'entry': {
+ name: entryAnimation,
+ timing: {
+ duration: entryAnimationDuration,
+ easing: 'ease-out'
+ }
+ },
+ // fade out
+ 'exit': {
+ name: exitAnimation,
+ timing: {
+ duration: exitAnimationDuration,
+ easing: 'ease-out',
+ fill: 'both'
+ }
+ }
+ };
+
+ dlg.classList.add('dialog');
+
+ if (options.scrollX) {
+ dlg.classList.add('scrollX');
+ dlg.classList.add('smoothScrollX');
+
+ if (layoutManager.tv) {
+ centerFocus(dlg, true, true);
+ }
+ }
+ else if (options.scrollY !== false) {
+ dlg.classList.add('smoothScrollY');
+
+ if (layoutManager.tv) {
+ centerFocus(dlg, false, true);
+ }
+ }
+
+ if (options.removeOnClose) {
+ dlg.setAttribute('data-removeonclose', 'true');
+ }
+
+ if (options.size) {
+ dlg.classList.add('dialog-fixedSize');
+ dlg.classList.add('dialog-' + options.size);
+ }
+
+ if (enableAnimation()) {
+
+ switch (dlg.animationConfig.entry.name) {
+
+ case 'fadein':
+ dlg.style.animation = 'fadein ' + entryAnimationDuration + 'ms ease-out normal';
+ break;
+ case 'scaleup':
+ dlg.style.animation = 'scaleup ' + entryAnimationDuration + 'ms ease-out normal both';
+ break;
+ case 'slideup':
+ dlg.style.animation = 'slideup ' + entryAnimationDuration + 'ms ease-out normal';
+ break;
+ case 'slidedown':
+ dlg.style.animation = 'slidedown ' + entryAnimationDuration + 'ms ease-out normal';
+ break;
+ default:
+ break;
+ }
+ }
+
+ return dlg;
}
- var globalOnOpenCallback, supportsOverscrollBehavior = "overscroll-behavior-y" in document.body.style;
+
return {
open: open,
close: close,
createDialog: createDialog,
- setOnOpen: function(val) {
- globalOnOpenCallback = val
+ setOnOpen: function (val) {
+ globalOnOpenCallback = val;
}
- }
+ };
});
\ No newline at end of file
diff --git a/src/bower_components/emby-webcomponents/displaysettings/displaysettings.js b/src/bower_components/emby-webcomponents/displaysettings/displaysettings.js
index 36158eaecc..90eaeba09e 100644
--- a/src/bower_components/emby-webcomponents/displaysettings/displaysettings.js
+++ b/src/bower_components/emby-webcomponents/displaysettings/displaysettings.js
@@ -1,122 +1,343 @@
-define(["require", "browser", "layoutManager", "appSettings", "pluginManager", "apphost", "focusManager", "datetime", "globalize", "loading", "connectionManager", "skinManager", "dom", "events", "emby-select", "emby-checkbox", "emby-linkbutton"], function(require, browser, layoutManager, appSettings, pluginManager, appHost, focusManager, datetime, globalize, loading, connectionManager, skinManager, dom, events) {
+define(['require', 'browser', 'layoutManager', 'appSettings', 'pluginManager', 'apphost', 'focusManager', 'datetime', 'globalize', 'loading', 'connectionManager', 'skinManager', 'dom', 'events', 'emby-select', 'emby-checkbox', 'emby-linkbutton'], function (require, browser, layoutManager, appSettings, pluginManager, appHost, focusManager, datetime, globalize, loading, connectionManager, skinManager, dom, events) {
"use strict";
function fillThemes(select, isDashboard) {
- select.innerHTML = skinManager.getThemes().map(function(t) {
+
+ select.innerHTML = skinManager.getThemes().map(function (t) {
+
var value = t.id;
- return t.isDefault && !isDashboard ? value = "" : t.isDefaultServerDashboard && isDashboard && (value = ""), '
' + t.name + " "
- }).join("")
+
+ if (t.isDefault && !isDashboard) {
+ value = '';
+ }
+ else if (t.isDefaultServerDashboard && isDashboard) {
+ value = '';
+ }
+
+ return '
' + t.name + ' ';
+
+ }).join('');
}
function loadScreensavers(context, userSettings) {
- var selectScreensaver = context.querySelector(".selectScreensaver"),
- options = pluginManager.ofType("screensaver").map(function(plugin) {
- return {
- name: plugin.name,
- value: plugin.id
- }
- });
+
+ var selectScreensaver = context.querySelector('.selectScreensaver');
+ var options = pluginManager.ofType('screensaver').map(function (plugin) {
+ return {
+ name: plugin.name,
+ value: plugin.id
+ };
+ });
+
options.unshift({
- name: globalize.translate("sharedcomponents#None"),
- value: "none"
- }), selectScreensaver.innerHTML = options.map(function(o) {
- return '
' + o.name + " "
- }).join(""), selectScreensaver.value = userSettings.screensaver(), selectScreensaver.value || (selectScreensaver.value = "none")
+ name: globalize.translate('sharedcomponents#None'),
+ value: 'none'
+ });
+
+ selectScreensaver.innerHTML = options.map(function (o) {
+ return '
' + o.name + ' ';
+ }).join('');
+ selectScreensaver.value = userSettings.screensaver();
+
+ if (!selectScreensaver.value) {
+ // TODO: set the default instead of none
+ selectScreensaver.value = 'none';
+ }
}
function loadSoundEffects(context, userSettings) {
- var selectSoundEffects = context.querySelector(".selectSoundEffects"),
- options = pluginManager.ofType("soundeffects").map(function(plugin) {
- return {
- name: plugin.name,
- value: plugin.id
- }
- });
+
+ var selectSoundEffects = context.querySelector('.selectSoundEffects');
+ var options = pluginManager.ofType('soundeffects').map(function (plugin) {
+ return {
+ name: plugin.name,
+ value: plugin.id
+ };
+ });
+
options.unshift({
- name: globalize.translate("sharedcomponents#None"),
- value: "none"
- }), selectSoundEffects.innerHTML = options.map(function(o) {
- return '
' + o.name + " "
- }).join(""), selectSoundEffects.value = userSettings.soundEffects(), selectSoundEffects.value || (selectSoundEffects.value = "none")
+ name: globalize.translate('sharedcomponents#None'),
+ value: 'none'
+ });
+
+ selectSoundEffects.innerHTML = options.map(function (o) {
+ return '
' + o.name + ' ';
+ }).join('');
+ selectSoundEffects.value = userSettings.soundEffects();
+
+ if (!selectSoundEffects.value) {
+ // TODO: set the default instead of none
+ selectSoundEffects.value = 'none';
+ }
}
function loadSkins(context, userSettings) {
- var selectSkin = context.querySelector(".selectSkin"),
- options = pluginManager.ofType("skin").map(function(plugin) {
- return {
- name: plugin.name,
- value: plugin.id
- }
- });
- selectSkin.innerHTML = options.map(function(o) {
- return '
' + o.name + " "
- }).join(""), selectSkin.value = userSettings.skin(), !selectSkin.value && options.length && (selectSkin.value = options[0].value), options.length > 1 && appHost.supports("skins") ? context.querySelector(".selectSkinContainer").classList.remove("hide") : context.querySelector(".selectSkinContainer").classList.add("hide")
+
+ var selectSkin = context.querySelector('.selectSkin');
+
+ var options = pluginManager.ofType('skin').map(function (plugin) {
+ return {
+ name: plugin.name,
+ value: plugin.id
+ };
+ });
+
+ selectSkin.innerHTML = options.map(function (o) {
+ return '
' + o.name + ' ';
+ }).join('');
+ selectSkin.value = userSettings.skin();
+
+ if (!selectSkin.value && options.length) {
+ selectSkin.value = options[0].value;
+ }
+
+ if (options.length > 1 && appHost.supports('skins')) {
+ context.querySelector('.selectSkinContainer').classList.remove('hide');
+ } else {
+ context.querySelector('.selectSkinContainer').classList.add('hide');
+ }
}
function showOrHideMissingEpisodesField(context, user, apiClient) {
- if (browser.tizen || browser.web0s) return void context.querySelector(".fldDisplayMissingEpisodes").classList.add("hide");
- context.querySelector(".fldDisplayMissingEpisodes").classList.remove("hide")
+
+ if (browser.tizen || browser.web0s) {
+ context.querySelector('.fldDisplayMissingEpisodes').classList.add('hide');
+ return;
+ }
+
+ context.querySelector('.fldDisplayMissingEpisodes').classList.remove('hide');
}
function loadForm(context, user, userSettings, apiClient) {
- apiClient.getCurrentUserId(), user.Id;
- user.Policy.IsAdministrator ? context.querySelector(".selectDashboardThemeContainer").classList.remove("hide") : context.querySelector(".selectDashboardThemeContainer").classList.add("hide"), appHost.supports("displaylanguage") ? context.querySelector(".languageSection").classList.remove("hide") : context.querySelector(".languageSection").classList.add("hide"), appHost.supports("displaymode") ? context.querySelector(".fldDisplayMode").classList.remove("hide") : context.querySelector(".fldDisplayMode").classList.add("hide"), appHost.supports("externallinks") ? context.querySelector(".learnHowToContributeContainer").classList.remove("hide") : context.querySelector(".learnHowToContributeContainer").classList.add("hide"), appHost.supports("runatstartup") ? context.querySelector(".fldAutorun").classList.remove("hide") : context.querySelector(".fldAutorun").classList.add("hide"), appHost.supports("soundeffects") ? context.querySelector(".fldSoundEffects").classList.remove("hide") : context.querySelector(".fldSoundEffects").classList.add("hide"), appHost.supports("screensaver") ? context.querySelector(".selectScreensaverContainer").classList.remove("hide") : context.querySelector(".selectScreensaverContainer").classList.add("hide"), datetime.supportsLocalization() ? context.querySelector(".fldDateTimeLocale").classList.remove("hide") : context.querySelector(".fldDateTimeLocale").classList.add("hide"), browser.tizen || browser.web0s ? (context.querySelector(".fldSeasonalThemes").classList.add("hide"), context.querySelector(".fldBackdrops").classList.add("hide"), context.querySelector(".fldThemeSong").classList.add("hide"), context.querySelector(".fldThemeVideo").classList.add("hide")) : (context.querySelector(".fldSeasonalThemes").classList.remove("hide"), context.querySelector(".fldBackdrops").classList.remove("hide"), context.querySelector(".fldThemeSong").classList.remove("hide"), context.querySelector(".fldThemeVideo").classList.remove("hide")), context.querySelector(".chkRunAtStartup").checked = appSettings.runAtStartup();
- var selectTheme = context.querySelector("#selectTheme"),
- selectDashboardTheme = context.querySelector("#selectDashboardTheme");
- fillThemes(selectTheme), fillThemes(selectDashboardTheme, !0), loadScreensavers(context, userSettings), loadSoundEffects(context, userSettings), loadSkins(context, userSettings), context.querySelector(".chkDisplayMissingEpisodes").checked = user.Configuration.DisplayMissingEpisodes || !1, context.querySelector("#chkThemeSong").checked = userSettings.enableThemeSongs(), context.querySelector("#chkThemeVideo").checked = userSettings.enableThemeVideos(), context.querySelector("#chkBackdrops").checked = userSettings.enableBackdrops(), context.querySelector("#chkSeasonalThemes").checked = userSettings.enableSeasonalThemes(), context.querySelector("#selectLanguage").value = userSettings.language() || "", context.querySelector(".selectDateTimeLocale").value = userSettings.dateTimeLocale() || "", selectDashboardTheme.value = userSettings.dashboardTheme() || "", selectTheme.value = userSettings.theme() || "", context.querySelector(".selectLayout").value = layoutManager.getSavedLayout() || "", showOrHideMissingEpisodesField(context, user, apiClient), loading.hide()
+
+ var loggedInUserId = apiClient.getCurrentUserId();
+ var userId = user.Id;
+
+ if (user.Policy.IsAdministrator) {
+ context.querySelector('.selectDashboardThemeContainer').classList.remove('hide');
+ } else {
+ context.querySelector('.selectDashboardThemeContainer').classList.add('hide');
+ }
+
+ if (appHost.supports('displaylanguage')) {
+ context.querySelector('.languageSection').classList.remove('hide');
+ } else {
+ context.querySelector('.languageSection').classList.add('hide');
+ }
+
+ if (appHost.supports('displaymode')) {
+ context.querySelector('.fldDisplayMode').classList.remove('hide');
+ } else {
+ context.querySelector('.fldDisplayMode').classList.add('hide');
+ }
+
+ if (appHost.supports('externallinks')) {
+ context.querySelector('.learnHowToContributeContainer').classList.remove('hide');
+ } else {
+ context.querySelector('.learnHowToContributeContainer').classList.add('hide');
+ }
+
+ if (appHost.supports('runatstartup')) {
+ context.querySelector('.fldAutorun').classList.remove('hide');
+ } else {
+ context.querySelector('.fldAutorun').classList.add('hide');
+ }
+
+ if (appHost.supports('soundeffects')) {
+ context.querySelector('.fldSoundEffects').classList.remove('hide');
+ } else {
+ context.querySelector('.fldSoundEffects').classList.add('hide');
+ }
+
+ if (appHost.supports('screensaver')) {
+ context.querySelector('.selectScreensaverContainer').classList.remove('hide');
+ } else {
+ context.querySelector('.selectScreensaverContainer').classList.add('hide');
+ }
+
+ if (datetime.supportsLocalization()) {
+ context.querySelector('.fldDateTimeLocale').classList.remove('hide');
+ } else {
+ context.querySelector('.fldDateTimeLocale').classList.add('hide');
+ }
+
+ if (!browser.tizen && !browser.web0s) {
+ context.querySelector('.fldSeasonalThemes').classList.remove('hide');
+ context.querySelector('.fldBackdrops').classList.remove('hide');
+ context.querySelector('.fldThemeSong').classList.remove('hide');
+ context.querySelector('.fldThemeVideo').classList.remove('hide');
+ } else {
+ context.querySelector('.fldSeasonalThemes').classList.add('hide');
+ context.querySelector('.fldBackdrops').classList.add('hide');
+ context.querySelector('.fldThemeSong').classList.add('hide');
+ context.querySelector('.fldThemeVideo').classList.add('hide');
+ }
+
+ context.querySelector('.chkRunAtStartup').checked = appSettings.runAtStartup();
+
+ var selectTheme = context.querySelector('#selectTheme');
+ var selectDashboardTheme = context.querySelector('#selectDashboardTheme');
+
+ fillThemes(selectTheme);
+ fillThemes(selectDashboardTheme, true);
+ loadScreensavers(context, userSettings);
+ loadSoundEffects(context, userSettings);
+ loadSkins(context, userSettings);
+
+ context.querySelector('.chkDisplayMissingEpisodes').checked = user.Configuration.DisplayMissingEpisodes || false;
+
+ context.querySelector('#chkThemeSong').checked = userSettings.enableThemeSongs();
+ context.querySelector('#chkThemeVideo').checked = userSettings.enableThemeVideos();
+ context.querySelector('#chkBackdrops').checked = userSettings.enableBackdrops();
+ context.querySelector('#chkSeasonalThemes').checked = userSettings.enableSeasonalThemes();
+
+ context.querySelector('#selectLanguage').value = userSettings.language() || '';
+ context.querySelector('.selectDateTimeLocale').value = userSettings.dateTimeLocale() || '';
+
+ selectDashboardTheme.value = userSettings.dashboardTheme() || '';
+ selectTheme.value = userSettings.theme() || '';
+
+ context.querySelector('.selectLayout').value = layoutManager.getSavedLayout() || '';
+
+ showOrHideMissingEpisodesField(context, user, apiClient);
+
+ loading.hide();
}
function saveUser(context, user, userSettingsInstance, apiClient) {
- return appSettings.runAtStartup(context.querySelector(".chkRunAtStartup").checked), user.Configuration.DisplayMissingEpisodes = context.querySelector(".chkDisplayMissingEpisodes").checked, appHost.supports("displaylanguage") && userSettingsInstance.language(context.querySelector("#selectLanguage").value), userSettingsInstance.dateTimeLocale(context.querySelector(".selectDateTimeLocale").value), userSettingsInstance.enableThemeSongs(context.querySelector("#chkThemeSong").checked), userSettingsInstance.enableThemeVideos(context.querySelector("#chkThemeVideo").checked), userSettingsInstance.dashboardTheme(context.querySelector("#selectDashboardTheme").value), userSettingsInstance.theme(context.querySelector("#selectTheme").value), userSettingsInstance.soundEffects(context.querySelector(".selectSoundEffects").value), userSettingsInstance.screensaver(context.querySelector(".selectScreensaver").value), userSettingsInstance.skin(context.querySelector(".selectSkin").value), userSettingsInstance.enableBackdrops(context.querySelector("#chkBackdrops").checked), userSettingsInstance.enableSeasonalThemes(context.querySelector("#chkSeasonalThemes").checked), user.Id === apiClient.getCurrentUserId() && skinManager.setTheme(userSettingsInstance.theme()), layoutManager.setLayout(context.querySelector(".selectLayout").value), apiClient.updateUserConfiguration(user.Id, user.Configuration)
+
+ appSettings.runAtStartup(context.querySelector('.chkRunAtStartup').checked);
+
+ user.Configuration.DisplayMissingEpisodes = context.querySelector('.chkDisplayMissingEpisodes').checked;
+
+ if (appHost.supports('displaylanguage')) {
+ userSettingsInstance.language(context.querySelector('#selectLanguage').value);
+ }
+
+ userSettingsInstance.dateTimeLocale(context.querySelector('.selectDateTimeLocale').value);
+
+ userSettingsInstance.enableThemeSongs(context.querySelector('#chkThemeSong').checked);
+ userSettingsInstance.enableThemeVideos(context.querySelector('#chkThemeVideo').checked);
+ userSettingsInstance.dashboardTheme(context.querySelector('#selectDashboardTheme').value);
+ userSettingsInstance.theme(context.querySelector('#selectTheme').value);
+ userSettingsInstance.soundEffects(context.querySelector('.selectSoundEffects').value);
+ userSettingsInstance.screensaver(context.querySelector('.selectScreensaver').value);
+
+ userSettingsInstance.skin(context.querySelector('.selectSkin').value);
+
+ userSettingsInstance.enableBackdrops(context.querySelector('#chkBackdrops').checked);
+ userSettingsInstance.enableSeasonalThemes(context.querySelector('#chkSeasonalThemes').checked);
+
+ if (user.Id === apiClient.getCurrentUserId()) {
+
+ skinManager.setTheme(userSettingsInstance.theme());
+ }
+
+ layoutManager.setLayout(context.querySelector('.selectLayout').value);
+
+ return apiClient.updateUserConfiguration(user.Id, user.Configuration);
}
function save(instance, context, userId, userSettings, apiClient, enableSaveConfirmation) {
- loading.show(), apiClient.getUser(userId).then(function(user) {
- saveUser(context, user, userSettings, apiClient).then(function() {
- loading.hide(), enableSaveConfirmation && require(["toast"], function(toast) {
- toast(globalize.translate("sharedcomponents#SettingsSaved"))
- }), events.trigger(instance, "saved")
- }, function() {
- loading.hide()
- })
- })
+
+ loading.show();
+
+ apiClient.getUser(userId).then(function (user) {
+
+ saveUser(context, user, userSettings, apiClient).then(function () {
+
+ loading.hide();
+ if (enableSaveConfirmation) {
+ require(['toast'], function (toast) {
+ toast(globalize.translate('sharedcomponents#SettingsSaved'));
+ });
+ }
+
+ events.trigger(instance, 'saved');
+
+ }, function () {
+ loading.hide();
+ });
+ });
}
function onSubmit(e) {
- var self = this,
- apiClient = connectionManager.getApiClient(self.options.serverId),
- userId = self.options.userId,
- userSettings = self.options.userSettings;
- return userSettings.setUserInfo(userId, apiClient).then(function() {
+
+ var self = this;
+ var apiClient = connectionManager.getApiClient(self.options.serverId);
+ var userId = self.options.userId;
+ var userSettings = self.options.userSettings;
+
+ userSettings.setUserInfo(userId, apiClient).then(function () {
+
var enableSaveConfirmation = self.options.enableSaveConfirmation;
- save(self, self.options.element, userId, userSettings, apiClient, enableSaveConfirmation)
- }), e && e.preventDefault(), !1
+ save(self, self.options.element, userId, userSettings, apiClient, enableSaveConfirmation);
+ });
+
+ // Disable default form submission
+ if (e) {
+ e.preventDefault();
+ }
+ return false;
}
function embed(options, self) {
- require(["text!./displaysettings.template.html"], function(template) {
- options.element.innerHTML = globalize.translateDocument(template, "sharedcomponents"), options.element.querySelector("form").addEventListener("submit", onSubmit.bind(self)), options.enableSaveButton && options.element.querySelector(".btnSave").classList.remove("hide"), self.loadData(options.autoFocus)
- })
+
+ require(['text!./displaysettings.template.html'], function (template) {
+
+ options.element.innerHTML = globalize.translateDocument(template, 'sharedcomponents');
+
+ options.element.querySelector('form').addEventListener('submit', onSubmit.bind(self));
+
+ if (options.enableSaveButton) {
+ options.element.querySelector('.btnSave').classList.remove('hide');
+ }
+
+ self.loadData(options.autoFocus);
+ });
}
function DisplaySettings(options) {
- this.options = options, embed(options, this)
+
+ this.options = options;
+
+ embed(options, this);
}
- return DisplaySettings.prototype.loadData = function(autoFocus) {
- var self = this,
- context = self.options.element;
+
+ DisplaySettings.prototype.loadData = function (autoFocus) {
+
+ var self = this;
+ var context = self.options.element;
+
loading.show();
- var userId = self.options.userId,
- apiClient = connectionManager.getApiClient(self.options.serverId),
- userSettings = self.options.userSettings;
- return apiClient.getUser(userId).then(function(user) {
- return userSettings.setUserInfo(userId, apiClient).then(function() {
- self.dataLoaded = !0, loadForm(context, user, userSettings, apiClient), autoFocus && focusManager.autoFocus(context)
- })
- })
- }, DisplaySettings.prototype.submit = function() {
- onSubmit.call(this)
- }, DisplaySettings.prototype.destroy = function() {
- this.options = null
- }, DisplaySettings
+
+ var userId = self.options.userId;
+ var apiClient = connectionManager.getApiClient(self.options.serverId);
+ var userSettings = self.options.userSettings;
+
+ return apiClient.getUser(userId).then(function (user) {
+
+ return userSettings.setUserInfo(userId, apiClient).then(function () {
+
+ self.dataLoaded = true;
+
+ loadForm(context, user, userSettings, apiClient);
+
+ if (autoFocus) {
+ focusManager.autoFocus(context);
+ }
+ });
+ });
+ };
+
+ DisplaySettings.prototype.submit = function () {
+ onSubmit.call(this);
+ };
+
+ DisplaySettings.prototype.destroy = function () {
+
+ this.options = null;
+ };
+
+ return DisplaySettings;
});
\ No newline at end of file
diff --git a/src/bower_components/emby-webcomponents/dom.js b/src/bower_components/emby-webcomponents/dom.js
index cbc85e28a4..ea8902b98e 100644
--- a/src/bower_components/emby-webcomponents/dom.js
+++ b/src/bower_components/emby-webcomponents/dom.js
@@ -1,96 +1,170 @@
-define([], function() {
- "use strict";
+define([], function () {
+ 'use strict';
function parentWithAttribute(elem, name, value) {
- for (; value ? elem.getAttribute(name) !== value : !elem.getAttribute(name);)
- if (!(elem = elem.parentNode) || !elem.getAttribute) return null;
- return elem
+
+ while ((value ? elem.getAttribute(name) !== value : !elem.getAttribute(name))) {
+ elem = elem.parentNode;
+
+ if (!elem || !elem.getAttribute) {
+ return null;
+ }
+ }
+
+ return elem;
}
function parentWithTag(elem, tagNames) {
- for (Array.isArray(tagNames) || (tagNames = [tagNames]); - 1 === tagNames.indexOf(elem.tagName || "");)
- if (!(elem = elem.parentNode)) return null;
- return elem
+
+ // accept both string and array passed in
+ if (!Array.isArray(tagNames)) {
+ tagNames = [tagNames];
+ }
+
+ while (tagNames.indexOf(elem.tagName || '') === -1) {
+ elem = elem.parentNode;
+
+ if (!elem) {
+ return null;
+ }
+ }
+
+ return elem;
}
function containsAnyClass(classList, classNames) {
- for (var i = 0, length = classNames.length; i < length; i++)
- if (classList.contains(classNames[i])) return !0;
- return !1
+
+ for (var i = 0, length = classNames.length; i < length; i++) {
+ if (classList.contains(classNames[i])) {
+ return true;
+ }
+ }
+ return false;
}
function parentWithClass(elem, classNames) {
- for (Array.isArray(classNames) || (classNames = [classNames]); !elem.classList || !containsAnyClass(elem.classList, classNames);)
- if (!(elem = elem.parentNode)) return null;
- return elem
+
+ // accept both string and array passed in
+ if (!Array.isArray(classNames)) {
+ classNames = [classNames];
+ }
+
+ while (!elem.classList || !containsAnyClass(elem.classList, classNames)) {
+ elem = elem.parentNode;
+
+ if (!elem) {
+ return null;
+ }
+ }
+
+ return elem;
}
+ var supportsCaptureOption = false;
+ try {
+ var opts = Object.defineProperty({}, 'capture', {
+ get: function () {
+ supportsCaptureOption = true;
+ }
+ });
+ window.addEventListener("test", null, opts);
+ } catch (e) { }
+
function addEventListenerWithOptions(target, type, handler, options) {
var optionsOrCapture = options;
- supportsCaptureOption || (optionsOrCapture = options.capture), target.addEventListener(type, handler, optionsOrCapture)
+ if (!supportsCaptureOption) {
+ optionsOrCapture = options.capture;
+ }
+ target.addEventListener(type, handler, optionsOrCapture);
}
function removeEventListenerWithOptions(target, type, handler, options) {
var optionsOrCapture = options;
- supportsCaptureOption || (optionsOrCapture = options.capture), target.removeEventListener(type, handler, optionsOrCapture)
+ if (!supportsCaptureOption) {
+ optionsOrCapture = options.capture;
+ }
+ target.removeEventListener(type, handler, optionsOrCapture);
}
+ var windowSize;
+ var windowSizeEventsBound;
function clearWindowSize() {
- windowSize = null
+ windowSize = null;
}
function getWindowSize() {
- return windowSize || (windowSize = {
- innerHeight: window.innerHeight,
- innerWidth: window.innerWidth
- }, windowSizeEventsBound || (windowSizeEventsBound = !0, addEventListenerWithOptions(window, "orientationchange", clearWindowSize, {
- passive: !0
- }), addEventListenerWithOptions(window, "resize", clearWindowSize, {
- passive: !0
- }))), windowSize
+ if (!windowSize) {
+ windowSize = {
+ innerHeight: window.innerHeight,
+ innerWidth: window.innerWidth
+ };
+
+ if (!windowSizeEventsBound) {
+ windowSizeEventsBound = true;
+ addEventListenerWithOptions(window, "orientationchange", clearWindowSize, { passive: true });
+ addEventListenerWithOptions(window, 'resize', clearWindowSize, { passive: true });
+ }
+ }
+
+ return windowSize;
}
+ var _animationEvent;
function whichAnimationEvent() {
- if (_animationEvent) return _animationEvent;
- var t, el = document.createElement("div"),
- animations = {
- animation: "animationend",
- OAnimation: "oAnimationEnd",
- MozAnimation: "animationend",
- WebkitAnimation: "webkitAnimationEnd"
- };
- for (t in animations)
- if (void 0 !== el.style[t]) return _animationEvent = animations[t], animations[t];
- return _animationEvent = "animationend"
+
+ if (_animationEvent) {
+ return _animationEvent;
+ }
+
+ var t,
+ el = document.createElement("div");
+ var animations = {
+ "animation": "animationend",
+ "OAnimation": "oAnimationEnd",
+ "MozAnimation": "animationend",
+ "WebkitAnimation": "webkitAnimationEnd"
+ };
+ for (t in animations) {
+ if (el.style[t] !== undefined) {
+ _animationEvent = animations[t];
+ return animations[t];
+ }
+ }
+
+ _animationEvent = 'animationend';
+ return _animationEvent;
}
function whichAnimationCancelEvent() {
- return whichAnimationEvent().replace("animationend", "animationcancel").replace("AnimationEnd", "AnimationCancel")
+
+ return whichAnimationEvent().replace('animationend', 'animationcancel').replace('AnimationEnd', 'AnimationCancel');
}
+ var _transitionEvent;
function whichTransitionEvent() {
- if (_transitionEvent) return _transitionEvent;
- var t, el = document.createElement("div"),
- transitions = {
- transition: "transitionend",
- OTransition: "oTransitionEnd",
- MozTransition: "transitionend",
- WebkitTransition: "webkitTransitionEnd"
- };
- for (t in transitions)
- if (void 0 !== el.style[t]) return _transitionEvent = transitions[t], transitions[t];
- return _transitionEvent = "transitionend"
- }
- var supportsCaptureOption = !1;
- try {
- var opts = Object.defineProperty({}, "capture", {
- get: function() {
- supportsCaptureOption = !0
+ if (_transitionEvent) {
+ return _transitionEvent;
+ }
+
+ var t,
+ el = document.createElement("div");
+ var transitions = {
+ "transition": "transitionend",
+ "OTransition": "oTransitionEnd",
+ "MozTransition": "transitionend",
+ "WebkitTransition": "webkitTransitionEnd"
+ };
+ for (t in transitions) {
+ if (el.style[t] !== undefined) {
+ _transitionEvent = transitions[t];
+ return transitions[t];
}
- });
- window.addEventListener("test", null, opts)
- } catch (e) {}
- var windowSize, windowSizeEventsBound, _animationEvent, _transitionEvent;
+ }
+
+ _transitionEvent = 'transitionend';
+ return _transitionEvent;
+ }
+
return {
parentWithAttribute: parentWithAttribute,
parentWithClass: parentWithClass,
@@ -101,5 +175,5 @@ define([], function() {
whichTransitionEvent: whichTransitionEvent,
whichAnimationEvent: whichAnimationEvent,
whichAnimationCancelEvent: whichAnimationCancelEvent
- }
+ };
});
\ No newline at end of file
diff --git a/src/bower_components/emby-webcomponents/emby-button/emby-button.css b/src/bower_components/emby-webcomponents/emby-button/emby-button.css
index 2147405eff..90807d2a8b 100644
--- a/src/bower_components/emby-webcomponents/emby-button/emby-button.css
+++ b/src/bower_components/emby-webcomponents/emby-button/emby-button.css
@@ -1,33 +1,14 @@
-.emby-button,
-.fab {
- -webkit-box-sizing: border-box;
- -webkit-box-align: center
-}
-
-.button-flat,
-.button-link {
- background: 0 0
-}
-
-.emby-button,
-.paper-icon-button-light {
- text-align: center;
- font-family: inherit;
- color: inherit;
- outline: 0 !important;
- -webkit-tap-highlight-color: transparent;
- position: relative
-}
-
.emby-button {
- display: -webkit-inline-box;
- display: -webkit-inline-flex;
+ position: relative;
display: inline-flex;
- -webkit-align-items: center;
align-items: center;
box-sizing: border-box;
margin: 0 .29em;
+ text-align: center;
font-size: inherit;
+ font-family: inherit;
+ color: inherit;
+ outline-width: 0;
-moz-user-select: none;
-ms-user-select: none;
-webkit-user-select: none;
@@ -35,99 +16,98 @@
cursor: pointer;
z-index: 0;
padding: .86em 1em;
+ vertical-align: middle;
border: 0;
vertical-align: middle;
- -webkit-border-radius: .2em;
border-radius: .2em;
+ /* These are getting an outline in opera tv browsers, which run chrome 30 */
+ outline: none !important;
+ position: relative;
font-weight: 600;
+ /* Disable webkit tap highlighting */
+ -webkit-tap-highlight-color: rgba(0,0,0,0);
text-decoration: none;
- line-height: 1.35
+
+ /* Not crazy about this but it normalizes heights between anchors and buttons */
+ line-height: 1.35;
}
.emby-button::-moz-focus-inner {
- border: 0
+ border: 0;
}
-.button-flat:hover {
- opacity: .5
+.button-flat {
+ background: transparent;
}
+ .button-flat:hover {
+ opacity: .5;
+ }
+
.button-link {
+ background: transparent;
margin: 0;
padding: 0;
- vertical-align: initial
+ vertical-align: initial;
}
.button-link-inline {
- display: inline
+ display: inline;
}
.button-link:hover {
- text-decoration: underline
+ text-decoration: underline;
}
.emby-button-focusscale {
- -webkit-transition: -webkit-transform 180ms ease-out !important;
- -o-transition: transform 180ms ease-out !important;
transition: transform 180ms ease-out !important;
-webkit-transform-origin: center center;
- transform-origin: center center
+ transform-origin: center center;
}
-.emby-button-focusscale:focus {
- -webkit-transform: scale(1.16);
- transform: scale(1.16);
- z-index: 1
+ .emby-button-focusscale:focus {
+ transform: scale(1.16);
+ z-index: 1;
+ }
+
+.emby-button > i {
+ /* For non-fab buttons that have icons */
+ font-size: 1.36em;
}
-.emby-button>i {
- font-size: 1.36em
-}
-
-.button-link>i {
- font-size: 1em
+.button-link > i {
+ font-size: 1em;
}
.fab {
- display: -webkit-inline-box;
- display: -webkit-inline-flex;
display: inline-flex;
- -webkit-border-radius: 50%;
border-radius: 50%;
padding: .6em;
box-sizing: border-box;
- -webkit-align-items: center;
align-items: center;
- -webkit-box-pack: center;
- -webkit-justify-content: center;
justify-content: center;
- text-align: center
+ text-align: center;
}
.emby-button.block {
display: block;
- -webkit-box-align: center;
- -webkit-align-items: center;
align-items: center;
- -webkit-box-pack: center;
- -webkit-justify-content: center;
justify-content: center;
margin: .25em 0;
- width: 100%
+ width: 100%;
}
.paper-icon-button-light {
- display: -webkit-inline-box;
- display: -webkit-inline-flex;
+ position: relative;
display: inline-flex;
- -webkit-box-align: center;
- -webkit-align-items: center;
align-items: center;
- -webkit-box-sizing: border-box;
box-sizing: border-box;
margin: 0 .29em;
- background: 0 0;
+ background: transparent;
+ text-align: center;
font-size: inherit;
+ font-family: inherit;
+ color: inherit;
-moz-user-select: none;
-ms-user-select: none;
-webkit-user-select: none;
@@ -139,84 +119,82 @@
width: auto;
height: auto;
padding: .556em;
+ vertical-align: middle;
border: 0;
vertical-align: middle;
+ /* These are getting an outline in opera tv browsers, which run chrome 30 */
+ outline: none !important;
+ position: relative;
overflow: hidden;
- -webkit-border-radius: 50%;
border-radius: 50%;
- -webkit-box-pack: center;
- -webkit-justify-content: center;
- justify-content: center
+ /* Disable webkit tap highlighting */
+ -webkit-tap-highlight-color: rgba(0,0,0,0);
+ justify-content: center;
}
-.paper-icon-button-light::-moz-focus-inner {
- border: 0
-}
+ .paper-icon-button-light::-moz-focus-inner {
+ border: 0;
+ }
-.paper-icon-button-light[disabled] {
- opacity: .3
-}
+ .paper-icon-button-light[disabled] {
+ opacity: .3;
+ }
-.paper-icon-button-light>i {
- font-size: 1.66956521739130434em;
- position: relative;
- z-index: 1;
- vertical-align: middle
-}
+ .paper-icon-button-light > i {
+ font-size: 1.66956521739130434em;
+ /* Make sure its on top of the ripple */
+ position: relative;
+ z-index: 1;
+ vertical-align: middle;
+ }
-.paper-icon-button-light>img {
- width: 1.72em;
- max-height: 100%;
- position: relative;
- z-index: 1;
- vertical-align: middle
-}
+ .paper-icon-button-light > img {
+ width: 1.72em;
+ /* Can't use 100% height or it will stretch past the boundaries in safari */
+ /*height: 100%;*/
+ max-height: 100%;
+ /* Make sure its on top of the ripple */
+ position: relative;
+ z-index: 1;
+ vertical-align: middle;
+ }
.emby-button-foreground {
position: relative;
- z-index: 1
+ z-index: 1;
}
.icon-button-focusscale {
- -webkit-transition: -webkit-transform 180ms ease-out !important;
- -o-transition: transform 180ms ease-out !important;
transition: transform 180ms ease-out !important;
-webkit-transform-origin: center center;
- transform-origin: center center
+ transform-origin: center center;
}
-.icon-button-focusscale:focus {
- -webkit-transform: scale(1.3);
- transform: scale(1.3);
- z-index: 1
-}
+ .icon-button-focusscale:focus {
+ transform: scale(1.3);
+ z-index: 1;
+ }
.btnFilterWithBubble {
- position: relative
+ position: relative;
}
.filterButtonBubble {
color: #fff;
position: absolute;
+ background: #444;
top: 0;
right: 0;
+ /* padding: .5em; */
width: 1.6em;
height: 1.6em;
z-index: 100000000;
- display: -webkit-box;
- display: -webkit-flex;
display: flex;
- -webkit-box-align: center;
- -webkit-align-items: center;
align-items: center;
- -webkit-box-pack: center;
- -webkit-justify-content: center;
justify-content: center;
font-size: 82%;
- -webkit-border-radius: 100em;
border-radius: 100em;
- -webkit-box-shadow: 0 4px 5px 0 rgba(0, 0, 0, .14), 0 1px 10px 0 rgba(0, 0, 0, .12), 0 2px 4px -1px rgba(0, 0, 0, .2);
- box-shadow: 0 4px 5px 0 rgba(0, 0, 0, .14), 0 1px 10px 0 rgba(0, 0, 0, .12), 0 2px 4px -1px rgba(0, 0, 0, .2);
+ box-shadow: 0px 4px 5px 0px rgba(0, 0, 0, 0.14), 0px 1px 10px 0px rgba(0, 0, 0, 0.12), 0px 2px 4px -1px rgba(0, 0, 0, 0.2);
background: #03A9F4;
- font-weight: 700
-}
\ No newline at end of file
+ font-weight: bold;
+}
diff --git a/src/bower_components/emby-webcomponents/emby-button/emby-button.js b/src/bower_components/emby-webcomponents/emby-button/emby-button.js
index bd27515990..173d21b9bd 100644
--- a/src/bower_components/emby-webcomponents/emby-button/emby-button.js
+++ b/src/bower_components/emby-webcomponents/emby-button/emby-button.js
@@ -1,29 +1,99 @@
-define(["browser", "dom", "layoutManager", "shell", "appRouter", "apphost", "css!./emby-button", "registerElement"], function(browser, dom, layoutManager, shell, appRouter, appHost) {
- "use strict";
+define(['browser', 'dom', 'layoutManager', 'shell', 'appRouter', 'apphost', 'css!./emby-button', 'registerElement'], function (browser, dom, layoutManager, shell, appRouter, appHost) {
+ 'use strict';
+
+ var EmbyButtonPrototype = Object.create(HTMLButtonElement.prototype);
+ var EmbyLinkButtonPrototype = Object.create(HTMLAnchorElement.prototype);
function openPremiumInfo() {
- require(["registrationServices"], function(registrationServices) {
- registrationServices.showPremiereInfo()
- })
+
+ require(['registrationServices'], function (registrationServices) {
+ registrationServices.showPremiereInfo();
+ });
}
function onAnchorClick(e) {
- var href = this.getAttribute("href") || "";
- "#" !== href ? this.getAttribute("target") ? -1 === href.indexOf("emby.media/premiere") || appHost.supports("externalpremium") ? appHost.supports("targetblank") || (e.preventDefault(), shell.openUrl(href)) : (e.preventDefault(), openPremiumInfo()) : appRouter.handleAnchorClick(e) : e.preventDefault()
+
+ var href = this.getAttribute('href') || '';
+
+ if (href !== '#') {
+
+ if (this.getAttribute('target')) {
+ if (href.indexOf('emby.media/premiere') !== -1 && !appHost.supports('externalpremium')) {
+ e.preventDefault();
+ openPremiumInfo();
+ }
+ else if (!appHost.supports('targetblank')) {
+ e.preventDefault();
+ shell.openUrl(href);
+ }
+ } else {
+ appRouter.handleAnchorClick(e);
+ }
+ } else {
+ e.preventDefault();
+ }
}
- var EmbyButtonPrototype = Object.create(HTMLButtonElement.prototype),
- EmbyLinkButtonPrototype = Object.create(HTMLAnchorElement.prototype);
- return EmbyButtonPrototype.createdCallback = function() {
- this.classList.contains("emby-button") || (this.classList.add("emby-button"), browser.firefox && this.classList.add("button-link-inline"), layoutManager.tv && ("false" !== this.getAttribute("data-focusscale") && this.classList.add("emby-button-focusscale"), this.classList.add("emby-button-tv")))
- }, EmbyButtonPrototype.attachedCallback = function() {
- "A" === this.tagName && (dom.removeEventListener(this, "click", onAnchorClick, {}), dom.addEventListener(this, "click", onAnchorClick, {}), "true" === this.getAttribute("data-autohide") && (appHost.supports("externallinks") ? this.classList.remove("hide") : this.classList.add("hide")))
- }, EmbyButtonPrototype.detachedCallback = function() {
- dom.removeEventListener(this, "click", onAnchorClick, {})
- }, EmbyLinkButtonPrototype.createdCallback = EmbyButtonPrototype.createdCallback, EmbyLinkButtonPrototype.attachedCallback = EmbyButtonPrototype.attachedCallback, document.registerElement("emby-button", {
+
+ EmbyButtonPrototype.createdCallback = function () {
+
+ if (this.classList.contains('emby-button')) {
+ return;
+ }
+
+ this.classList.add('emby-button');
+
+ if (browser.firefox) {
+ // a ff hack is needed for vertical alignment
+ this.classList.add('button-link-inline');
+ }
+
+ if (layoutManager.tv) {
+ if (this.getAttribute('data-focusscale') !== 'false') {
+ this.classList.add('emby-button-focusscale');
+ }
+ this.classList.add('emby-button-tv');
+ }
+ };
+
+ EmbyButtonPrototype.attachedCallback = function () {
+
+ if (this.tagName === 'A') {
+
+ dom.removeEventListener(this, 'click', onAnchorClick, {
+ });
+
+ dom.addEventListener(this, 'click', onAnchorClick, {
+ });
+
+ if (this.getAttribute('data-autohide') === 'true') {
+ if (appHost.supports('externallinks')) {
+ this.classList.remove('hide');
+ } else {
+ this.classList.add('hide');
+ }
+ }
+ }
+ };
+
+ EmbyButtonPrototype.detachedCallback = function () {
+
+ dom.removeEventListener(this, 'click', onAnchorClick, {
+ });
+ };
+
+ EmbyLinkButtonPrototype.createdCallback = EmbyButtonPrototype.createdCallback;
+ EmbyLinkButtonPrototype.attachedCallback = EmbyButtonPrototype.attachedCallback;
+
+ document.registerElement('emby-button', {
prototype: EmbyButtonPrototype,
- extends: "button"
- }), document.registerElement("emby-linkbutton", {
+ extends: 'button'
+ });
+
+ document.registerElement('emby-linkbutton', {
prototype: EmbyLinkButtonPrototype,
- extends: "a"
- }), EmbyButtonPrototype
+ extends: 'a'
+ });
+
+ // For extension purposes
+ return EmbyButtonPrototype;
});
\ No newline at end of file
diff --git a/src/bower_components/emby-webcomponents/emby-button/paper-icon-button-light.js b/src/bower_components/emby-webcomponents/emby-button/paper-icon-button-light.js
index 85b377c06f..b3b5c5aee3 100644
--- a/src/bower_components/emby-webcomponents/emby-button/paper-icon-button-light.js
+++ b/src/bower_components/emby-webcomponents/emby-button/paper-icon-button-light.js
@@ -1,10 +1,19 @@
-define(["layoutManager", "css!./emby-button", "registerElement"], function(layoutManager) {
- "use strict";
+define(['layoutManager', 'css!./emby-button', 'registerElement'], function (layoutManager) {
+ 'use strict';
+
var EmbyButtonPrototype = Object.create(HTMLButtonElement.prototype);
- EmbyButtonPrototype.createdCallback = function() {
- this.classList.add("paper-icon-button-light"), layoutManager.tv && this.classList.add("icon-button-focusscale")
- }, document.registerElement("paper-icon-button-light", {
+
+ EmbyButtonPrototype.createdCallback = function () {
+
+ this.classList.add('paper-icon-button-light');
+
+ if (layoutManager.tv) {
+ this.classList.add('icon-button-focusscale');
+ }
+ };
+
+ document.registerElement('paper-icon-button-light', {
prototype: EmbyButtonPrototype,
- extends: "button"
- })
+ extends: 'button'
+ });
});
\ No newline at end of file
diff --git a/src/bower_components/emby-webcomponents/emby-checkbox/emby-checkbox.css b/src/bower_components/emby-webcomponents/emby-checkbox/emby-checkbox.css
index 7ae2f8c973..dc12b2de82 100644
--- a/src/bower_components/emby-webcomponents/emby-checkbox/emby-checkbox.css
+++ b/src/bower_components/emby-webcomponents/emby-checkbox/emby-checkbox.css
@@ -2,45 +2,37 @@
position: relative;
z-index: 1;
vertical-align: middle;
- display: -webkit-inline-box;
- display: -webkit-inline-flex;
display: inline-flex;
- -webkit-box-sizing: border-box;
box-sizing: border-box;
width: 100%;
margin: 0;
- padding: 0 0 0 2.4em;
- -webkit-box-align: center;
- -webkit-align-items: center;
+ padding: 0;
+ padding-left: 2.4em;
align-items: center;
height: 2.35em;
- cursor: pointer
-}
-
-.checkboxContainer,
-.checkboxListContainer {
- margin-bottom: 1.8em
+ cursor: pointer;
}
.checkboxFieldDescription {
- padding-left: 2.4em
+ padding-left: 2.4em;
}
.checkboxContainer {
- display: -webkit-box;
- display: -webkit-flex;
- display: flex
+ margin-bottom: 1.8em;
+ display: flex;
+}
+
+.checkboxListContainer {
+ margin-bottom: 1.8em;
}
.checkboxContainer-withDescription {
- -webkit-box-orient: vertical;
- -webkit-box-direction: normal;
- -webkit-flex-direction: column;
- flex-direction: column
+ flex-direction: column;
}
.emby-checkbox {
position: absolute;
+ /* This is for focusing purposes, so the focusManager doesn't skip over it */
width: 1px;
height: 1px;
margin: 0;
@@ -50,112 +42,109 @@
-moz-appearance: none;
-webkit-appearance: none;
appearance: none;
- border: none
+ border: none;
}
.checkboxOutline {
position: absolute;
top: 3px;
left: 0;
- -webkit-box-sizing: border-box;
+ display: inline-block;
box-sizing: border-box;
width: 1.83em;
height: 1.83em;
margin: 0;
overflow: hidden;
border: 2px solid currentcolor;
- -webkit-border-radius: .14em;
border-radius: .14em;
z-index: 2;
- display: -webkit-box;
- display: -webkit-flex;
display: flex;
- -webkit-box-align: center;
- -webkit-align-items: center;
align-items: center;
- -webkit-box-pack: center;
- -webkit-justify-content: center;
- justify-content: center
+ justify-content: center;
}
+/* Commenting this out - set by theme */
+/*.emby-checkbox:checked + span + span + .checkboxOutline {
+ border-color: #52B54B;
+}*/
+
.emby-checkbox-focushelper {
position: absolute;
- top: -.915em;
- left: -.915em;
+ top: -0.915em;
+ left: -0.915em;
width: 3.66em;
height: 3.66em;
display: inline-block;
- -webkit-box-sizing: border-box;
box-sizing: border-box;
- margin: 3px 0 0;
- -webkit-border-radius: 50%;
+ margin: 3px 0 0 0;
border-radius: 50%;
- background-color: transparent
+ background-color: transparent;
}
+/* Commenting this out - set by theme */
+/*.emby-checkbox:focus + span + .emby-checkbox-focushelper {
+ background-color: rgba(82, 181, 75, 0.26);
+}*/
+
.checkboxIcon {
font-size: 1.6em;
- color: #fff
+ color: #fff;
}
.checkboxIcon-checked {
- display: none
+ display: none;
}
-.emby-checkbox:checked+span+span+.checkboxOutline>.checkboxIcon-checked {
- display: -webkit-box !important;
- display: -webkit-flex !important;
- display: flex !important
+.emby-checkbox:checked + span + span + .checkboxOutline > .checkboxIcon-checked {
+ /* background-color set by theme */
+ /*background-color: #52B54B;*/
+ display: flex !important;
}
-.emby-checkbox:checked+span+span+.checkboxOutline>.checkboxIcon-unchecked {
- display: none !important
+.emby-checkbox:checked + span + span + .checkboxOutline > .checkboxIcon-unchecked {
+ /* background-color set by theme */
+ display: none !important;
}
-.emby-checkbox:checked[disabled]+span+span+.checkboxOutline>.checkboxIcon {
- background-color: rgba(0, 0, 0, .26)
+.emby-checkbox:checked[disabled] + span + span + .checkboxOutline > .checkboxIcon {
+ background-color: rgba(0, 0, 0, 0.26);
}
.checkboxLabel {
position: relative;
- margin: 0
+ margin: 0;
}
-.checkboxList>.emby-checkbox-label {
- display: -webkit-box;
- display: -webkit-flex;
+.checkboxList > .emby-checkbox-label {
display: flex;
- margin: .5em 0
+ margin: .5em 0;
}
.checkboxList-verticalwrap {
- display: -webkit-box;
- display: -webkit-flex;
display: flex;
- -webkit-flex-wrap: wrap;
- flex-wrap: wrap
+ flex-wrap: wrap;
}
-.checkboxList-verticalwrap>.emby-checkbox-label {
- display: -webkit-inline-box;
- display: -webkit-inline-flex;
- display: inline-flex;
- margin: .3em 0;
- width: 12em
-}
+ .checkboxList-verticalwrap > .emby-checkbox-label {
+ display: inline-flex;
+ margin: .3em 0 .3em 0;
+ width: 12em;
+ }
.checkboxList-paperList {
- padding: 1em !important
+ padding: 1em !important;
}
.checkboxListLabel {
- margin-bottom: .25em
+ margin-bottom: .25em;
}
@-webkit-keyframes repaintChrome {
-
- from,
- to {
- padding: 0
+ from {
+ padding: 0;
}
-}
\ No newline at end of file
+
+ to {
+ padding: 0;
+ }
+}
diff --git a/src/bower_components/emby-webcomponents/emby-checkbox/emby-checkbox.js b/src/bower_components/emby-webcomponents/emby-checkbox/emby-checkbox.js
index 38649f0934..5d350612a4 100644
--- a/src/bower_components/emby-webcomponents/emby-checkbox/emby-checkbox.js
+++ b/src/bower_components/emby-webcomponents/emby-checkbox/emby-checkbox.js
@@ -1,55 +1,110 @@
-define(["browser", "dom", "css!./emby-checkbox", "registerElement"], function(browser, dom) {
- "use strict";
+define(['browser', 'dom', 'css!./emby-checkbox', 'registerElement'], function (browser, dom) {
+ 'use strict';
+
+ var EmbyCheckboxPrototype = Object.create(HTMLInputElement.prototype);
function onKeyDown(e) {
- if (13 === e.keyCode) return e.preventDefault(), this.checked = !this.checked, this.dispatchEvent(new CustomEvent("change", {
- bubbles: !0
- })), !1
+
+ // Don't submit form on enter
+ if (e.keyCode === 13) {
+ e.preventDefault();
+
+ this.checked = !this.checked;
+
+ this.dispatchEvent(new CustomEvent('change', {
+ bubbles: true
+ }));
+
+ return false;
+ }
}
+ var enableRefreshHack = browser.tizen || browser.orsay || browser.operaTv || browser.web0s ? true : false;
+
function forceRefresh(loading) {
+
var elem = this.parentNode;
- elem.style.webkitAnimationName = "repaintChrome", elem.style.webkitAnimationDelay = !0 === loading ? "500ms" : "", elem.style.webkitAnimationDuration = "10ms", elem.style.webkitAnimationIterationCount = "1", setTimeout(function() {
- elem.style.webkitAnimationName = ""
- }, !0 === loading ? 520 : 20)
+
+ elem.style.webkitAnimationName = 'repaintChrome';
+ elem.style.webkitAnimationDelay = (loading === true ? '500ms' : '');
+ elem.style.webkitAnimationDuration = '10ms';
+ elem.style.webkitAnimationIterationCount = '1';
+
+ setTimeout(function () {
+ elem.style.webkitAnimationName = '';
+ }, (loading === true ? 520 : 20));
}
- var EmbyCheckboxPrototype = Object.create(HTMLInputElement.prototype),
- enableRefreshHack = !!(browser.tizen || browser.orsay || browser.operaTv || browser.web0s);
- EmbyCheckboxPrototype.attachedCallback = function() {
- if ("true" !== this.getAttribute("data-embycheckbox")) {
- this.setAttribute("data-embycheckbox", "true"), this.classList.add("emby-checkbox");
- var labelElement = this.parentNode;
- labelElement.classList.add("emby-checkbox-label");
- var labelTextElement = labelElement.querySelector("span"),
- outlineClass = "checkboxOutline",
- customClass = this.getAttribute("data-outlineclass");
- customClass && (outlineClass += " " + customClass);
- var checkedIcon = this.getAttribute("data-checkedicon") || "",
- uncheckedIcon = this.getAttribute("data-uncheckedicon") || "",
- checkHtml = '
' + checkedIcon + " ",
- uncheckedHtml = '
' + uncheckedIcon + " ";
- labelElement.insertAdjacentHTML("beforeend", '
' + checkHtml + uncheckedHtml + " "), labelTextElement.classList.add("checkboxLabel"), this.addEventListener("keydown", onKeyDown), enableRefreshHack && (forceRefresh.call(this, !0), dom.addEventListener(this, "click", forceRefresh, {
- passive: !0
- }), dom.addEventListener(this, "blur", forceRefresh, {
- passive: !0
- }), dom.addEventListener(this, "focus", forceRefresh, {
- passive: !0
- }), dom.addEventListener(this, "change", forceRefresh, {
- passive: !0
- }))
+
+ EmbyCheckboxPrototype.attachedCallback = function () {
+
+ if (this.getAttribute('data-embycheckbox') === 'true') {
+ return;
}
- }, EmbyCheckboxPrototype.detachedCallback = function() {
- this.removeEventListener("keydown", onKeyDown), dom.removeEventListener(this, "click", forceRefresh, {
- passive: !0
- }), dom.removeEventListener(this, "blur", forceRefresh, {
- passive: !0
- }), dom.removeEventListener(this, "focus", forceRefresh, {
- passive: !0
- }), dom.removeEventListener(this, "change", forceRefresh, {
- passive: !0
- })
- }, document.registerElement("emby-checkbox", {
+
+ this.setAttribute('data-embycheckbox', 'true');
+
+ this.classList.add('emby-checkbox');
+
+ var labelElement = this.parentNode;
+ labelElement.classList.add('emby-checkbox-label');
+
+ var labelTextElement = labelElement.querySelector('span');
+
+ var outlineClass = 'checkboxOutline';
+
+ var customClass = this.getAttribute('data-outlineclass');
+ if (customClass) {
+ outlineClass += ' ' + customClass;
+ }
+
+ var checkedIcon = this.getAttribute('data-checkedicon') || '';
+ var uncheckedIcon = this.getAttribute('data-uncheckedicon') || '';
+ var checkHtml = '
' + checkedIcon + ' ';
+ var uncheckedHtml = '
' + uncheckedIcon + ' ';
+ labelElement.insertAdjacentHTML('beforeend', '
' + checkHtml + uncheckedHtml + ' ');
+
+ labelTextElement.classList.add('checkboxLabel');
+
+ this.addEventListener('keydown', onKeyDown);
+
+ if (enableRefreshHack) {
+
+ forceRefresh.call(this, true);
+ dom.addEventListener(this, 'click', forceRefresh, {
+ passive: true
+ });
+ dom.addEventListener(this, 'blur', forceRefresh, {
+ passive: true
+ });
+ dom.addEventListener(this, 'focus', forceRefresh, {
+ passive: true
+ });
+ dom.addEventListener(this, 'change', forceRefresh, {
+ passive: true
+ });
+ }
+ };
+
+ EmbyCheckboxPrototype.detachedCallback = function () {
+
+ this.removeEventListener('keydown', onKeyDown);
+
+ dom.removeEventListener(this, 'click', forceRefresh, {
+ passive: true
+ });
+ dom.removeEventListener(this, 'blur', forceRefresh, {
+ passive: true
+ });
+ dom.removeEventListener(this, 'focus', forceRefresh, {
+ passive: true
+ });
+ dom.removeEventListener(this, 'change', forceRefresh, {
+ passive: true
+ });
+ };
+
+ document.registerElement('emby-checkbox', {
prototype: EmbyCheckboxPrototype,
- extends: "input"
- })
-});
\ No newline at end of file
+ extends: 'input'
+ });
+});
diff --git a/src/bower_components/emby-webcomponents/emby-collapse/emby-collapse.css b/src/bower_components/emby-webcomponents/emby-collapse/emby-collapse.css
index a03a0aee72..0a982e975d 100644
--- a/src/bower_components/emby-webcomponents/emby-collapse/emby-collapse.css
+++ b/src/bower_components/emby-webcomponents/emby-collapse/emby-collapse.css
@@ -1,56 +1,44 @@
.emby-collapse {
- margin: .5em 0
+ margin: .5em 0;
}
.collapseContent {
border-width: 0;
- padding: 1.25em;
+ padding: 1.25em 1.25em;
height: 0;
- -webkit-transition-property: height;
- -o-transition-property: height;
transition-property: height;
- -webkit-transition-duration: .3s;
- -o-transition-duration: .3s;
- transition-duration: .3s;
- overflow: hidden
+ transition-duration: 300ms;
+ overflow: hidden;
}
.emby-collapsible-button {
margin: 0;
- display: -webkit-box;
- display: -webkit-flex;
display: flex;
- -webkit-box-align: center;
- -webkit-align-items: center;
align-items: center;
+ text-transform: none;
width: 100%;
text-align: left;
text-transform: none;
- border-width: 0 0 .1em;
+ border-width: 0 0 .1em 0;
border-style: solid;
padding-left: .1em;
- background: 0 0;
- -webkit-box-shadow: none;
- box-shadow: none
+ background: transparent;
+ box-shadow: none;
}
.emby-collapse-expandIcon {
- -webkit-transform-origin: 50% 50%;
transform-origin: 50% 50%;
- -webkit-transition: -webkit-transform 180ms ease-out;
- -o-transition: transform 180ms ease-out;
transition: transform 180ms ease-out;
position: absolute;
right: .5em;
- font-size: 1.5em
+ font-size: 1.5em;
}
.emby-collapse-expandIconExpanded {
- -webkit-transform: rotate(180deg);
- transform: rotate(180deg)
+ transform: rotate(180deg);
}
.emby-collapsible-title {
margin: 0;
- padding: 0
-}
\ No newline at end of file
+ padding: 0;
+}
diff --git a/src/bower_components/emby-webcomponents/emby-collapse/emby-collapse.js b/src/bower_components/emby-webcomponents/emby-collapse/emby-collapse.js
index 4a237a9174..198278e1d7 100644
--- a/src/bower_components/emby-webcomponents/emby-collapse/emby-collapse.js
+++ b/src/bower_components/emby-webcomponents/emby-collapse/emby-collapse.js
@@ -1,43 +1,100 @@
-define(["browser", "css!./emby-collapse", "registerElement", "emby-button"], function(browser) {
- "use strict";
+define(['browser', 'css!./emby-collapse', 'registerElement', 'emby-button'], function (browser) {
+ 'use strict';
+
+ var EmbyButtonPrototype = Object.create(HTMLDivElement.prototype);
function slideDownToShow(button, elem) {
- elem.classList.remove("hide"), elem.classList.add("expanded"), elem.style.height = "auto";
- var height = elem.offsetHeight + "px";
- elem.style.height = "0";
- elem.offsetHeight;
- elem.style.height = height, setTimeout(function() {
- elem.classList.contains("expanded") ? elem.classList.remove("hide") : elem.classList.add("hide"), elem.style.height = "auto"
- }, 300), button.querySelector("i").classList.add("emby-collapse-expandIconExpanded")
+
+ elem.classList.remove('hide');
+ elem.classList.add('expanded');
+ elem.style.height = 'auto';
+ var height = elem.offsetHeight + 'px';
+ elem.style.height = '0';
+
+ // trigger reflow
+ var newHeight = elem.offsetHeight;
+ elem.style.height = height;
+
+ setTimeout(function () {
+ if (elem.classList.contains('expanded')) {
+ elem.classList.remove('hide');
+ } else {
+ elem.classList.add('hide');
+ }
+ elem.style.height = 'auto';
+ }, 300);
+
+ var icon = button.querySelector('i');
+ //icon.innerHTML = 'expand_less';
+ icon.classList.add('emby-collapse-expandIconExpanded');
}
function slideUpToHide(button, elem) {
- elem.style.height = elem.offsetHeight + "px";
- elem.offsetHeight;
- elem.classList.remove("expanded"), elem.style.height = "0", setTimeout(function() {
- elem.classList.contains("expanded") ? elem.classList.remove("hide") : elem.classList.add("hide")
- }, 300), button.querySelector("i").classList.remove("emby-collapse-expandIconExpanded")
+
+ elem.style.height = elem.offsetHeight + 'px';
+ // trigger reflow
+ var newHeight = elem.offsetHeight;
+
+ elem.classList.remove('expanded');
+ elem.style.height = '0';
+
+ setTimeout(function () {
+ if (elem.classList.contains('expanded')) {
+ elem.classList.remove('hide');
+ } else {
+ elem.classList.add('hide');
+ }
+ }, 300);
+
+ var icon = button.querySelector('i');
+ //icon.innerHTML = 'expand_more';
+ icon.classList.remove('emby-collapse-expandIconExpanded');
}
function onButtonClick(e) {
- var button = this,
- collapseContent = button.parentNode.querySelector(".collapseContent");
- collapseContent.expanded ? (collapseContent.expanded = !1, slideUpToHide(button, collapseContent)) : (collapseContent.expanded = !0, slideDownToShow(button, collapseContent))
- }
- var EmbyButtonPrototype = Object.create(HTMLDivElement.prototype);
- EmbyButtonPrototype.attachedCallback = function() {
- if (!this.classList.contains("emby-collapse")) {
- this.classList.add("emby-collapse");
- var collapseContent = this.querySelector(".collapseContent");
- collapseContent && collapseContent.classList.add("hide");
- var title = this.getAttribute("title"),
- html = '
' + title + ' expand_more ';
- this.insertAdjacentHTML("afterbegin", html);
- var button = this.querySelector(".emby-collapsible-button");
- button.addEventListener("click", onButtonClick), "true" === this.getAttribute("data-expanded") && onButtonClick.call(button)
+
+ var button = this;
+ var collapseContent = button.parentNode.querySelector('.collapseContent');
+
+ if (collapseContent.expanded) {
+ collapseContent.expanded = false;
+ slideUpToHide(button, collapseContent);
+ } else {
+ collapseContent.expanded = true;
+ slideDownToShow(button, collapseContent);
}
- }, document.registerElement("emby-collapse", {
+ }
+
+ EmbyButtonPrototype.attachedCallback = function () {
+
+ if (this.classList.contains('emby-collapse')) {
+ return;
+ }
+
+ this.classList.add('emby-collapse');
+
+ var collapseContent = this.querySelector('.collapseContent');
+ if (collapseContent) {
+ collapseContent.classList.add('hide');
+ }
+
+ var title = this.getAttribute('title');
+
+ var html = '
' + title + ' expand_more ';
+
+ this.insertAdjacentHTML('afterbegin', html);
+
+ var button = this.querySelector('.emby-collapsible-button');
+
+ button.addEventListener('click', onButtonClick);
+
+ if (this.getAttribute('data-expanded') === 'true') {
+ onButtonClick.call(button);
+ }
+ };
+
+ document.registerElement('emby-collapse', {
prototype: EmbyButtonPrototype,
- extends: "div"
- })
+ extends: 'div'
+ });
});
\ No newline at end of file
diff --git a/src/bower_components/emby-webcomponents/emby-connect/connecthelper.js b/src/bower_components/emby-webcomponents/emby-connect/connecthelper.js
index 50292c9f14..054070a447 100644
--- a/src/bower_components/emby-webcomponents/emby-connect/connecthelper.js
+++ b/src/bower_components/emby-webcomponents/emby-connect/connecthelper.js
@@ -1,106 +1,219 @@
-define(["globalize", "apphost", "loading", "alert", "emby-linkbutton"], function(globalize, appHost, loading, alert) {
- "use strict";
+define(['globalize', 'apphost', 'loading', 'alert', 'emby-linkbutton'], function (globalize, appHost, loading, alert) {
+ 'use strict';
function resolvePromise() {
- return Promise.resolve()
+ return Promise.resolve();
}
function rejectPromise() {
- return Promise.reject()
+ return Promise.reject();
}
function showNewUserInviteMessage(result) {
- if (!result.IsNewUserInvitation && !result.IsPending) return Promise.resolve();
- var message = result.IsNewUserInvitation ? globalize.translate("sharedcomponents#MessageInvitationSentToNewUser", result.GuestDisplayName) : globalize.translate("sharedcomponents#MessageInvitationSentToUser", result.GuestDisplayName);
+
+ if (!result.IsNewUserInvitation && !result.IsPending) {
+
+ // It was immediately approved
+ return Promise.resolve();
+ }
+
+ var message = result.IsNewUserInvitation ?
+ globalize.translate('sharedcomponents#MessageInvitationSentToNewUser', result.GuestDisplayName) :
+ globalize.translate('sharedcomponents#MessageInvitationSentToUser', result.GuestDisplayName);
+
return alert({
+
text: message,
- title: globalize.translate("sharedcomponents#HeaderInvitationSent")
- }).then(resolvePromise, resolvePromise)
+ title: globalize.translate('sharedcomponents#HeaderInvitationSent')
+
+ }).then(resolvePromise, resolvePromise);
}
function inviteGuest(options) {
+
var apiClient = options.apiClient;
- return loading.show(), apiClient.ajax({
+
+ loading.show();
+
+ // Add/Update connect info
+ return apiClient.ajax({
+
type: "POST",
- url: apiClient.getUrl("Connect/Invite"),
- dataType: "json",
+ url: apiClient.getUrl('Connect/Invite'),
+ dataType: 'json',
data: options.guestOptions || {}
- }).then(function(result) {
- return loading.hide(), showNewUserInviteMessage(result)
- }, function(response) {
+
+ }).then(function (result) {
+
loading.hide();
+ return showNewUserInviteMessage(result);
+
+ }, function (response) {
+
+ loading.hide();
+
var statusCode = response ? response.status : 0;
- return 502 === statusCode ? showConnectServerUnreachableErrorMessage().then(rejectPromise, rejectPromise) : 404 === statusCode ? alert({
- text: globalize.translate("sharedcomponents#GuestUserNotFound")
- }).then(rejectPromise, rejectPromise) : (statusCode || 0) >= 500 ? alert({
- text: globalize.translate("sharedcomponents#ErrorReachingEmbyConnect")
- }).then(rejectPromise, rejectPromise) : showGuestGeneralErrorMessage().then(rejectPromise, rejectPromise)
- })
+
+ if (statusCode === 502) {
+ return showConnectServerUnreachableErrorMessage().then(rejectPromise, rejectPromise);
+ }
+ else if (statusCode === 404) {
+ // User doesn't exist
+ return alert({
+ text: globalize.translate('sharedcomponents#GuestUserNotFound')
+ }).then(rejectPromise, rejectPromise);
+
+ } else if ((statusCode || 0) >= 500) {
+
+ // Unable to reach connect server ?
+ return alert({
+ text: globalize.translate('sharedcomponents#ErrorReachingEmbyConnect')
+ }).then(rejectPromise, rejectPromise);
+
+ } else {
+
+ // status 400 = account not activated
+
+ // General error
+ return showGuestGeneralErrorMessage().then(rejectPromise, rejectPromise);
+ }
+ });
}
function showGuestGeneralErrorMessage() {
+
var html;
- appHost.supports("externallinks") && (html = globalize.translate("sharedcomponents#ErrorAddingGuestAccount1", '
https://github.com/jellyfin/jellyfin '), html += "
" + globalize.translate("sharedcomponents#ErrorAddingGuestAccount2", "apps@emby.media"));
- var text = globalize.translate("sharedcomponents#ErrorAddingGuestAccount1", "https://github.com/jellyfin/jellyfin");
- return text += "\n\n" + globalize.translate("sharedcomponents#ErrorAddingGuestAccount2", "apps@emby.media"), alert({
+
+ if (appHost.supports('externallinks')) {
+ html = globalize.translate('sharedcomponents#ErrorAddingGuestAccount1', '
https://emby.media/connect ');
+ html += '
' + globalize.translate('sharedcomponents#ErrorAddingGuestAccount2', 'apps@emby.media');
+ }
+
+ var text = globalize.translate('sharedcomponents#ErrorAddingGuestAccount1', 'https://emby.media/connect');
+ text += '\n\n' + globalize.translate('sharedcomponents#ErrorAddingGuestAccount2', 'apps@emby.media');
+
+ return alert({
text: text,
html: html
- })
+ });
}
function showConnectServerUnreachableErrorMessage() {
- var text = globalize.translate("sharedcomponents#ErrorConnectServerUnreachable", "https://connect.emby.media");
+
+ var text = globalize.translate('sharedcomponents#ErrorConnectServerUnreachable', 'https://connect.emby.media');
+
return alert({
text: text
- })
+ });
}
function showLinkUserErrorMessage(username, statusCode) {
- var html, text;
- return 502 === statusCode ? showConnectServerUnreachableErrorMessage() : (username ? (appHost.supports("externallinks") && (html = globalize.translate("sharedcomponents#ErrorAddingEmbyConnectAccount1", '
https://github.com/jellyfin/jellyfin '), html += "
" + globalize.translate("sharedcomponents#ErrorAddingEmbyConnectAccount2", "apps@emby.media")), text = globalize.translate("sharedcomponents#ErrorAddingEmbyConnectAccount1", "https://github.com/jellyfin/jellyfin"), text += "\n\n" + globalize.translate("sharedcomponents#ErrorAddingEmbyConnectAccount2", "apps@emby.media")) : html = text = globalize.translate("sharedcomponents#DefaultErrorMessage"), alert({
+
+ var html;
+ var text;
+
+ if (statusCode === 502) {
+ return showConnectServerUnreachableErrorMessage();
+ }
+ else if (username) {
+
+ if (appHost.supports('externallinks')) {
+ html = globalize.translate('sharedcomponents#ErrorAddingEmbyConnectAccount1', '
https://emby.media/connect ');
+ html += '
' + globalize.translate('sharedcomponents#ErrorAddingEmbyConnectAccount2', 'apps@emby.media');
+ }
+
+ text = globalize.translate('sharedcomponents#ErrorAddingEmbyConnectAccount1', 'https://emby.media/connect');
+ text += '\n\n' + globalize.translate('sharedcomponents#ErrorAddingEmbyConnectAccount2', 'apps@emby.media');
+
+ } else {
+ html = text = globalize.translate('sharedcomponents#DefaultErrorMessage');
+ }
+
+ return alert({
text: text,
html: html
- }))
+ });
}
function updateUserLink(apiClient, user, newConnectUsername) {
- var currentConnectUsername = user.ConnectUserName || "",
- enteredConnectUsername = newConnectUsername,
- linkUrl = apiClient.getUrl("Users/" + user.Id + "/Connect/Link");
- return currentConnectUsername && !enteredConnectUsername ? apiClient.ajax({
- type: "DELETE",
- url: linkUrl
- }).then(function() {
- return alert({
- text: globalize.translate("sharedcomponents#MessageEmbyAccontRemoved"),
- title: globalize.translate("sharedcomponents#HeaderEmbyAccountRemoved")
- }).catch(resolvePromise)
- }, function(response) {
- return 502 === (response ? response.status : 0) ? showConnectServerUnreachableErrorMessage().then(rejectPromise) : alert({
- text: globalize.translate("sharedcomponents#ErrorRemovingEmbyConnectAccount")
- }).then(rejectPromise)
- }) : currentConnectUsername !== enteredConnectUsername ? apiClient.ajax({
- type: "POST",
- url: linkUrl,
- data: {
- ConnectUsername: enteredConnectUsername
- },
- dataType: "json"
- }).then(function(result) {
- var msgKey = result.IsPending ? "sharedcomponents#MessagePendingEmbyAccountAdded" : "sharedcomponents#MessageEmbyAccountAdded";
- return alert({
- text: globalize.translate(msgKey),
- title: globalize.translate("sharedcomponents#HeaderEmbyAccountAdded")
- }).catch(resolvePromise)
- }, function(response) {
- var statusCode = response ? response.status : 0;
- return 502 === statusCode ? showConnectServerUnreachableErrorMessage().then(rejectPromise) : showLinkUserErrorMessage(".", statusCode).then(rejectPromise)
- }) : Promise.reject()
+ var currentConnectUsername = user.ConnectUserName || '';
+ var enteredConnectUsername = newConnectUsername;
+
+ var linkUrl = apiClient.getUrl('Users/' + user.Id + '/Connect/Link');
+
+ if (currentConnectUsername && !enteredConnectUsername) {
+
+ // Remove connect info
+ // Add/Update connect info
+ return apiClient.ajax({
+
+ type: "DELETE",
+ url: linkUrl
+
+ }).then(function () {
+
+ return alert({
+ text: globalize.translate('sharedcomponents#MessageEmbyAccontRemoved'),
+ title: globalize.translate('sharedcomponents#HeaderEmbyAccountRemoved'),
+
+ }).catch(resolvePromise);
+
+ }, function (response) {
+
+ var statusCode = response ? response.status : 0;
+
+ if (statusCode === 502) {
+ return showConnectServerUnreachableErrorMessage().then(rejectPromise);
+ }
+
+ return alert({
+ text: globalize.translate('sharedcomponents#ErrorRemovingEmbyConnectAccount')
+
+ }).then(rejectPromise);
+ });
+
+ }
+ else if (currentConnectUsername !== enteredConnectUsername) {
+
+ // Add/Update connect info
+ return apiClient.ajax({
+ type: "POST",
+ url: linkUrl,
+ data: {
+ ConnectUsername: enteredConnectUsername
+ },
+ dataType: 'json'
+
+ }).then(function (result) {
+
+ var msgKey = result.IsPending ? 'sharedcomponents#MessagePendingEmbyAccountAdded' : 'sharedcomponents#MessageEmbyAccountAdded';
+
+ return alert({
+ text: globalize.translate(msgKey),
+ title: globalize.translate('sharedcomponents#HeaderEmbyAccountAdded'),
+
+ }).catch(resolvePromise);
+
+ }, function (response) {
+
+ var statusCode = response ? response.status : 0;
+
+ if (statusCode === 502) {
+ return showConnectServerUnreachableErrorMessage().then(rejectPromise);
+ }
+
+ return showLinkUserErrorMessage('.', statusCode).then(rejectPromise);
+ });
+
+ } else {
+ return Promise.reject();
+ }
}
+
return {
inviteGuest: inviteGuest,
updateUserLink: updateUserLink,
showLinkUserErrorMessage: showLinkUserErrorMessage,
showConnectServerUnreachableErrorMessage: showConnectServerUnreachableErrorMessage
- }
+ };
});
\ No newline at end of file
diff --git a/src/bower_components/emby-webcomponents/emby-input/emby-input.css b/src/bower_components/emby-webcomponents/emby-input/emby-input.css
index 31041f0a63..d888eb570d 100644
--- a/src/bower_components/emby-webcomponents/emby-input/emby-input.css
+++ b/src/bower_components/emby-webcomponents/emby-input/emby-input.css
@@ -2,35 +2,39 @@
display: block;
margin: 0;
margin-bottom: 0 !important;
+ /* Remove select styling */
+ /* Font size must the 16px or larger to prevent iOS page zoom on focus */
font-size: 110%;
+ /* General select styles: change as needed */
font-family: inherit;
font-weight: inherit;
padding: .4em .25em;
+ /* Prevent padding from causing width overflow */
-webkit-box-sizing: border-box;
box-sizing: border-box;
- outline: 0 !important;
- -webkit-tap-highlight-color: transparent;
- width: 100%
+ outline: none !important;
+ -webkit-tap-highlight-color: rgba(0,0,0,0);
+ width: 100%;
}
-.emby-input::-moz-focus-inner {
- border: 0
-}
+ .emby-input::-moz-focus-inner {
+ border: 0;
+ }
.inputContainer {
- margin-bottom: 1.8em
+ margin-bottom: 1.8em;
}
.inputLabel {
display: inline-block;
- margin-bottom: .25em
+ margin-bottom: .25em;
}
-.emby-input+.fieldDescription {
- margin-top: .25em
+.emby-input + .fieldDescription {
+ margin-top: .25em;
}
.emby-input-iconbutton {
-webkit-align-self: flex-end;
- align-self: flex-end
-}
\ No newline at end of file
+ align-self: flex-end;
+}
diff --git a/src/bower_components/emby-webcomponents/emby-input/emby-input.js b/src/bower_components/emby-webcomponents/emby-input/emby-input.js
index e6d6c0aeb7..9481b89225 100644
--- a/src/bower_components/emby-webcomponents/emby-input/emby-input.js
+++ b/src/bower_components/emby-webcomponents/emby-input/emby-input.js
@@ -1,56 +1,125 @@
-define(["layoutManager", "browser", "dom", "css!./emby-input", "registerElement"], function(layoutManager, browser, dom) {
- "use strict";
+define(['layoutManager', 'browser', 'dom', 'css!./emby-input', 'registerElement'], function (layoutManager, browser, dom) {
+ 'use strict';
+
+ var EmbyInputPrototype = Object.create(HTMLInputElement.prototype);
+
+ var inputId = 0;
+ var supportsFloatingLabel = false;
- function onChange() {
- var label = this.labelElement;
- if (this.value) label.classList.remove("inputLabel-float");
- else {
- supportsFloatingLabel && "date" !== this.type && "time" !== this.type && label.classList.add("inputLabel-float")
- }
- }
- var EmbyInputPrototype = Object.create(HTMLInputElement.prototype),
- inputId = 0,
- supportsFloatingLabel = !1;
if (Object.getOwnPropertyDescriptor && Object.defineProperty) {
- var descriptor = Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, "value");
+
+ var descriptor = Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, 'value');
+
+ // descriptor returning null in webos
if (descriptor && descriptor.configurable) {
var baseSetMethod = descriptor.set;
- descriptor.set = function(value) {
- baseSetMethod.call(this, value), this.dispatchEvent(new CustomEvent("valueset", {
- bubbles: !1,
- cancelable: !1
- }))
- }, Object.defineProperty(HTMLInputElement.prototype, "value", descriptor), supportsFloatingLabel = !0
+ descriptor.set = function (value) {
+ baseSetMethod.call(this, value);
+
+ this.dispatchEvent(new CustomEvent('valueset', {
+ bubbles: false,
+ cancelable: false
+ }));
+ };
+
+ Object.defineProperty(HTMLInputElement.prototype, 'value', descriptor);
+ supportsFloatingLabel = true;
}
}
- EmbyInputPrototype.createdCallback = function() {
- if (this.id || (this.id = "embyinput" + inputId, inputId++), !this.classList.contains("emby-input")) {
- this.classList.add("emby-input");
- var parentNode = this.parentNode,
- document = this.ownerDocument,
- label = document.createElement("label");
- label.innerHTML = this.getAttribute("label") || "", label.classList.add("inputLabel"), label.classList.add("inputLabelUnfocused"), label.htmlFor = this.id, parentNode.insertBefore(label, this), this.labelElement = label, dom.addEventListener(this, "focus", function() {
- onChange.call(this), document.attachIME && document.attachIME(this), label.classList.add("inputLabelFocused"), label.classList.remove("inputLabelUnfocused")
- }, {
- passive: !0
- }), dom.addEventListener(this, "blur", function() {
- onChange.call(this), label.classList.remove("inputLabelFocused"), label.classList.add("inputLabelUnfocused")
- }, {
- passive: !0
- }), dom.addEventListener(this, "change", onChange, {
- passive: !0
- }), dom.addEventListener(this, "input", onChange, {
- passive: !0
- }), dom.addEventListener(this, "valueset", onChange, {
- passive: !0
- }), browser.orsay && this === document.activeElement && document.attachIME && document.attachIME(this)
+
+ EmbyInputPrototype.createdCallback = function () {
+
+ if (!this.id) {
+ this.id = 'embyinput' + inputId;
+ inputId++;
+ } if (this.classList.contains('emby-input')) {
+ return;
}
- }, EmbyInputPrototype.attachedCallback = function() {
- this.labelElement.htmlFor = this.id, onChange.call(this)
- }, EmbyInputPrototype.label = function(text) {
- this.labelElement.innerHTML = text
- }, document.registerElement("emby-input", {
+
+ this.classList.add('emby-input');
+
+ var parentNode = this.parentNode;
+ var document = this.ownerDocument;
+ var label = document.createElement('label');
+ label.innerHTML = this.getAttribute('label') || '';
+ label.classList.add('inputLabel');
+ label.classList.add('inputLabelUnfocused');
+
+ label.htmlFor = this.id;
+ parentNode.insertBefore(label, this);
+ this.labelElement = label;
+
+ dom.addEventListener(this, 'focus', function () {
+ onChange.call(this);
+
+ // For Samsung orsay devices
+ if (document.attachIME) {
+ document.attachIME(this);
+ }
+
+ label.classList.add('inputLabelFocused');
+ label.classList.remove('inputLabelUnfocused');
+ }, {
+ passive: true
+ });
+
+ dom.addEventListener(this, 'blur', function () {
+ onChange.call(this);
+ label.classList.remove('inputLabelFocused');
+ label.classList.add('inputLabelUnfocused');
+ }, {
+ passive: true
+ });
+
+ dom.addEventListener(this, 'change', onChange, {
+ passive: true
+ });
+ dom.addEventListener(this, 'input', onChange, {
+ passive: true
+ });
+ dom.addEventListener(this, 'valueset', onChange, {
+ passive: true
+ });
+
+ if (browser.orsay) {
+ if (this === document.activeElement) {
+ //Make sure the IME pops up if this is the first/default element on the page
+ if (document.attachIME) {
+ document.attachIME(this);
+ }
+ }
+ }
+
+ };
+
+ function onChange() {
+
+ var label = this.labelElement;
+ if (this.value) {
+ label.classList.remove('inputLabel-float');
+ } else {
+
+ var instanceSupportsFloat = supportsFloatingLabel && this.type !== 'date' && this.type !== 'time';
+
+ if (instanceSupportsFloat) {
+ label.classList.add('inputLabel-float');
+ }
+ }
+ }
+
+ EmbyInputPrototype.attachedCallback = function () {
+
+ this.labelElement.htmlFor = this.id;
+
+ onChange.call(this);
+ };
+
+ EmbyInputPrototype.label = function (text) {
+ this.labelElement.innerHTML = text;
+ };
+
+ document.registerElement('emby-input', {
prototype: EmbyInputPrototype,
- extends: "input"
- })
+ extends: 'input'
+ });
});
\ No newline at end of file
diff --git a/src/bower_components/emby-webcomponents/emby-itemrefreshindicator/emby-itemrefreshindicator.js b/src/bower_components/emby-webcomponents/emby-itemrefreshindicator/emby-itemrefreshindicator.js
index a575c8ec27..502af23542 100644
--- a/src/bower_components/emby-webcomponents/emby-itemrefreshindicator/emby-itemrefreshindicator.js
+++ b/src/bower_components/emby-webcomponents/emby-itemrefreshindicator/emby-itemrefreshindicator.js
@@ -1,32 +1,77 @@
-define(["emby-progressring", "dom", "serverNotifications", "events", "registerElement"], function(EmbyProgressRing, dom, serverNotifications, events) {
- "use strict";
+define(['emby-progressring', 'dom', 'serverNotifications', 'events', 'registerElement'], function (EmbyProgressRing, dom, serverNotifications, events) {
+ 'use strict';
function addNotificationEvent(instance, name, handler) {
+
var localHandler = handler.bind(instance);
- events.on(serverNotifications, name, localHandler), instance[name] = localHandler
+ events.on(serverNotifications, name, localHandler);
+ instance[name] = localHandler;
}
function removeNotificationEvent(instance, name) {
+
var handler = instance[name];
- handler && (events.off(serverNotifications, name, handler), instance[name] = null)
+ if (handler) {
+ events.off(serverNotifications, name, handler);
+ instance[name] = null;
+ }
}
function onRefreshProgress(e, apiClient, info) {
+
var indicator = this;
- if (indicator.itemId || (indicator.itemId = dom.parentWithAttribute(indicator, "data-id").getAttribute("data-id")), info.ItemId === indicator.itemId) {
+
+ if (!indicator.itemId) {
+ indicator.itemId = dom.parentWithAttribute(indicator, 'data-id').getAttribute('data-id');
+ }
+
+ if (info.ItemId === indicator.itemId) {
+
var progress = parseFloat(info.Progress);
- progress && progress < 100 ? this.classList.remove("hide") : this.classList.add("hide"), this.setProgress(progress)
+
+ if (progress && progress < 100) {
+ this.classList.remove('hide');
+ } else {
+ this.classList.add('hide');
+ }
+
+ this.setProgress(progress);
}
}
+
var EmbyItemRefreshIndicatorPrototype = Object.create(EmbyProgressRing);
- EmbyItemRefreshIndicatorPrototype.createdCallback = function() {
- EmbyProgressRing.createdCallback && EmbyProgressRing.createdCallback.call(this), addNotificationEvent(this, "RefreshProgress", onRefreshProgress)
- }, EmbyItemRefreshIndicatorPrototype.attachedCallback = function() {
- EmbyProgressRing.attachedCallback && EmbyProgressRing.attachedCallback.call(this)
- }, EmbyItemRefreshIndicatorPrototype.detachedCallback = function() {
- EmbyProgressRing.detachedCallback && EmbyProgressRing.detachedCallback.call(this), removeNotificationEvent(this, "RefreshProgress"), this.itemId = null
- }, document.registerElement("emby-itemrefreshindicator", {
+
+ EmbyItemRefreshIndicatorPrototype.createdCallback = function () {
+
+ // base method
+ if (EmbyProgressRing.createdCallback) {
+ EmbyProgressRing.createdCallback.call(this);
+ }
+
+ addNotificationEvent(this, 'RefreshProgress', onRefreshProgress);
+ };
+
+ EmbyItemRefreshIndicatorPrototype.attachedCallback = function () {
+
+ // base method
+ if (EmbyProgressRing.attachedCallback) {
+ EmbyProgressRing.attachedCallback.call(this);
+ }
+ };
+
+ EmbyItemRefreshIndicatorPrototype.detachedCallback = function () {
+
+ // base method
+ if (EmbyProgressRing.detachedCallback) {
+ EmbyProgressRing.detachedCallback.call(this);
+ }
+
+ removeNotificationEvent(this, 'RefreshProgress');
+ this.itemId = null;
+ };
+
+ document.registerElement('emby-itemrefreshindicator', {
prototype: EmbyItemRefreshIndicatorPrototype,
- extends: "div"
- })
+ extends: 'div'
+ });
});
\ No newline at end of file
diff --git a/src/bower_components/emby-webcomponents/emby-itemscontainer/emby-itemscontainer.js b/src/bower_components/emby-webcomponents/emby-itemscontainer/emby-itemscontainer.js
index b33c3f4509..cd2cab827b 100644
--- a/src/bower_components/emby-webcomponents/emby-itemscontainer/emby-itemscontainer.js
+++ b/src/bower_components/emby-webcomponents/emby-itemscontainer/emby-itemscontainer.js
@@ -1,220 +1,548 @@
-define(["itemShortcuts", "inputManager", "connectionManager", "playbackManager", "imageLoader", "layoutManager", "browser", "dom", "loading", "focusManager", "serverNotifications", "events", "registerElement"], function(itemShortcuts, inputManager, connectionManager, playbackManager, imageLoader, layoutManager, browser, dom, loading, focusManager, serverNotifications, events) {
- "use strict";
+define(['itemShortcuts', 'inputManager', 'connectionManager', 'playbackManager', 'imageLoader', 'layoutManager', 'browser', 'dom', 'loading', 'focusManager', 'serverNotifications', 'events', 'registerElement'], function (itemShortcuts, inputManager, connectionManager, playbackManager, imageLoader, layoutManager, browser, dom, loading, focusManager, serverNotifications, events) {
+ 'use strict';
+
+ var ItemsContainerProtoType = Object.create(HTMLDivElement.prototype);
function onClick(e) {
- var itemsContainer = this,
- multiSelect = (e.target, itemsContainer.multiSelect);
- multiSelect && !1 === multiSelect.onContainerClick.call(itemsContainer, e) || itemShortcuts.onClick.call(itemsContainer, e)
+
+ var itemsContainer = this;
+ var target = e.target;
+
+ var multiSelect = itemsContainer.multiSelect;
+
+ if (multiSelect) {
+ if (multiSelect.onContainerClick.call(itemsContainer, e) === false) {
+ return;
+ }
+ }
+
+ itemShortcuts.onClick.call(itemsContainer, e);
}
function disableEvent(e) {
- return e.preventDefault(), e.stopPropagation(), !1
+
+ e.preventDefault();
+ e.stopPropagation();
+ return false;
}
function onContextMenu(e) {
- var target = e.target,
- card = dom.parentWithAttribute(target, "data-id");
- if (card && card.getAttribute("data-serverid")) return inputManager.trigger("menu", {
- sourceElement: card
- }), e.preventDefault(), e.stopPropagation(), !1
+
+ var itemsContainer = this;
+
+ var target = e.target;
+ var card = dom.parentWithAttribute(target, 'data-id');
+
+ // check for serverId, it won't be present on selectserver
+ if (card && card.getAttribute('data-serverid')) {
+
+ inputManager.trigger('menu', {
+ sourceElement: card
+ });
+
+ e.preventDefault();
+ e.stopPropagation();
+ return false;
+ }
}
function getShortcutOptions() {
return {
- click: !1
- }
+ click: false
+ };
}
+ ItemsContainerProtoType.enableMultiSelect = function (enabled) {
+
+ var current = this.multiSelect;
+
+ if (!enabled) {
+ if (current) {
+ current.destroy();
+ this.multiSelect = null;
+ }
+ return;
+ }
+
+ if (current) {
+ return;
+ }
+
+ var self = this;
+ require(['multiSelect'], function (MultiSelect) {
+ self.multiSelect = new MultiSelect({
+ container: self,
+ bindOnClick: false
+ });
+ });
+ };
+
function onDrop(evt, itemsContainer) {
- var el = evt.item,
- newIndex = evt.newIndex,
- itemId = el.getAttribute("data-playlistitemid"),
- playlistId = el.getAttribute("data-playlistid");
+
+ var el = evt.item;
+
+ var newIndex = evt.newIndex;
+ var itemId = el.getAttribute('data-playlistitemid');
+ var playlistId = el.getAttribute('data-playlistid');
+
if (!playlistId) {
+
var oldIndex = evt.oldIndex;
- return void el.dispatchEvent(new CustomEvent("itemdrop", {
+
+ el.dispatchEvent(new CustomEvent('itemdrop', {
detail: {
oldIndex: oldIndex,
newIndex: newIndex,
playlistItemId: itemId
},
- bubbles: !0,
- cancelable: !1
- }))
+ bubbles: true,
+ cancelable: false
+ }));
+ return;
}
- var serverId = el.getAttribute("data-serverid"),
- apiClient = connectionManager.getApiClient(serverId);
- loading.show(), apiClient.ajax({
- url: apiClient.getUrl("Playlists/" + playlistId + "/Items/" + itemId + "/Move/" + newIndex),
- type: "POST"
- }).then(function() {
- loading.hide()
- }, function() {
- loading.hide(), itemsContainer.refreshItems()
- })
+
+ var serverId = el.getAttribute('data-serverid');
+ var apiClient = connectionManager.getApiClient(serverId);
+
+ loading.show();
+
+ apiClient.ajax({
+
+ url: apiClient.getUrl('Playlists/' + playlistId + '/Items/' + itemId + '/Move/' + newIndex),
+
+ type: 'POST'
+
+ }).then(function () {
+
+ loading.hide();
+
+ }, function () {
+
+ loading.hide();
+
+ itemsContainer.refreshItems();
+ });
}
- function onUserDataChanged(e, apiClient, userData) {
- var itemsContainer = this;
- require(["cardBuilder"], function(cardBuilder) {
- cardBuilder.onUserDataChanged(userData, itemsContainer)
+ ItemsContainerProtoType.enableDragReordering = function (enabled) {
+
+ var current = this.sortable;
+
+ if (!enabled) {
+ if (current) {
+ current.destroy();
+ this.sortable = null;
+ }
+ return;
+ }
+
+ if (current) {
+ return;
+ }
+
+ var self = this;
+ require(['sortable'], function (Sortable) {
+
+ self.sortable = new Sortable(self, {
+
+ draggable: ".listItem",
+ handle: '.listViewDragHandle',
+
+ // dragging ended
+ onEnd: function (/**Event*/evt) {
+
+ return onDrop(evt, self);
+ }
+ });
});
- var eventsToMonitor = getEventsToMonitor(itemsContainer); - 1 !== eventsToMonitor.indexOf("markfavorite") ? itemsContainer.notifyRefreshNeeded() : -1 !== eventsToMonitor.indexOf("markplayed") && itemsContainer.notifyRefreshNeeded()
+ };
+
+ function onUserDataChanged(e, apiClient, userData) {
+
+ var itemsContainer = this;
+
+ require(['cardBuilder'], function (cardBuilder) {
+ cardBuilder.onUserDataChanged(userData, itemsContainer);
+ });
+
+ var eventsToMonitor = getEventsToMonitor(itemsContainer);
+
+ // TODO: Check user data change reason?
+ if (eventsToMonitor.indexOf('markfavorite') !== -1) {
+
+ itemsContainer.notifyRefreshNeeded();
+ }
+ else if (eventsToMonitor.indexOf('markplayed') !== -1) {
+
+ itemsContainer.notifyRefreshNeeded();
+ }
}
function getEventsToMonitor(itemsContainer) {
- var monitor = itemsContainer.getAttribute("data-monitor");
- return monitor ? monitor.split(",") : []
+
+ var monitor = itemsContainer.getAttribute('data-monitor');
+ if (monitor) {
+ return monitor.split(',');
+ }
+
+ return [];
}
function onTimerCreated(e, apiClient, data) {
+
var itemsContainer = this;
- if (-1 !== getEventsToMonitor(itemsContainer).indexOf("timers")) return void itemsContainer.notifyRefreshNeeded();
- var programId = data.ProgramId,
- newTimerId = data.Id;
- require(["cardBuilder"], function(cardBuilder) {
- cardBuilder.onTimerCreated(programId, newTimerId, itemsContainer)
- })
+
+ if (getEventsToMonitor(itemsContainer).indexOf('timers') !== -1) {
+
+ itemsContainer.notifyRefreshNeeded();
+ return;
+ }
+
+ var programId = data.ProgramId;
+ // This could be null, not supported by all tv providers
+ var newTimerId = data.Id;
+
+ require(['cardBuilder'], function (cardBuilder) {
+ cardBuilder.onTimerCreated(programId, newTimerId, itemsContainer);
+ });
}
function onSeriesTimerCreated(e, apiClient, data) {
+
var itemsContainer = this;
- if (-1 !== getEventsToMonitor(itemsContainer).indexOf("seriestimers")) return void itemsContainer.notifyRefreshNeeded()
+ if (getEventsToMonitor(itemsContainer).indexOf('seriestimers') !== -1) {
+
+ itemsContainer.notifyRefreshNeeded();
+ return;
+ }
}
function onTimerCancelled(e, apiClient, data) {
var itemsContainer = this;
- if (-1 !== getEventsToMonitor(itemsContainer).indexOf("timers")) return void itemsContainer.notifyRefreshNeeded();
+
+ if (getEventsToMonitor(itemsContainer).indexOf('timers') !== -1) {
+
+ itemsContainer.notifyRefreshNeeded();
+ return;
+ }
+
var id = data.Id;
- require(["cardBuilder"], function(cardBuilder) {
- cardBuilder.onTimerCancelled(id, itemsContainer)
- })
+
+ require(['cardBuilder'], function (cardBuilder) {
+ cardBuilder.onTimerCancelled(id, itemsContainer);
+ });
}
function onSeriesTimerCancelled(e, apiClient, data) {
+
var itemsContainer = this;
- if (-1 !== getEventsToMonitor(itemsContainer).indexOf("seriestimers")) return void itemsContainer.notifyRefreshNeeded();
+ if (getEventsToMonitor(itemsContainer).indexOf('seriestimers') !== -1) {
+
+ itemsContainer.notifyRefreshNeeded();
+ return;
+ }
+
var id = data.Id;
- require(["cardBuilder"], function(cardBuilder) {
- cardBuilder.onSeriesTimerCancelled(id, itemsContainer)
- })
+
+ require(['cardBuilder'], function (cardBuilder) {
+ cardBuilder.onSeriesTimerCancelled(id, itemsContainer);
+ });
}
function onLibraryChanged(e, apiClient, data) {
- var itemsContainer = this,
- eventsToMonitor = getEventsToMonitor(itemsContainer);
- if (-1 === eventsToMonitor.indexOf("seriestimers") && -1 === eventsToMonitor.indexOf("timers")) {
- var itemsAdded = data.ItemsAdded || [],
- itemsRemoved = data.ItemsRemoved || [];
- if (itemsAdded.length || itemsRemoved.length) {
- var parentId = itemsContainer.getAttribute("data-parentid");
- if (parentId) {
- var foldersAddedTo = data.FoldersAddedTo || [],
- foldersRemovedFrom = data.FoldersRemovedFrom || [],
- collectionFolders = data.CollectionFolders || [];
- if (-1 === foldersAddedTo.indexOf(parentId) && -1 === foldersRemovedFrom.indexOf(parentId) && -1 === collectionFolders.indexOf(parentId)) return
- }
- itemsContainer.notifyRefreshNeeded()
+
+ var itemsContainer = this;
+ var eventsToMonitor = getEventsToMonitor(itemsContainer);
+ if (eventsToMonitor.indexOf('seriestimers') !== -1 || eventsToMonitor.indexOf('timers') !== -1) {
+
+ // yes this is an assumption
+ return;
+ }
+
+ var itemsAdded = data.ItemsAdded || [];
+ var itemsRemoved = data.ItemsRemoved || [];
+ if (!itemsAdded.length && !itemsRemoved.length) {
+ return;
+ }
+
+ var parentId = itemsContainer.getAttribute('data-parentid');
+ if (parentId) {
+ var foldersAddedTo = data.FoldersAddedTo || [];
+ var foldersRemovedFrom = data.FoldersRemovedFrom || [];
+ var collectionFolders = data.CollectionFolders || [];
+
+ if (foldersAddedTo.indexOf(parentId) === -1 && foldersRemovedFrom.indexOf(parentId) === -1 && collectionFolders.indexOf(parentId) === -1) {
+ return;
+ }
+ }
+
+ itemsContainer.notifyRefreshNeeded();
+ }
+
+ function onPlaybackStopped(e, stopInfo) {
+
+ var itemsContainer = this;
+
+ var state = stopInfo.state;
+
+ var eventsToMonitor = getEventsToMonitor(itemsContainer);
+ if (state.NowPlayingItem && state.NowPlayingItem.MediaType === 'Video') {
+
+ if (eventsToMonitor.indexOf('videoplayback') !== -1) {
+
+ itemsContainer.notifyRefreshNeeded(true);
+ return;
+ }
+ }
+
+ else if (state.NowPlayingItem && state.NowPlayingItem.MediaType === 'Audio') {
+
+ if (eventsToMonitor.indexOf('audioplayback') !== -1) {
+
+ itemsContainer.notifyRefreshNeeded(true);
+ return;
}
}
}
- function onPlaybackStopped(e, stopInfo) {
- var itemsContainer = this,
- state = stopInfo.state,
- eventsToMonitor = getEventsToMonitor(itemsContainer);
- if (state.NowPlayingItem && "Video" === state.NowPlayingItem.MediaType) {
- if (-1 !== eventsToMonitor.indexOf("videoplayback")) return void itemsContainer.notifyRefreshNeeded(!0)
- } else if (state.NowPlayingItem && "Audio" === state.NowPlayingItem.MediaType && -1 !== eventsToMonitor.indexOf("audioplayback")) return void itemsContainer.notifyRefreshNeeded(!0)
- }
-
function addNotificationEvent(instance, name, handler, owner) {
+
var localHandler = handler.bind(instance);
- owner = owner || serverNotifications, events.on(owner, name, localHandler), instance["event_" + name] = localHandler
+ owner = owner || serverNotifications;
+ events.on(owner, name, localHandler);
+ instance['event_' + name] = localHandler;
}
function removeNotificationEvent(instance, name, owner) {
- var handler = instance["event_" + name];
- handler && (owner = owner || serverNotifications, events.off(owner, name, handler), instance["event_" + name] = null)
+
+ var handler = instance['event_' + name];
+ if (handler) {
+ owner = owner || serverNotifications;
+ events.off(owner, name, handler);
+ instance['event_' + name] = null;
+ }
}
+ ItemsContainerProtoType.createdCallback = function () {
+
+ this.classList.add('itemsContainer');
+ };
+
+ ItemsContainerProtoType.attachedCallback = function () {
+
+ this.addEventListener('click', onClick);
+
+ if (browser.touch) {
+ this.addEventListener('contextmenu', disableEvent);
+ } else {
+ if (this.getAttribute('data-contextmenu') !== 'false') {
+ this.addEventListener('contextmenu', onContextMenu);
+ }
+ }
+
+ if (layoutManager.desktop || layoutManager.mobile) {
+ if (this.getAttribute('data-multiselect') !== 'false') {
+ this.enableMultiSelect(true);
+ }
+ }
+
+ if (layoutManager.tv) {
+ this.classList.add('itemsContainer-tv');
+ }
+
+ itemShortcuts.on(this, getShortcutOptions());
+
+ addNotificationEvent(this, 'UserDataChanged', onUserDataChanged);
+ addNotificationEvent(this, 'TimerCreated', onTimerCreated);
+ addNotificationEvent(this, 'SeriesTimerCreated', onSeriesTimerCreated);
+ addNotificationEvent(this, 'TimerCancelled', onTimerCancelled);
+ addNotificationEvent(this, 'SeriesTimerCancelled', onSeriesTimerCancelled);
+ addNotificationEvent(this, 'LibraryChanged', onLibraryChanged);
+ addNotificationEvent(this, 'playbackstop', onPlaybackStopped, playbackManager);
+
+ if (this.getAttribute('data-dragreorder') === 'true') {
+ this.enableDragReordering(true);
+ }
+ };
+
+ ItemsContainerProtoType.detachedCallback = function () {
+
+ clearRefreshInterval(this);
+
+ this.enableMultiSelect(false);
+ this.enableDragReordering(false);
+ this.removeEventListener('click', onClick);
+ this.removeEventListener('contextmenu', onContextMenu);
+ this.removeEventListener('contextmenu', disableEvent);
+ itemShortcuts.off(this, getShortcutOptions());
+
+ removeNotificationEvent(this, 'UserDataChanged');
+ removeNotificationEvent(this, 'TimerCreated');
+ removeNotificationEvent(this, 'SeriesTimerCreated');
+ removeNotificationEvent(this, 'TimerCancelled');
+ removeNotificationEvent(this, 'SeriesTimerCancelled');
+ removeNotificationEvent(this, 'LibraryChanged');
+ removeNotificationEvent(this, 'playbackstop', playbackManager);
+
+ this.fetchData = null;
+ this.getItemsHtml = null;
+ this.parentContainer = null;
+ };
+
+ ItemsContainerProtoType.pause = function () {
+
+ clearRefreshInterval(this, true);
+
+ this.paused = true;
+ };
+
+ ItemsContainerProtoType.resume = function (options) {
+
+ this.paused = false;
+
+ var refreshIntervalEndTime = this.refreshIntervalEndTime;
+ if (refreshIntervalEndTime) {
+
+ var remainingMs = refreshIntervalEndTime - new Date().getTime();
+ if (remainingMs > 0 && !this.needsRefresh) {
+
+ resetRefreshInterval(this, remainingMs);
+
+ } else {
+ this.needsRefresh = true;
+ this.refreshIntervalEndTime = null;
+ }
+ }
+
+ if (this.needsRefresh || (options && options.refresh)) {
+ return this.refreshItems();
+ }
+
+ return Promise.resolve();
+ };
+
+ ItemsContainerProtoType.refreshItems = function () {
+
+ if (!this.fetchData) {
+ return Promise.resolve();
+ }
+
+ if (this.paused) {
+ this.needsRefresh = true;
+ return Promise.resolve();
+ }
+
+ this.needsRefresh = false;
+
+ return this.fetchData().then(onDataFetched.bind(this));
+ };
+
+ ItemsContainerProtoType.notifyRefreshNeeded = function (isInForeground) {
+
+ if (this.paused) {
+ this.needsRefresh = true;
+ return;
+ }
+
+ var timeout = this.refreshTimeout;
+ if (timeout) {
+ clearTimeout(timeout);
+ }
+
+ if (isInForeground === true) {
+ this.refreshItems();
+ } else {
+ this.refreshTimeout = setTimeout(this.refreshItems.bind(this), 10000);
+ }
+ };
+
function clearRefreshInterval(itemsContainer, isPausing) {
- itemsContainer.refreshInterval && (clearInterval(itemsContainer.refreshInterval), itemsContainer.refreshInterval = null, isPausing || (itemsContainer.refreshIntervalEndTime = null))
+
+ if (itemsContainer.refreshInterval) {
+
+ clearInterval(itemsContainer.refreshInterval);
+ itemsContainer.refreshInterval = null;
+
+ if (!isPausing) {
+ itemsContainer.refreshIntervalEndTime = null;
+ }
+ }
}
function resetRefreshInterval(itemsContainer, intervalMs) {
- clearRefreshInterval(itemsContainer), intervalMs || (intervalMs = parseInt(itemsContainer.getAttribute("data-refreshinterval") || "0")), intervalMs && (itemsContainer.refreshInterval = setInterval(itemsContainer.notifyRefreshNeeded.bind(itemsContainer), intervalMs), itemsContainer.refreshIntervalEndTime = (new Date).getTime() + intervalMs)
+
+ clearRefreshInterval(itemsContainer);
+
+ if (!intervalMs) {
+ intervalMs = parseInt(itemsContainer.getAttribute('data-refreshinterval') || '0');
+ }
+
+ if (intervalMs) {
+ itemsContainer.refreshInterval = setInterval(itemsContainer.notifyRefreshNeeded.bind(itemsContainer), intervalMs);
+ itemsContainer.refreshIntervalEndTime = new Date().getTime() + intervalMs;
+ }
}
function onDataFetched(result) {
- var items = result.Items || result,
- parentContainer = this.parentContainer;
- parentContainer && (items.length ? parentContainer.classList.remove("hide") : parentContainer.classList.add("hide"));
- var focusId, hasActiveElement, activeElement = document.activeElement;
- this.contains(activeElement) && (hasActiveElement = !0, focusId = activeElement.getAttribute("data-id")), this.innerHTML = this.getItemsHtml(items), imageLoader.lazyChildren(this), hasActiveElement && setFocus(this, focusId), resetRefreshInterval(this), this.afterRefresh && this.afterRefresh(result)
+
+ var items = result.Items || result;
+
+ var parentContainer = this.parentContainer;
+ if (parentContainer) {
+ if (items.length) {
+ parentContainer.classList.remove('hide');
+ } else {
+ parentContainer.classList.add('hide');
+ }
+ }
+
+ // Scroll back up so they can see the results from the beginning
+ // TODO: Find scroller
+ //window.scrollTo(0, 0);
+
+ var activeElement = document.activeElement;
+ var focusId;
+ var hasActiveElement;
+
+ if (this.contains(activeElement)) {
+ hasActiveElement = true;
+ focusId = activeElement.getAttribute('data-id');
+ }
+
+ this.innerHTML = this.getItemsHtml(items);
+
+ imageLoader.lazyChildren(this);
+
+ if (hasActiveElement) {
+ setFocus(this, focusId);
+ }
+
+ resetRefreshInterval(this);
+
+ if (this.afterRefresh) {
+ this.afterRefresh(result);
+ }
}
function setFocus(itemsContainer, focusId) {
if (focusId) {
var newElement = itemsContainer.querySelector('[data-id="' + focusId + '"]');
- if (newElement) try {
- return void focusManager.focus(newElement)
- } catch (err) {}
+ if (newElement) {
+
+ try {
+ focusManager.focus(newElement);
+ return;
+ }
+ catch (err) {
+ }
+ }
}
- focusManager.autoFocus(itemsContainer)
+
+ focusManager.autoFocus(itemsContainer);
}
- var ItemsContainerProtoType = Object.create(HTMLDivElement.prototype);
- ItemsContainerProtoType.enableMultiSelect = function(enabled) {
- var current = this.multiSelect;
- if (!enabled) return void(current && (current.destroy(), this.multiSelect = null));
- if (!current) {
- var self = this;
- require(["multiSelect"], function(MultiSelect) {
- self.multiSelect = new MultiSelect({
- container: self,
- bindOnClick: !1
- })
- })
- }
- }, ItemsContainerProtoType.enableDragReordering = function(enabled) {
- var current = this.sortable;
- if (!enabled) return void(current && (current.destroy(), this.sortable = null));
- if (!current) {
- var self = this;
- require(["sortable"], function(Sortable) {
- self.sortable = new Sortable(self, {
- draggable: ".listItem",
- handle: ".listViewDragHandle",
- onEnd: function(evt) {
- return onDrop(evt, self)
- }
- })
- })
- }
- }, ItemsContainerProtoType.createdCallback = function() {
- this.classList.add("itemsContainer")
- }, ItemsContainerProtoType.attachedCallback = function() {
- this.addEventListener("click", onClick), browser.touch ? this.addEventListener("contextmenu", disableEvent) : "false" !== this.getAttribute("data-contextmenu") && this.addEventListener("contextmenu", onContextMenu), (layoutManager.desktop || layoutManager.mobile) && "false" !== this.getAttribute("data-multiselect") && this.enableMultiSelect(!0), layoutManager.tv && this.classList.add("itemsContainer-tv"), itemShortcuts.on(this, getShortcutOptions()), addNotificationEvent(this, "UserDataChanged", onUserDataChanged), addNotificationEvent(this, "TimerCreated", onTimerCreated), addNotificationEvent(this, "SeriesTimerCreated", onSeriesTimerCreated), addNotificationEvent(this, "TimerCancelled", onTimerCancelled), addNotificationEvent(this, "SeriesTimerCancelled", onSeriesTimerCancelled), addNotificationEvent(this, "LibraryChanged", onLibraryChanged), addNotificationEvent(this, "playbackstop", onPlaybackStopped, playbackManager), "true" === this.getAttribute("data-dragreorder") && this.enableDragReordering(!0)
- }, ItemsContainerProtoType.detachedCallback = function() {
- clearRefreshInterval(this), this.enableMultiSelect(!1), this.enableDragReordering(!1), this.removeEventListener("click", onClick), this.removeEventListener("contextmenu", onContextMenu), this.removeEventListener("contextmenu", disableEvent), itemShortcuts.off(this, getShortcutOptions()), removeNotificationEvent(this, "UserDataChanged"), removeNotificationEvent(this, "TimerCreated"), removeNotificationEvent(this, "SeriesTimerCreated"), removeNotificationEvent(this, "TimerCancelled"), removeNotificationEvent(this, "SeriesTimerCancelled"), removeNotificationEvent(this, "LibraryChanged"), removeNotificationEvent(this, "playbackstop", playbackManager), this.fetchData = null, this.getItemsHtml = null, this.parentContainer = null
- }, ItemsContainerProtoType.pause = function() {
- clearRefreshInterval(this, !0), this.paused = !0
- }, ItemsContainerProtoType.resume = function(options) {
- this.paused = !1;
- var refreshIntervalEndTime = this.refreshIntervalEndTime;
- if (refreshIntervalEndTime) {
- var remainingMs = refreshIntervalEndTime - (new Date).getTime();
- remainingMs > 0 && !this.needsRefresh ? resetRefreshInterval(this, remainingMs) : (this.needsRefresh = !0, this.refreshIntervalEndTime = null)
- }
- return this.needsRefresh || options && options.refresh ? this.refreshItems() : Promise.resolve()
- }, ItemsContainerProtoType.refreshItems = function() {
- return this.fetchData ? this.paused ? (this.needsRefresh = !0, Promise.resolve()) : (this.needsRefresh = !1, this.fetchData().then(onDataFetched.bind(this))) : Promise.resolve()
- }, ItemsContainerProtoType.notifyRefreshNeeded = function(isInForeground) {
- if (this.paused) return void(this.needsRefresh = !0);
- var timeout = this.refreshTimeout;
- timeout && clearTimeout(timeout), !0 === isInForeground ? this.refreshItems() : this.refreshTimeout = setTimeout(this.refreshItems.bind(this), 1e4)
- }, document.registerElement("emby-itemscontainer", {
+
+ document.registerElement('emby-itemscontainer', {
prototype: ItemsContainerProtoType,
- extends: "div"
- })
+ extends: 'div'
+ });
});
\ No newline at end of file
diff --git a/src/bower_components/emby-webcomponents/emby-progressring/emby-progressring.css b/src/bower_components/emby-webcomponents/emby-progressring/emby-progressring.css
index 5edd2cfa21..11c05ab518 100644
--- a/src/bower_components/emby-webcomponents/emby-progressring/emby-progressring.css
+++ b/src/bower_components/emby-webcomponents/emby-progressring/emby-progressring.css
@@ -1,157 +1,105 @@
-.progressring {
+.progressring {
position: relative;
width: 2.6em;
height: 2.6em;
float: left;
- -webkit-user-select: none;
- -moz-user-select: none;
- -ms-user-select: none;
user-select: none;
- -webkit-box-sizing: border-box;
- box-sizing: border-box
+ box-sizing: border-box;
}
.progressring-bg {
width: 100%;
height: 100%;
- -webkit-border-radius: 50%;
border-radius: 50%;
border: .25em solid rgba(0, 0, 0, 1);
- -webkit-box-sizing: border-box;
box-sizing: border-box;
background: rgba(0, 0, 0, .9);
- display: -webkit-box;
- display: -webkit-flex;
display: flex;
- -webkit-box-align: center;
- -webkit-align-items: center;
align-items: center;
- -webkit-box-pack: center;
- -webkit-justify-content: center;
- justify-content: center
-}
-
-.spiner-holder-one,
-.spiner-holder-two {
- position: absolute;
- top: 0;
- left: 0;
- overflow: hidden;
- background: 0 0;
- -webkit-box-sizing: border-box
+ justify-content: center;
}
.progressring-text {
text-align: center;
color: #ddd;
- font-size: 90%
+ font-size: 90%;
}
.spiner-holder-one {
+ position: absolute;
+ top: 0;
+ left: 0;
+ overflow: hidden;
width: 51%;
height: 51%;
- box-sizing: border-box
+ background: transparent;
+ box-sizing: border-box;
}
.spiner-holder-two {
+ position: absolute;
+ top: 0;
+ left: 0;
+ overflow: hidden;
width: 100%;
height: 100%;
- box-sizing: border-box
+ background: transparent;
+ box-sizing: border-box;
}
.progressring-spiner {
width: 200%;
height: 200%;
- -webkit-border-radius: 50%;
border-radius: 50%;
border-width: .25em;
border-style: solid;
- -webkit-box-sizing: border-box;
- box-sizing: border-box
+ box-sizing: border-box;
}
.animate-0-25-a {
- -webkit-transform: rotate(90deg);
transform: rotate(90deg);
- -webkit-transform-origin: 100% 100%;
transform-origin: 100% 100%;
- -webkit-transition: -webkit-transform 180ms ease-out;
- -o-transition: transform 180ms ease-out;
- transition: transform 180ms ease-out
-}
-
-.animate-0-25-b,
-.animate-25-50-a {
- -webkit-transition: -webkit-transform 180ms ease-out;
- -o-transition: transform 180ms ease-out
+ transition: transform 180ms ease-out;
}
.animate-0-25-b {
- -webkit-transform: rotate(-90deg);
transform: rotate(-90deg);
- -webkit-transform-origin: 100% 100%;
transform-origin: 100% 100%;
- transition: transform 180ms ease-out
+ transition: transform 180ms ease-out;
}
.animate-25-50-a {
- -webkit-transform: rotate(180deg);
transform: rotate(180deg);
- -webkit-transform-origin: 100% 100%;
transform-origin: 100% 100%;
- transition: transform 180ms ease-out
-}
-
-.animate-25-50-b,
-.animate-50-75-a {
- -webkit-transition: -webkit-transform 180ms ease-out;
- -o-transition: transform 180ms ease-out
+ transition: transform 180ms ease-out;
}
.animate-25-50-b {
- -webkit-transform: rotate(-90deg);
transform: rotate(-90deg);
- -webkit-transform-origin: 100% 100%;
transform-origin: 100% 100%;
- transition: transform 180ms ease-out
+ transition: transform 180ms ease-out;
}
.animate-50-75-a {
- -webkit-transform: rotate(270deg);
transform: rotate(270deg);
- -webkit-transform-origin: 100% 100%;
transform-origin: 100% 100%;
- transition: transform 180ms ease-out
-}
-
-.animate-50-75-b,
-.animate-75-100-a {
- -webkit-transition: -webkit-transform 180ms ease-out;
- -o-transition: transform 180ms ease-out
+ transition: transform 180ms ease-out;
}
.animate-50-75-b {
- -webkit-transform: rotate(-90deg);
transform: rotate(-90deg);
- -webkit-transform-origin: 100% 100%;
transform-origin: 100% 100%;
- transition: transform 180ms ease-out
+ transition: transform 180ms ease-out;
}
.animate-75-100-a {
- -webkit-transform: rotate(0);
- transform: rotate(0);
- -webkit-transform-origin: 100% 100%;
+ transform: rotate(0deg);
transform-origin: 100% 100%;
- transition: transform 180ms ease-out
+ transition: transform 180ms ease-out;
}
.animate-75-100-b {
- -webkit-transform: rotate(-90deg);
transform: rotate(-90deg);
- -webkit-transform-origin: 100% 100%;
transform-origin: 100% 100%;
- -webkit-transition: -webkit-transform 180ms ease-out;
- -o-transition: transform 180ms ease-out;
- transition: transform 180ms ease-out
-}
\ No newline at end of file
+ transition: transform 180ms ease-out;
+}
diff --git a/src/bower_components/emby-webcomponents/emby-progressring/emby-progressring.js b/src/bower_components/emby-webcomponents/emby-progressring/emby-progressring.js
index c5358f32e2..feb4ddb20d 100644
--- a/src/bower_components/emby-webcomponents/emby-progressring/emby-progressring.js
+++ b/src/bower_components/emby-webcomponents/emby-progressring/emby-progressring.js
@@ -1,21 +1,105 @@
-define(["require", "css!./emby-progressring", "registerElement"], function(require) {
- "use strict";
+define(['require', 'css!./emby-progressring', 'registerElement'], function (require) {
+ 'use strict';
+
var EmbyProgressRing = Object.create(HTMLDivElement.prototype);
- return EmbyProgressRing.createdCallback = function() {
- this.classList.add("progressring");
+
+ EmbyProgressRing.createdCallback = function () {
+
+ this.classList.add('progressring');
var instance = this;
- require(["text!./emby-progressring.template.html"], function(template) {
- instance.innerHTML = template, instance.setProgress(parseFloat(instance.getAttribute("data-progress") || "0"))
- })
- }, EmbyProgressRing.setProgress = function(progress) {
+
+ require(['text!./emby-progressring.template.html'], function (template) {
+ instance.innerHTML = template;
+
+ //if (window.MutationObserver) {
+ // // create an observer instance
+ // var observer = new MutationObserver(function (mutations) {
+ // mutations.forEach(function (mutation) {
+
+ // instance.setProgress(parseFloat(instance.getAttribute('data-progress') || '0'));
+ // });
+ // });
+
+ // // configuration of the observer:
+ // var config = { attributes: true, childList: false, characterData: false };
+
+ // // pass in the target node, as well as the observer options
+ // observer.observe(instance, config);
+
+ // instance.observer = observer;
+ //}
+
+ instance.setProgress(parseFloat(instance.getAttribute('data-progress') || '0'));
+ });
+ };
+
+ EmbyProgressRing.setProgress = function (progress) {
+
progress = Math.floor(progress);
+
var angle;
- progress < 25 ? (angle = progress / 100 * 360 - 90, this.querySelector(".animate-0-25-b").style.transform = "rotate(" + angle + "deg)", this.querySelector(".animate-25-50-b").style.transform = "rotate(-90deg)", this.querySelector(".animate-50-75-b").style.transform = "rotate(-90deg)", this.querySelector(".animate-75-100-b").style.transform = "rotate(-90deg)") : progress >= 25 && progress < 50 ? (angle = (progress - 25) / 100 * 360 - 90, this.querySelector(".animate-0-25-b").style.transform = "none", this.querySelector(".animate-25-50-b").style.transform = "rotate(" + angle + "deg)", this.querySelector(".animate-50-75-b").style.transform = "rotate(-90deg)", this.querySelector(".animate-75-100-b").style.transform = "rotate(-90deg)") : progress >= 50 && progress < 75 ? (angle = (progress - 50) / 100 * 360 - 90, this.querySelector(".animate-0-25-b").style.transform = "none", this.querySelector(".animate-25-50-b").style.transform = "none", this.querySelector(".animate-50-75-b").style.transform = "rotate(" + angle + "deg)", this.querySelector(".animate-75-100-b").style.transform = "rotate(-90deg)") : progress >= 75 && progress <= 100 && (angle = (progress - 75) / 100 * 360 - 90, this.querySelector(".animate-0-25-b").style.transform = "none", this.querySelector(".animate-25-50-b").style.transform = "none", this.querySelector(".animate-50-75-b").style.transform = "none", this.querySelector(".animate-75-100-b").style.transform = "rotate(" + angle + "deg)"), this.querySelector(".progressring-text").innerHTML = progress + "%"
- }, EmbyProgressRing.attachedCallback = function() {}, EmbyProgressRing.detachedCallback = function() {
+
+ if (progress < 25) {
+ angle = -90 + (progress / 100) * 360;
+
+ this.querySelector('.animate-0-25-b').style.transform = 'rotate(' + angle + 'deg)';
+
+ this.querySelector('.animate-25-50-b').style.transform = 'rotate(-90deg)';
+ this.querySelector('.animate-50-75-b').style.transform = 'rotate(-90deg)';
+ this.querySelector('.animate-75-100-b').style.transform = 'rotate(-90deg)';
+ }
+ else if (progress >= 25 && progress < 50) {
+
+ angle = -90 + ((progress - 25) / 100) * 360;
+
+ this.querySelector('.animate-0-25-b').style.transform = 'none';
+ this.querySelector('.animate-25-50-b').style.transform = 'rotate(' + angle + 'deg)';
+
+ this.querySelector('.animate-50-75-b').style.transform = 'rotate(-90deg)';
+ this.querySelector('.animate-75-100-b').style.transform = 'rotate(-90deg)';
+ }
+ else if (progress >= 50 && progress < 75) {
+ angle = -90 + ((progress - 50) / 100) * 360;
+
+ this.querySelector('.animate-0-25-b').style.transform = 'none';
+ this.querySelector('.animate-25-50-b').style.transform = 'none';
+ this.querySelector('.animate-50-75-b').style.transform = 'rotate(' + angle + 'deg)';
+
+ this.querySelector('.animate-75-100-b').style.transform = 'rotate(-90deg)';
+ }
+ else if (progress >= 75 && progress <= 100) {
+ angle = -90 + ((progress - 75) / 100) * 360;
+
+ this.querySelector('.animate-0-25-b').style.transform = 'none';
+ this.querySelector('.animate-25-50-b').style.transform = 'none';
+ this.querySelector('.animate-50-75-b').style.transform = 'none';
+ this.querySelector('.animate-75-100-b').style.transform = 'rotate(' + angle + 'deg)';
+ }
+
+ this.querySelector('.progressring-text').innerHTML = progress + '%';
+ };
+
+ EmbyProgressRing.attachedCallback = function () {
+
+ };
+
+ EmbyProgressRing.detachedCallback = function () {
+
+
var observer = this.observer;
- observer && (observer.disconnect(), this.observer = null)
- }, document.registerElement("emby-progressring", {
+
+ if (observer) {
+ // later, you can stop observing
+ observer.disconnect();
+
+ this.observer = null;
+ }
+ };
+
+ document.registerElement('emby-progressring', {
prototype: EmbyProgressRing,
- extends: "div"
- }), EmbyProgressRing
+ extends: 'div'
+ });
+
+ return EmbyProgressRing;
});
\ No newline at end of file
diff --git a/src/bower_components/emby-webcomponents/emby-radio/emby-radio.css b/src/bower_components/emby-webcomponents/emby-radio/emby-radio.css
index 382919ac1f..25fdc5b933 100644
--- a/src/bower_components/emby-webcomponents/emby-radio/emby-radio.css
+++ b/src/bower_components/emby-webcomponents/emby-radio/emby-radio.css
@@ -2,26 +2,26 @@
position: relative;
line-height: 24px;
display: inline-block;
- -webkit-box-sizing: border-box;
box-sizing: border-box;
margin: 0;
- padding-left: 24px
+ padding-left: 0;
}
.radio-label-block {
- display: -webkit-box;
- display: -webkit-flex;
display: flex;
- -webkit-box-align: center;
- -webkit-align-items: center;
align-items: center;
margin-top: .5em;
- margin-bottom: .5em
+ margin-bottom: .5em;
+}
+
+.mdl-radio {
+ padding-left: 24px;
}
.mdl-radio__button {
line-height: 24px;
position: absolute;
+ /* 1px is for focusing purposes, so the focusManager doesn't skip over it */
width: 1px;
height: 1px;
margin: 0;
@@ -31,7 +31,7 @@
-moz-appearance: none;
-webkit-appearance: none;
appearance: none;
- border: none
+ border: none;
}
.mdl-radio__outer-circle {
@@ -39,25 +39,23 @@
top: 4px;
left: 0;
display: inline-block;
- -webkit-box-sizing: border-box;
box-sizing: border-box;
width: 16px;
height: 16px;
margin: 0;
cursor: pointer;
border: 2px solid currentcolor;
- -webkit-border-radius: 50%;
border-radius: 50%;
- z-index: 2
+ z-index: 2;
}
-.mdl-radio__button:checked+.mdl-radio__label+.mdl-radio__outer-circle {
- border: 2px solid #00a4dc
+.mdl-radio__button:checked + .mdl-radio__label + .mdl-radio__outer-circle {
+ border: 2px solid #00a4dc;
}
-.mdl-radio__button:disabled+.mdl-radio__label+.mdl-radio__outer-circle {
- border: 2px solid rgba(0, 0, 0, .26);
- cursor: auto
+.mdl-radio__button:disabled + .mdl-radio__label + .mdl-radio__outer-circle {
+ border: 2px solid rgba(0,0,0, 0.26);
+ cursor: auto;
}
.mdl-radio__inner-circle {
@@ -66,52 +64,44 @@
margin: 0;
top: 8px;
left: 4px;
- -webkit-box-sizing: border-box;
box-sizing: border-box;
width: 8px;
height: 8px;
cursor: pointer;
- -webkit-transition-duration: .28s;
- -o-transition-duration: .28s;
- transition-duration: .28s;
- -webkit-transition-timing-function: cubic-bezier(.4, 0, .2, 1);
- -o-transition-timing-function: cubic-bezier(.4, 0, .2, 1);
- transition-timing-function: cubic-bezier(.4, 0, .2, 1);
- -o-transition-property: transform;
- -webkit-transition-property: -webkit-transform, -webkit-transform;
+ transition-duration: 0.28s;
+ transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
+ transition-property: -webkit-transform;
+ transition-property: transform;
transition-property: transform, -webkit-transform;
-webkit-transform: scale3d(0, 0, 0);
transform: scale3d(0, 0, 0);
- -webkit-border-radius: 50%;
border-radius: 50%;
- background: #00a4dc
+ background: #00a4dc;
}
-.mdl-radio__button:checked+.mdl-radio__label+.mdl-radio__outer-circle+.mdl-radio__inner-circle {
+.mdl-radio__button:checked + .mdl-radio__label + .mdl-radio__outer-circle + .mdl-radio__inner-circle {
-webkit-transform: scale3d(1, 1, 1);
- transform: scale3d(1, 1, 1)
+ transform: scale3d(1, 1, 1);
}
-.mdl-radio__button:disabled+.mdl-radio__label+.mdl-radio__outer-circle+.mdl-radio__inner-circle {
- background: rgba(0, 0, 0, .26);
- cursor: auto
+.mdl-radio__button:disabled + .mdl-radio__label + .mdl-radio__outer-circle + .mdl-radio__inner-circle {
+ background: rgba(0,0,0, 0.26);
+ cursor: auto;
}
-.mdl-radio__button:focus+.mdl-radio__label+.mdl-radio__outer-circle+.mdl-radio__inner-circle {
- -webkit-box-shadow: 0 0 0 10px rgba(255, 255, 255, .76);
- box-shadow: 0 0 0 10px rgba(255, 255, 255, .76)
+.mdl-radio__button:focus + .mdl-radio__label + .mdl-radio__outer-circle + .mdl-radio__inner-circle {
+ box-shadow: 0 0 0px 10px rgba(255, 255, 255, 0.76);
}
-.mdl-radio__button:checked:focus+.mdl-radio__label+.mdl-radio__outer-circle+.mdl-radio__inner-circle {
- -webkit-box-shadow: 0 0 0 10px rgba(0,164,220, .26);
- box-shadow: 0 0 0 10px rgba(0,164,220, .26)
+.mdl-radio__button:checked:focus + .mdl-radio__label + .mdl-radio__outer-circle + .mdl-radio__inner-circle {
+ box-shadow: 0 0 0 10px rgba(0, 164, 220, 0.26)
}
.mdl-radio__label {
- cursor: pointer
+ cursor: pointer;
}
-.mdl-radio__button:disabled+.mdl-radio__label {
- color: rgba(0, 0, 0, .26);
- cursor: auto
-}
\ No newline at end of file
+.mdl-radio__button:disabled + .mdl-radio__label {
+ color: rgba(0,0,0, 0.26);
+ cursor: auto;
+}
diff --git a/src/bower_components/emby-webcomponents/emby-radio/emby-radio.js b/src/bower_components/emby-webcomponents/emby-radio/emby-radio.js
index a41b3ed06d..6e3b6b9bf4 100644
--- a/src/bower_components/emby-webcomponents/emby-radio/emby-radio.js
+++ b/src/bower_components/emby-webcomponents/emby-radio/emby-radio.js
@@ -1,20 +1,48 @@
-define(["css!./emby-radio", "registerElement"], function() {
- "use strict";
+define(['css!./emby-radio', 'registerElement'], function () {
+ 'use strict';
+
+ var EmbyRadioPrototype = Object.create(HTMLInputElement.prototype);
function onKeyDown(e) {
- if (13 === e.keyCode) return e.preventDefault(), this.checked = !0, !1
- }
- var EmbyRadioPrototype = Object.create(HTMLInputElement.prototype);
- EmbyRadioPrototype.attachedCallback = function() {
- if ("true" !== this.getAttribute("data-radio")) {
- this.setAttribute("data-radio", "true"), this.classList.add("mdl-radio__button");
- var labelElement = this.parentNode;
- labelElement.classList.add("mdl-radio"), labelElement.classList.add("mdl-js-radio"), labelElement.classList.add("mdl-js-ripple-effect");
- var labelTextElement = labelElement.querySelector("span");
- labelTextElement.classList.add("radioButtonLabel"), labelTextElement.classList.add("mdl-radio__label"), labelElement.insertAdjacentHTML("beforeend", '
'), this.addEventListener("keydown", onKeyDown)
+
+ // Don't submit form on enter
+ if (e.keyCode === 13) {
+ e.preventDefault();
+
+ this.checked = true;
+
+ return false;
}
- }, document.registerElement("emby-radio", {
+ }
+
+ EmbyRadioPrototype.attachedCallback = function () {
+
+ if (this.getAttribute('data-radio') === 'true') {
+ return;
+ }
+
+ this.setAttribute('data-radio', 'true');
+
+ this.classList.add('mdl-radio__button');
+
+ var labelElement = this.parentNode;
+ //labelElement.classList.add('"mdl-radio mdl-js-radio mdl-js-ripple-effect');
+ labelElement.classList.add('mdl-radio');
+ labelElement.classList.add('mdl-js-radio');
+ labelElement.classList.add('mdl-js-ripple-effect');
+
+ var labelTextElement = labelElement.querySelector('span');
+
+ labelTextElement.classList.add('radioButtonLabel');
+ labelTextElement.classList.add('mdl-radio__label');
+
+ labelElement.insertAdjacentHTML('beforeend', '
');
+
+ this.addEventListener('keydown', onKeyDown);
+ };
+
+ document.registerElement('emby-radio', {
prototype: EmbyRadioPrototype,
- extends: "input"
- })
+ extends: 'input'
+ });
});
\ No newline at end of file
diff --git a/src/bower_components/emby-webcomponents/emby-scrollbuttons/emby-scrollbuttons.css b/src/bower_components/emby-webcomponents/emby-scrollbuttons/emby-scrollbuttons.css
index 39408352e0..5e404e780d 100644
--- a/src/bower_components/emby-webcomponents/emby-scrollbuttons/emby-scrollbuttons.css
+++ b/src/bower_components/emby-webcomponents/emby-scrollbuttons/emby-scrollbuttons.css
@@ -1,67 +1,60 @@
.emby-scrollbuttons-scroller {
- position: relative
+ position: relative;
}
.scrollbuttoncontainer {
position: absolute;
top: 0;
bottom: 0;
- -webkit-box-align: center;
- -webkit-align-items: center;
align-items: center;
- -webkit-box-pack: center;
- -webkit-justify-content: center;
justify-content: center;
z-index: 1;
font-size: 3em;
color: #fff;
display: none;
- overflow: hidden
+ overflow: hidden;
}
.scrollbuttoncontainer-left {
background: rgba(20, 20, 20, .5);
- background: -webkit-linear-gradient(left, #000 0, rgba(0, 0, 0, 0) 100%);
- background: -webkit-gradient(linear, left top, right top, from(#000), to(rgba(0, 0, 0, 0)));
- background: -webkit-linear-gradient(left, #000, rgba(0, 0, 0, 0));
- background: -o-linear-gradient(left, #000, rgba(0, 0, 0, 0));
- background: linear-gradient(to right, #000, rgba(0, 0, 0, 0));
- left: 0
+ background: -moz-linear-gradient(left,#000 0,rgba(0,0,0,0) 100%);
+ background: -webkit-linear-gradient(left,#000 0,rgba(0,0,0,0) 100%);
+ background: linear-gradient(to right,#000,rgba(0,0,0,0));
}
.scrollbuttoncontainer-right {
background: rgba(20, 20, 20, .5);
- background: -webkit-linear-gradient(right, #000 0, rgba(0, 0, 0, 0) 100%);
- background: -webkit-gradient(linear, right top, left top, from(#000), to(rgba(0, 0, 0, 0)));
- background: -webkit-linear-gradient(right, #000, rgba(0, 0, 0, 0));
- background: -o-linear-gradient(right, #000, rgba(0, 0, 0, 0));
- background: linear-gradient(to left, #000, rgba(0, 0, 0, 0));
- right: 0
+ background: -moz-linear-gradient(right,#000 0,rgba(0,0,0,0) 100%);
+ background: -webkit-linear-gradient(right,#000 0,rgba(0,0,0,0) 100%);
+ background: linear-gradient(to left,#000,rgba(0,0,0,0));
}
.emby-scrollbuttons-scroller:hover .scrollbuttoncontainer {
- display: -webkit-box;
- display: -webkit-flex;
- display: flex
+ display: flex;
+}
+
+.scrollbuttoncontainer-left {
+ left: 0;
+}
+
+.scrollbuttoncontainer-right {
+ right: 0;
}
.emby-scrollbuttons-scrollbutton {
margin: 0 -.2em;
- -webkit-transition: -webkit-transform 160ms ease-out;
- -o-transition: transform 160ms ease-out;
- transition: transform 160ms ease-out
+ transition: transform 160ms ease-out;
}
-.scrollbuttoncontainer:hover>.emby-scrollbuttons-scrollbutton {
- -webkit-transform: scale(1.3, 1.3);
- transform: scale(1.3, 1.3)
+.scrollbuttoncontainer:hover > .emby-scrollbuttons-scrollbutton {
+ transform: scale(1.3, 1.3);
}
.emby-scrollbuttons-scrollbutton:after {
content: '';
- display: none !important
+ display: none !important;
}
.emby-scrollbuttons-scrollbutton:focus {
- color: inherit !important
-}
\ No newline at end of file
+ color: inherit !important;
+}
diff --git a/src/bower_components/emby-webcomponents/emby-scrollbuttons/emby-scrollbuttons.js b/src/bower_components/emby-webcomponents/emby-scrollbuttons/emby-scrollbuttons.js
index fc9c7be825..cd285a8769 100644
--- a/src/bower_components/emby-webcomponents/emby-scrollbuttons/emby-scrollbuttons.js
+++ b/src/bower_components/emby-webcomponents/emby-scrollbuttons/emby-scrollbuttons.js
@@ -1,75 +1,201 @@
-define(["layoutManager", "dom", "css!./emby-scrollbuttons", "registerElement", "paper-icon-button-light"], function(layoutManager, dom) {
- "use strict";
+define(['layoutManager', 'dom', 'css!./emby-scrollbuttons', 'registerElement', 'paper-icon-button-light'], function (layoutManager, dom) {
+ 'use strict';
+
+ var EmbyScrollButtonsPrototype = Object.create(HTMLDivElement.prototype);
+
+ EmbyScrollButtonsPrototype.createdCallback = function () {
+
+ };
function getScrollButtonContainerHtml(direction) {
- var html = "";
- html += '
';
- var icon = "left" === direction ? "" : "";
- return html += '', html += '' + icon + " ", html += " ", html += "
"
+
+ var html = '';
+
+ var hide = direction === 'left' ? ' hide' : '';
+ html += '
';
+
+ var icon = direction === 'left' ? '' : '';
+
+ html += '';
+ html += '' + icon + ' ';
+ html += ' ';
+
+ html += '
';
+
+ return html;
}
function getScrollPosition(parent) {
- return parent.getScrollPosition ? parent.getScrollPosition() : 0
+
+ if (parent.getScrollPosition) {
+ return parent.getScrollPosition();
+ }
+
+ return 0;
}
function getScrollWidth(parent) {
- return parent.getScrollSize ? parent.getScrollSize() : 0
+
+ if (parent.getScrollSize) {
+ return parent.getScrollSize();
+ }
+
+ return 0;
}
function onScrolledToPosition(scrollButtons, pos, scrollWidth) {
- pos > 0 ? scrollButtons.scrollButtonsLeft.classList.remove("hide") : scrollButtons.scrollButtonsLeft.classList.add("hide"), scrollWidth > 0 && (pos += scrollButtons.offsetWidth, pos >= scrollWidth ? scrollButtons.scrollButtonsRight.classList.add("hide") : scrollButtons.scrollButtonsRight.classList.remove("hide"))
+
+ if (pos > 0) {
+ scrollButtons.scrollButtonsLeft.classList.remove('hide');
+ } else {
+ scrollButtons.scrollButtonsLeft.classList.add('hide');
+ }
+
+ if (scrollWidth > 0) {
+
+ pos += scrollButtons.offsetWidth;
+
+ if (pos >= scrollWidth) {
+ scrollButtons.scrollButtonsRight.classList.add('hide');
+ } else {
+ scrollButtons.scrollButtonsRight.classList.remove('hide');
+ }
+ }
}
function onScroll(e) {
- var scrollButtons = this,
- scroller = this.scroller;
- onScrolledToPosition(scrollButtons, getScrollPosition(scroller), getScrollWidth(scroller))
+
+ var scrollButtons = this;
+ var scroller = this.scroller;
+ var pos = getScrollPosition(scroller);
+ var scrollWidth = getScrollWidth(scroller);
+
+ onScrolledToPosition(scrollButtons, pos, scrollWidth);
}
function getStyleValue(style, name) {
+
var value = style.getPropertyValue(name);
- return value && (value = value.replace("px", "")) ? (value = parseInt(value), isNaN(value) ? 0 : value) : 0
+
+ if (!value) {
+ return 0;
+ }
+
+ value = value.replace('px', '');
+
+ if (!value) {
+ return 0;
+ }
+
+ value = parseInt(value);
+ if (isNaN(value)) {
+ return 0;
+ }
+
+ return value;
}
function getScrollSize(elem) {
- var scrollSize = elem.offsetWidth,
- style = window.getComputedStyle(elem, null),
- paddingLeft = getStyleValue(style, "padding-left");
- paddingLeft && (scrollSize -= paddingLeft);
- var paddingRight = getStyleValue(style, "padding-right");
- paddingRight && (scrollSize -= paddingRight);
+
+ var scrollSize = elem.offsetWidth;
+
+ var style = window.getComputedStyle(elem, null);
+
+ var paddingLeft = getStyleValue(style, 'padding-left');
+
+ if (paddingLeft) {
+ scrollSize -= paddingLeft;
+ }
+ var paddingRight = getStyleValue(style, 'padding-right');
+
+ if (paddingRight) {
+ scrollSize -= paddingRight;
+ }
+
var slider = elem.getScrollSlider();
- return style = window.getComputedStyle(slider, null), paddingLeft = getStyleValue(style, "padding-left"), paddingLeft && (scrollSize -= paddingLeft), paddingRight = getStyleValue(style, "padding-right"), paddingRight && (scrollSize -= paddingRight), scrollSize
+ style = window.getComputedStyle(slider, null);
+
+ paddingLeft = getStyleValue(style, 'padding-left');
+
+ if (paddingLeft) {
+ scrollSize -= paddingLeft;
+ }
+ paddingRight = getStyleValue(style, 'padding-right');
+
+ if (paddingRight) {
+ scrollSize -= paddingRight;
+ }
+
+ return scrollSize;
}
function onScrollButtonClick(e) {
- var newPos, parent = dom.parentWithAttribute(this, "is", "emby-scroller"),
- direction = this.getAttribute("data-direction"),
- scrollSize = getScrollSize(parent),
- pos = getScrollPosition(parent);
- newPos = "left" === direction ? Math.max(0, pos - scrollSize) : pos + scrollSize, parent.scrollToPosition(newPos, !1)
+
+ var parent = dom.parentWithAttribute(this, 'is', 'emby-scroller');
+
+ var direction = this.getAttribute('data-direction');
+
+ var scrollSize = getScrollSize(parent);
+
+ var pos = getScrollPosition(parent);
+ var newPos;
+
+ if (direction === 'left') {
+ newPos = Math.max(0, pos - scrollSize);
+ } else {
+ newPos = pos + scrollSize;
+ }
+
+ parent.scrollToPosition(newPos, false);
}
- var EmbyScrollButtonsPrototype = Object.create(HTMLDivElement.prototype);
- EmbyScrollButtonsPrototype.createdCallback = function() {}, EmbyScrollButtonsPrototype.attachedCallback = function() {
- var parent = dom.parentWithAttribute(this, "is", "emby-scroller");
- this.scroller = parent, parent.classList.add("emby-scrollbuttons-scroller"), this.innerHTML = getScrollButtonContainerHtml("left") + getScrollButtonContainerHtml("right");
+
+ EmbyScrollButtonsPrototype.attachedCallback = function () {
+
+ var parent = dom.parentWithAttribute(this, 'is', 'emby-scroller');
+ this.scroller = parent;
+
+ parent.classList.add('emby-scrollbuttons-scroller');
+
+ this.innerHTML = getScrollButtonContainerHtml('left') + getScrollButtonContainerHtml('right');
+
var scrollHandler = onScroll.bind(this);
this.scrollHandler = scrollHandler;
- var buttons = this.querySelectorAll(".emby-scrollbuttons-scrollbutton");
- buttons[0].addEventListener("click", onScrollButtonClick), buttons[1].addEventListener("click", onScrollButtonClick), buttons = this.querySelectorAll(".scrollbuttoncontainer"), this.scrollButtonsLeft = buttons[0], this.scrollButtonsRight = buttons[1], parent.addScrollEventListener(scrollHandler, {
- capture: !1,
- passive: !0
- })
- }, EmbyScrollButtonsPrototype.detachedCallback = function() {
+
+ var buttons = this.querySelectorAll('.emby-scrollbuttons-scrollbutton');
+ buttons[0].addEventListener('click', onScrollButtonClick);
+ buttons[1].addEventListener('click', onScrollButtonClick);
+
+ buttons = this.querySelectorAll('.scrollbuttoncontainer');
+ this.scrollButtonsLeft = buttons[0];
+ this.scrollButtonsRight = buttons[1];
+
+ parent.addScrollEventListener(scrollHandler, {
+ capture: false,
+ passive: true
+ });
+ };
+
+ EmbyScrollButtonsPrototype.detachedCallback = function () {
+
var parent = this.scroller;
this.scroller = null;
+
var scrollHandler = this.scrollHandler;
- parent && scrollHandler && parent.removeScrollEventListener(scrollHandler, {
- capture: !1,
- passive: !0
- }), this.scrollHandler = null, this.scrollButtonsLeft = null, this.scrollButtonsRight = null
- }, document.registerElement("emby-scrollbuttons", {
+
+ if (parent && scrollHandler) {
+ parent.removeScrollEventListener(scrollHandler, {
+ capture: false,
+ passive: true
+ });
+ }
+
+ this.scrollHandler = null;
+ this.scrollButtonsLeft = null;
+ this.scrollButtonsRight = null;
+ };
+
+ document.registerElement('emby-scrollbuttons', {
prototype: EmbyScrollButtonsPrototype,
- extends: "div"
- })
+ extends: 'div'
+ });
});
\ No newline at end of file
diff --git a/src/bower_components/emby-webcomponents/emby-scroller/emby-scroller.js b/src/bower_components/emby-webcomponents/emby-scroller/emby-scroller.js
index d358666f97..6237fd99f6 100644
--- a/src/bower_components/emby-webcomponents/emby-scroller/emby-scroller.js
+++ b/src/bower_components/emby-webcomponents/emby-scroller/emby-scroller.js
@@ -1,101 +1,224 @@
-define(["scroller", "dom", "layoutManager", "inputManager", "focusManager", "browser", "registerElement"], function(scroller, dom, layoutManager, inputManager, focusManager, browser) {
- "use strict";
+define(['scroller', 'dom', 'layoutManager', 'inputManager', 'focusManager', 'browser', 'registerElement'], function (scroller, dom, layoutManager, inputManager, focusManager, browser) {
+ 'use strict';
+
+ var ScrollerProtoType = Object.create(HTMLDivElement.prototype);
+
+ ScrollerProtoType.createdCallback = function () {
+ this.classList.add('emby-scroller');
+ };
function initCenterFocus(elem, scrollerInstance) {
- dom.addEventListener(elem, "focus", function(e) {
+
+ dom.addEventListener(elem, 'focus', function (e) {
+
var focused = focusManager.focusableParent(e.target);
- focused && scrollerInstance.toCenter(focused)
+
+ if (focused) {
+ scrollerInstance.toCenter(focused);
+ }
+
}, {
- capture: !0,
- passive: !0
- })
+ capture: true,
+ passive: true
+ });
}
+ ScrollerProtoType.scrollToBeginning = function () {
+ if (this.scroller) {
+ this.scroller.slideTo(0, true);
+ }
+ };
+ ScrollerProtoType.toStart = function (elem, immediate) {
+ if (this.scroller) {
+ this.scroller.toStart(elem, immediate);
+ }
+ };
+ ScrollerProtoType.toCenter = function (elem, immediate) {
+ if (this.scroller) {
+ this.scroller.toCenter(elem, immediate);
+ }
+ };
+
+ ScrollerProtoType.scrollToPosition = function (pos, immediate) {
+ if (this.scroller) {
+ this.scroller.slideTo(pos, immediate);
+ }
+ };
+
+ ScrollerProtoType.getScrollPosition = function () {
+ if (this.scroller) {
+ return this.scroller.getScrollPosition();
+ }
+ };
+
+ ScrollerProtoType.getScrollSize = function () {
+ if (this.scroller) {
+ return this.scroller.getScrollSize();
+ }
+ };
+
+ ScrollerProtoType.getScrollEventName = function () {
+ if (this.scroller) {
+ return this.scroller.getScrollEventName();
+ }
+ };
+
+ ScrollerProtoType.getScrollSlider = function () {
+ if (this.scroller) {
+ return this.scroller.getScrollSlider();
+ }
+ };
+
+ ScrollerProtoType.addScrollEventListener = function (fn, options) {
+ if (this.scroller) {
+ dom.addEventListener(this.scroller.getScrollFrame(), this.scroller.getScrollEventName(), fn, options);
+ }
+ };
+
+ ScrollerProtoType.removeScrollEventListener = function (fn, options) {
+ if (this.scroller) {
+ dom.removeEventListener(this.scroller.getScrollFrame(), this.scroller.getScrollEventName(), fn, options);
+ }
+ };
+
function onInputCommand(e) {
+
var cmd = e.detail.command;
- "end" === cmd ? (focusManager.focusLast(this, "." + this.getAttribute("data-navcommands")), e.preventDefault(), e.stopPropagation()) : "pageup" === cmd ? (focusManager.moveFocus(e.target, this, "." + this.getAttribute("data-navcommands"), -12), e.preventDefault(), e.stopPropagation()) : "pagedown" === cmd && (focusManager.moveFocus(e.target, this, "." + this.getAttribute("data-navcommands"), 12), e.preventDefault(), e.stopPropagation())
+
+ if (cmd === 'end') {
+ focusManager.focusLast(this, '.' + this.getAttribute('data-navcommands'));
+ e.preventDefault();
+ e.stopPropagation();
+ }
+ else if (cmd === 'pageup') {
+ focusManager.moveFocus(e.target, this, '.' + this.getAttribute('data-navcommands'), -12);
+ e.preventDefault();
+ e.stopPropagation();
+ }
+ else if (cmd === 'pagedown') {
+ focusManager.moveFocus(e.target, this, '.' + this.getAttribute('data-navcommands'), 12);
+ e.preventDefault();
+ e.stopPropagation();
+ }
}
function initHeadroom(elem) {
- require(["headroom"], function(Headroom) {
+ require(['headroom'], function (Headroom) {
+
var headroom = new Headroom([], {
scroller: elem
});
- headroom.init(), headroom.add(document.querySelector(".skinHeader")), elem.headroom = headroom
- })
+ // initialise
+ headroom.init();
+ headroom.add(document.querySelector('.skinHeader'));
+ elem.headroom = headroom;
+ });
}
+ ScrollerProtoType.attachedCallback = function () {
+
+ if (this.getAttribute('data-navcommands')) {
+ inputManager.on(this, onInputCommand);
+ }
+
+ var horizontal = this.getAttribute('data-horizontal') !== 'false';
+
+ var slider = this.querySelector('.scrollSlider');
+
+ if (horizontal) {
+ slider.style['white-space'] = 'nowrap';
+ }
+
+ var bindHeader = this.getAttribute('data-bindheader') === 'true';
+
+ var scrollFrame = this;
+ var enableScrollButtons = layoutManager.desktop && horizontal && this.getAttribute('data-scrollbuttons') !== 'false';
+
+ var options = {
+ horizontal: horizontal,
+ mouseDragging: 1,
+ mouseWheel: this.getAttribute('data-mousewheel') !== 'false',
+ touchDragging: 1,
+ slidee: slider,
+ scrollBy: 200,
+ speed: horizontal ? 270 : 240,
+ //immediateSpeed: pageOptions.immediateSpeed,
+ elasticBounds: 1,
+ dragHandle: 1,
+ scrollWidth: this.getAttribute('data-scrollsize') === 'auto' ? null : 5000000,
+ autoImmediate: true,
+ skipSlideToWhenVisible: this.getAttribute('data-skipfocuswhenvisible') === 'true',
+ dispatchScrollEvent: enableScrollButtons || bindHeader || this.getAttribute('data-scrollevent') === 'true',
+ hideScrollbar: enableScrollButtons || this.getAttribute('data-hidescrollbar') === 'true',
+ allowNativeSmoothScroll: this.getAttribute('data-allownativesmoothscroll') === 'true' && !enableScrollButtons,
+ allowNativeScroll: !enableScrollButtons,
+ forceHideScrollbars: enableScrollButtons,
+
+ // In edge, with the native scroll, the content jumps around when hovering over the buttons
+ requireAnimation: enableScrollButtons && browser.edge
+ };
+
+ // If just inserted it might not have any height yet - yes this is a hack
+ this.scroller = new scroller(scrollFrame, options);
+ this.scroller.init();
+
+ if (layoutManager.tv && this.getAttribute('data-centerfocus')) {
+ initCenterFocus(this, this.scroller);
+ }
+
+ if (bindHeader) {
+ initHeadroom(this);
+ }
+
+ if (enableScrollButtons) {
+ loadScrollButtons(this);
+ }
+ };
+
function loadScrollButtons(scroller) {
- require(["emby-scrollbuttons"], function() {
- scroller.insertAdjacentHTML("beforeend", '
')
- })
+
+ require(['emby-scrollbuttons'], function () {
+ scroller.insertAdjacentHTML('beforeend', '
');
+ });
}
- var ScrollerProtoType = Object.create(HTMLDivElement.prototype);
- ScrollerProtoType.createdCallback = function() {
- this.classList.add("emby-scroller")
- }, ScrollerProtoType.scrollToBeginning = function() {
- this.scroller && this.scroller.slideTo(0, !0)
- }, ScrollerProtoType.toStart = function(elem, immediate) {
- this.scroller && this.scroller.toStart(elem, immediate)
- }, ScrollerProtoType.toCenter = function(elem, immediate) {
- this.scroller && this.scroller.toCenter(elem, immediate)
- }, ScrollerProtoType.scrollToPosition = function(pos, immediate) {
- this.scroller && this.scroller.slideTo(pos, immediate)
- }, ScrollerProtoType.getScrollPosition = function() {
- if (this.scroller) return this.scroller.getScrollPosition()
- }, ScrollerProtoType.getScrollSize = function() {
- if (this.scroller) return this.scroller.getScrollSize()
- }, ScrollerProtoType.getScrollEventName = function() {
- if (this.scroller) return this.scroller.getScrollEventName()
- }, ScrollerProtoType.getScrollSlider = function() {
- if (this.scroller) return this.scroller.getScrollSlider()
- }, ScrollerProtoType.addScrollEventListener = function(fn, options) {
- this.scroller && dom.addEventListener(this.scroller.getScrollFrame(), this.scroller.getScrollEventName(), fn, options)
- }, ScrollerProtoType.removeScrollEventListener = function(fn, options) {
- this.scroller && dom.removeEventListener(this.scroller.getScrollFrame(), this.scroller.getScrollEventName(), fn, options)
- }, ScrollerProtoType.attachedCallback = function() {
- this.getAttribute("data-navcommands") && inputManager.on(this, onInputCommand);
- var horizontal = "false" !== this.getAttribute("data-horizontal"),
- slider = this.querySelector(".scrollSlider");
- horizontal && (slider.style["white-space"] = "nowrap");
- var bindHeader = "true" === this.getAttribute("data-bindheader"),
- scrollFrame = this,
- enableScrollButtons = layoutManager.desktop && horizontal && "false" !== this.getAttribute("data-scrollbuttons"),
- options = {
- horizontal: horizontal,
- mouseDragging: 1,
- mouseWheel: "false" !== this.getAttribute("data-mousewheel"),
- touchDragging: 1,
- slidee: slider,
- scrollBy: 200,
- speed: horizontal ? 270 : 240,
- elasticBounds: 1,
- dragHandle: 1,
- scrollWidth: "auto" === this.getAttribute("data-scrollsize") ? null : 5e6,
- autoImmediate: !0,
- skipSlideToWhenVisible: "true" === this.getAttribute("data-skipfocuswhenvisible"),
- dispatchScrollEvent: enableScrollButtons || bindHeader || "true" === this.getAttribute("data-scrollevent"),
- hideScrollbar: enableScrollButtons || "true" === this.getAttribute("data-hidescrollbar"),
- allowNativeSmoothScroll: "true" === this.getAttribute("data-allownativesmoothscroll") && !enableScrollButtons,
- allowNativeScroll: !enableScrollButtons,
- forceHideScrollbars: enableScrollButtons,
- requireAnimation: enableScrollButtons && browser.edge
- };
- this.scroller = new scroller(scrollFrame, options), this.scroller.init(), layoutManager.tv && this.getAttribute("data-centerfocus") && initCenterFocus(this, this.scroller), bindHeader && initHeadroom(this), enableScrollButtons && loadScrollButtons(this)
- }, ScrollerProtoType.pause = function() {
+
+ ScrollerProtoType.pause = function () {
+
var headroom = this.headroom;
- headroom && headroom.pause()
- }, ScrollerProtoType.resume = function() {
+ if (headroom) {
+ headroom.pause();
+ }
+ };
+
+ ScrollerProtoType.resume = function () {
+
var headroom = this.headroom;
- headroom && headroom.resume()
- }, ScrollerProtoType.detachedCallback = function() {
- this.getAttribute("data-navcommands") && inputManager.off(this, onInputCommand);
+ if (headroom) {
+ headroom.resume();
+ }
+ };
+
+ ScrollerProtoType.detachedCallback = function () {
+
+ if (this.getAttribute('data-navcommands')) {
+ inputManager.off(this, onInputCommand);
+ }
+
var headroom = this.headroom;
- headroom && (headroom.destroy(), this.headroom = null);
+ if (headroom) {
+ headroom.destroy();
+ this.headroom = null;
+ }
+
var scrollerInstance = this.scroller;
- scrollerInstance && (scrollerInstance.destroy(), this.scroller = null)
- }, document.registerElement("emby-scroller", {
+ if (scrollerInstance) {
+ scrollerInstance.destroy();
+ this.scroller = null;
+ }
+ };
+
+ document.registerElement('emby-scroller', {
prototype: ScrollerProtoType,
- extends: "div"
- })
+ extends: 'div'
+ });
});
\ No newline at end of file
diff --git a/src/bower_components/emby-webcomponents/emby-select/emby-select.css b/src/bower_components/emby-webcomponents/emby-select/emby-select.css
index 1dfe686f53..76b28c4208 100644
--- a/src/bower_components/emby-webcomponents/emby-select/emby-select.css
+++ b/src/bower_components/emby-webcomponents/emby-select/emby-select.css
@@ -2,91 +2,84 @@
display: block;
margin: 0;
margin-bottom: 0 !important;
+ /* Remove select styling */
+ /* Font size must the 16px or larger to prevent iOS page zoom on focus */
font-size: 110%;
+ /* General select styles: change as needed */
font-family: inherit;
font-weight: inherit;
padding: .5em 1.9em .5em .5em;
- -webkit-box-sizing: border-box;
+ /* Prevent padding from causing width overflow */
box-sizing: border-box;
- outline: 0 !important;
- -webkit-tap-highlight-color: transparent;
- width: 100%
+ outline: none !important;
+ -webkit-tap-highlight-color: rgba(0,0,0,0);
+ width: 100%;
}
-.emby-select[disabled] {
- background: 0 0 !important;
- border-color: transparent !important;
- color: inherit !important;
- -webkit-appearance: none;
- -moz-appearance: none;
- appearance: none
-}
+ .emby-select[disabled] {
+ background: none !important;
+ border-color: transparent !important;
+ color: inherit !important;
+ -webkit-appearance: none;
+ -moz-appearance: none;
+ appearance: none;
+ }
-.selectContainer-inline>.emby-select {
+.selectContainer-inline > .emby-select {
padding: .3em 1.9em .3em .5em;
- font-size: inherit
+ font-size: inherit;
}
-.selectContainer-inline>.emby-select[disabled] {
- padding-left: 0;
- padding-right: 0
-}
+ .selectContainer-inline > .emby-select[disabled] {
+ padding-left: 0;
+ padding-right: 0;
+ }
.emby-select::-moz-focus-inner {
- border: 0
+ border: 0;
}
.emby-select-focusscale {
- -webkit-transition: -webkit-transform 180ms ease-out !important;
- -o-transition: transform 180ms ease-out !important;
transition: transform 180ms ease-out !important;
-webkit-transform-origin: center center;
- transform-origin: center center
+ transform-origin: center center;
}
-.emby-select-focusscale:focus {
- -webkit-transform: scale(1.04);
- transform: scale(1.04);
- z-index: 1
-}
+ .emby-select-focusscale:focus {
+ transform: scale(1.04);
+ z-index: 1;
+ }
-.emby-select+.fieldDescription {
- margin-top: .25em
+.emby-select + .fieldDescription {
+ margin-top: .25em;
}
.selectContainer {
margin-bottom: 1.8em;
- position: relative
+ position: relative;
}
.selectContainer-inline {
- display: -webkit-inline-box;
- display: -webkit-inline-flex;
display: inline-flex;
margin-bottom: 0;
- -webkit-box-align: center;
- -webkit-align-items: center;
- align-items: center
+ align-items: center;
}
.selectLabel {
display: block;
- margin-bottom: .25em
+ margin-bottom: .25em;
}
-.selectContainer-inline>.selectLabel {
+.selectContainer-inline > .selectLabel {
margin-bottom: 0;
margin-right: .5em;
- -webkit-flex-shrink: 0;
- flex-shrink: 0
+ flex-shrink: 0;
}
.emby-select-withcolor {
-webkit-appearance: none;
- -moz-appearance: none;
appearance: none;
- -webkit-border-radius: .2em;
- border-radius: .2em
+ border-radius: .2em;
}
.selectArrowContainer {
@@ -94,25 +87,24 @@
right: .3em;
top: .2em;
color: inherit;
- pointer-events: none
+ pointer-events: none;
}
-.selectContainer-inline>.selectArrowContainer {
+.selectContainer-inline > .selectArrowContainer {
top: initial;
bottom: .24em;
- font-size: 90%
+ font-size: 90%;
}
-.emby-select[disabled]+.selectArrowContainer {
- display: none
+.emby-select[disabled] + .selectArrowContainer {
+ display: none;
}
.selectArrow {
margin-top: .35em;
- font-size: 1.7em
+ font-size: 1.7em;
}
.emby-select-iconbutton {
- -webkit-align-self: flex-end;
- align-self: flex-end
-}
\ No newline at end of file
+ align-self: flex-end;
+}
diff --git a/src/bower_components/emby-webcomponents/emby-select/emby-select.js b/src/bower_components/emby-webcomponents/emby-select/emby-select.js
index 25e646fcdb..6783f2f48c 100644
--- a/src/bower_components/emby-webcomponents/emby-select/emby-select.js
+++ b/src/bower_components/emby-webcomponents/emby-select/emby-select.js
@@ -1,75 +1,168 @@
-define(["layoutManager", "browser", "actionsheet", "css!./emby-select", "registerElement"], function(layoutManager, browser, actionsheet) {
- "use strict";
+define(['layoutManager', 'browser', 'actionsheet', 'css!./emby-select', 'registerElement'], function (layoutManager, browser, actionsheet) {
+ 'use strict';
+
+ var EmbySelectPrototype = Object.create(HTMLSelectElement.prototype);
function enableNativeMenu() {
- return !(!browser.edgeUwp && !browser.xboxOne) || !(browser.tizen || browser.orsay || browser.web0s) && (!!browser.tv || !layoutManager.tv)
+
+ if (browser.edgeUwp || browser.xboxOne) {
+ return true;
+ }
+
+ // Doesn't seem to work at all
+ if (browser.tizen || browser.orsay || browser.web0s) {
+ return false;
+ }
+
+ // Take advantage of the native input methods
+ if (browser.tv) {
+ return true;
+ }
+
+ if (layoutManager.tv) {
+ return false;
+ }
+
+ return true;
}
function triggerChange(select) {
var evt = document.createEvent("HTMLEvents");
- evt.initEvent("change", !1, !0), select.dispatchEvent(evt)
+ evt.initEvent("change", false, true);
+ select.dispatchEvent(evt);
}
function setValue(select, value) {
- select.value = value
+
+ select.value = value;
}
function showActionSheet(select) {
- var labelElem = getLabel(select),
- title = labelElem ? labelElem.textContent || labelElem.innerText : null;
+
+ var labelElem = getLabel(select);
+ var title = labelElem ? (labelElem.textContent || labelElem.innerText) : null;
+
actionsheet.show({
items: select.options,
positionTo: select,
title: title
- }).then(function(value) {
- setValue(select, value), triggerChange(select)
- })
+
+ }).then(function (value) {
+ setValue(select, value);
+ triggerChange(select);
+ });
}
function getLabel(select) {
- for (var elem = select.previousSibling; elem && "LABEL" !== elem.tagName;) elem = elem.previousSibling;
- return elem
+ var elem = select.previousSibling;
+ while (elem && elem.tagName !== 'LABEL') {
+ elem = elem.previousSibling;
+ }
+ return elem;
}
function onFocus(e) {
var label = getLabel(this);
- label && label.classList.add("selectLabelFocused")
+ if (label) {
+ label.classList.add('selectLabelFocused');
+ }
}
function onBlur(e) {
var label = getLabel(this);
- label && label.classList.remove("selectLabelFocused")
+ if (label) {
+ label.classList.remove('selectLabelFocused');
+ }
}
function onMouseDown(e) {
- e.button || enableNativeMenu() || (e.preventDefault(), showActionSheet(this))
+
+ // e.button=0 for primary (left) mouse button click
+ if (!e.button && !enableNativeMenu()) {
+ e.preventDefault();
+ showActionSheet(this);
+ }
}
function onKeyDown(e) {
+
switch (e.keyCode) {
+
case 13:
- return void(enableNativeMenu() || (e.preventDefault(), showActionSheet(this)));
+ if (!enableNativeMenu()) {
+ e.preventDefault();
+ showActionSheet(this);
+ }
+ return;
case 37:
case 38:
case 39:
case 40:
- return void(layoutManager.tv && e.preventDefault())
+ if (layoutManager.tv) {
+ e.preventDefault();
+ }
+ return;
+ default:
+ break;
}
}
- var EmbySelectPrototype = Object.create(HTMLSelectElement.prototype),
- inputId = 0;
- EmbySelectPrototype.createdCallback = function() {
- this.id || (this.id = "embyselect" + inputId, inputId++), browser.firefox || (this.classList.add("emby-select-withcolor"), layoutManager.tv && this.classList.add("emby-select-tv-withcolor")), layoutManager.tv && this.classList.add("emby-select-focusscale"), this.addEventListener("mousedown", onMouseDown), this.addEventListener("keydown", onKeyDown), this.addEventListener("focus", onFocus), this.addEventListener("blur", onBlur)
- }, EmbySelectPrototype.attachedCallback = function() {
- if (!this.classList.contains("emby-select")) {
- this.classList.add("emby-select");
- var label = this.ownerDocument.createElement("label");
- label.innerHTML = this.getAttribute("label") || "", label.classList.add("selectLabel"), label.htmlFor = this.id, this.parentNode.insertBefore(label, this), this.classList.contains("emby-select-withcolor") && this.parentNode.insertAdjacentHTML("beforeend", '
')
+
+ var inputId = 0;
+
+ EmbySelectPrototype.createdCallback = function () {
+
+ if (!this.id) {
+ this.id = 'embyselect' + inputId;
+ inputId++;
}
- }, EmbySelectPrototype.setLabel = function(text) {
- this.parentNode.querySelector("label").innerHTML = text
- }, document.registerElement("emby-select", {
+
+ if (!browser.firefox) {
+ this.classList.add('emby-select-withcolor');
+
+ if (layoutManager.tv) {
+ this.classList.add('emby-select-tv-withcolor');
+ }
+ }
+
+ if (layoutManager.tv) {
+ this.classList.add('emby-select-focusscale');
+ }
+
+ this.addEventListener('mousedown', onMouseDown);
+ this.addEventListener('keydown', onKeyDown);
+
+ this.addEventListener('focus', onFocus);
+ this.addEventListener('blur', onBlur);
+ };
+
+ EmbySelectPrototype.attachedCallback = function () {
+
+ if (this.classList.contains('emby-select')) {
+ return;
+ }
+
+ this.classList.add('emby-select');
+
+ var label = this.ownerDocument.createElement('label');
+ label.innerHTML = this.getAttribute('label') || '';
+ label.classList.add('selectLabel');
+ label.htmlFor = this.id;
+ this.parentNode.insertBefore(label, this);
+
+ if (this.classList.contains('emby-select-withcolor')) {
+ this.parentNode.insertAdjacentHTML('beforeend', '
');
+ }
+ };
+
+ EmbySelectPrototype.setLabel = function (text) {
+
+ var label = this.parentNode.querySelector('label');
+
+ label.innerHTML = text;
+ };
+
+ document.registerElement('emby-select', {
prototype: EmbySelectPrototype,
- extends: "select"
- })
+ extends: 'select'
+ });
});
\ No newline at end of file
diff --git a/src/bower_components/emby-webcomponents/emby-slider/emby-slider.css b/src/bower_components/emby-webcomponents/emby-slider/emby-slider.css
index 38cad647b3..9617c6be49 100644
--- a/src/bower_components/emby-webcomponents/emby-slider/emby-slider.css
+++ b/src/bower_components/emby-webcomponents/emby-slider/emby-slider.css
@@ -1,7 +1,7 @@
_:-ms-input-placeholder {
-ms-appearance: none;
height: 2.223em;
- margin: 0
+ margin: 0;
}
.mdl-slider {
@@ -11,7 +11,7 @@ _:-ms-input-placeholder {
-ms-appearance: none;
appearance: none;
height: .2em;
- background: 0 0;
+ background: transparent;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
@@ -20,78 +20,79 @@ _:-ms-input-placeholder {
padding: 1em 0;
color: #00a4dc;
-webkit-align-self: center;
+ -ms-flex-item-align: center;
align-self: center;
z-index: 1;
cursor: pointer;
margin: 0;
- -webkit-tap-highlight-color: transparent;
- display: block
+ /* Disable webkit tap highlighting */
+ -webkit-tap-highlight-color: rgba(0,0,0,0);
+ display: block;
+ /**************************** Tracks ****************************/
+ /**************************** Thumbs ****************************/
+ /**************************** 0-value ****************************/
+ /**************************** Disabled ****************************/
}
-.mdl-slider::-moz-focus-outer {
- border: 0
-}
+ .mdl-slider::-moz-focus-outer {
+ border: 0;
+ }
-.mdl-slider::-ms-tooltip {
- display: none
-}
+ .mdl-slider::-ms-tooltip {
+ display: none;
+ }
-.mdl-slider::-webkit-slider-runnable-track {
- background: 0 0
-}
+ .mdl-slider::-webkit-slider-runnable-track {
+ background: transparent;
+ }
-.mdl-slider::-moz-range-track {
- background: #444;
- border: none
-}
+ .mdl-slider::-moz-range-track {
+ background: #444;
+ border: none;
+ }
-.mdl-slider::-moz-range-progress {
- background: #00a4dc
-}
+ .mdl-slider::-moz-range-progress {
+ background: #00a4dc;
+ }
-.mdl-slider::-ms-track {
- background: 0 0;
- color: transparent;
- height: .2em;
- width: 100%;
- border: none
-}
+ .mdl-slider::-ms-track {
+ background: none;
+ color: transparent;
+ height: .2em;
+ width: 100%;
+ border: none;
+ }
-.mdl-slider::-ms-fill-lower {
- display: none
-}
+ .mdl-slider::-ms-fill-lower {
+ display: none;
+ }
-.mdl-slider::-ms-fill-upper {
- display: none
-}
+ .mdl-slider::-ms-fill-upper {
+ display: none;
+ }
-.mdl-slider::-webkit-slider-thumb {
- -webkit-appearance: none;
- width: 1.8em;
- height: 1.8em;
- -webkit-box-sizing: border-box;
- box-sizing: border-box;
- -webkit-border-radius: 50%;
- border-radius: 50%;
- background: #00a4dc;
- border: none;
- -webkit-transition: -webkit-transform .3s cubic-bezier(.4, 0, .2, 1), border .18s cubic-bezier(.4, 0, .2, 1), -webkit-box-shadow .18s cubic-bezier(.4, 0, .2, 1), background .28s cubic-bezier(.4, 0, .2, 1);
- transition: transform .3s cubic-bezier(.4, 0, .2, 1), border .18s cubic-bezier(.4, 0, .2, 1), box-shadow .18s cubic-bezier(.4, 0, .2, 1), background .28s cubic-bezier(.4, 0, .2, 1)
-}
+ .mdl-slider::-webkit-slider-thumb {
+ -webkit-appearance: none;
+ width: 1.8em;
+ height: 1.8em;
+ box-sizing: border-box;
+ border-radius: 50%;
+ background: #00a4dc;
+ border: none;
+ transition: transform 300ms cubic-bezier(0.4, 0, 0.2, 1), border 0.18s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.18s cubic-bezier(0.4, 0, 0.2, 1), background 0.28s cubic-bezier(0.4, 0, 0.2, 1);
+ }
.mdl-slider-hoverthumb::-webkit-slider-thumb {
margin-left: -.12em;
- -webkit-transform: scale(.7, .7);
- transform: scale(.7, .7)
+ transform: scale(.7, .7);
}
.mdl-slider:hover::-webkit-slider-thumb {
- -webkit-transform: none;
- transform: none
+ transform: none;
}
.slider-no-webkit-thumb::-webkit-slider-thumb {
- opacity: 0 !important
+ opacity: 0 !important;
}
.mdl-slider::-moz-range-thumb {
@@ -100,8 +101,9 @@ _:-ms-input-placeholder {
height: 1.8em;
box-sizing: border-box;
border-radius: 50%;
+ background-image: none;
background: #00a4dc;
- border: none
+ border: none;
}
.mdl-slider::-ms-thumb {
@@ -112,28 +114,28 @@ _:-ms-input-placeholder {
border-radius: 50%;
background: #00a4dc;
border: none;
- transition: transform .3s cubic-bezier(.4, 0, .2, 1), border .18s cubic-bezier(.4, 0, .2, 1), box-shadow .18s cubic-bezier(.4, 0, .2, 1), background .28s cubic-bezier(.4, 0, .2, 1)
+ transition: transform 300ms cubic-bezier(0.4, 0, 0.2, 1), border 0.18s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.18s cubic-bezier(0.4, 0, 0.2, 1), background 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}
.mdl-slider-hoverthumb::-ms-thumb {
margin-left: -.4em;
- transform: scale(.5, .5)
+ transform: scale(.5, .5);
}
.mdl-slider:hover::-ms-thumb {
- transform: none
+ transform: none;
}
.mdl-slider[disabled]::-webkit-slider-thumb {
- display: none
+ display: none;
}
.mdl-slider[disabled]::-moz-range-thumb {
- display: none
+ display: none;
}
.mdl-slider[disabled]::-ms-thumb {
- display: none
+ display: none;
}
.mdl-slider-ie-container {
@@ -141,20 +143,15 @@ _:-ms-input-placeholder {
overflow: visible;
border: none;
margin: 0;
- padding: 0
+ padding: 0;
}
.mdl-slider-container {
height: 1.25em;
position: relative;
- background: 0 0;
- display: -webkit-box;
- display: -webkit-flex;
+ background: none;
display: flex;
- -webkit-box-orient: horizontal;
- -webkit-box-direction: normal;
- -webkit-flex-direction: row;
- flex-direction: row
+ flex-direction: row;
}
.mdl-slider-background-flex {
@@ -165,70 +162,62 @@ _:-ms-input-placeholder {
width: 100%;
top: 50%;
left: 0;
- display: -webkit-box;
- display: -webkit-flex;
display: flex;
overflow: hidden;
border: 0;
- padding: 0
+ padding: 0;
}
.mdl-slider-background-flex-inner {
position: relative;
- width: 100%
+ width: 100%;
}
.mdl-slider-background-lower {
+ /*transition: width 0.18s cubic-bezier(0.4, 0, 0.2, 1);*/
position: absolute;
left: 0;
width: 0;
top: 0;
bottom: 0;
- background-color: #00a4dc
+ background-color: #00a4dc;
}
.mdl-slider-background-lower-clear {
- background-color: transparent
+ background-color: transparent;
}
.mdl-slider-background-lower-withtransform {
width: 100%;
- -webkit-transform-origin: left center;
+ /*transition: transform 0.18s cubic-bezier(0.4, 0, 0.2, 1);*/
transform-origin: left center;
- -webkit-transform: scaleX(0);
- transform: scaleX(0)
+ transform: scaleX(0);
}
.mdl-slider-background-upper {
+ /*transition: left 0.18s cubic-bezier(0.4, 0, 0.2, 1), width 0.18s cubic-bezier(0.4, 0, 0.2, 1);*/
background: #666;
background: rgba(255, 255, 255, .4);
position: absolute;
left: 0;
width: 0;
top: 0;
- bottom: 0
+ bottom: 0;
}
.sliderBubble {
position: absolute;
top: 0;
left: 0;
- -webkit-transform: translate3d(-48%, -120%, 0);
transform: translate3d(-48%, -120%, 0);
background: #282828;
color: #fff;
- display: -webkit-box;
- display: -webkit-flex;
display: flex;
- -webkit-box-align: center;
- -webkit-align-items: center;
align-items: center;
- -webkit-box-pack: center;
- -webkit-justify-content: center;
- justify-content: center
+ justify-content: center;
}
.sliderBubbleText {
margin: 0;
- padding: .5em .75em
-}
\ No newline at end of file
+ padding: .5em .75em;
+}
diff --git a/src/bower_components/emby-webcomponents/emby-slider/emby-slider.js b/src/bower_components/emby-webcomponents/emby-slider/emby-slider.js
index 74e160d5b7..06fcdcfea1 100644
--- a/src/bower_components/emby-webcomponents/emby-slider/emby-slider.js
+++ b/src/bower_components/emby-webcomponents/emby-slider/emby-slider.js
@@ -1,101 +1,270 @@
-define(["browser", "dom", "layoutManager", "css!./emby-slider", "registerElement", "emby-input"], function(browser, dom, layoutManager) {
- "use strict";
+define(['browser', 'dom', 'layoutManager', 'css!./emby-slider', 'registerElement', 'emby-input'], function (browser, dom, layoutManager) {
+ 'use strict';
+
+ var EmbySliderPrototype = Object.create(HTMLInputElement.prototype);
+
+ var supportsNativeProgressStyle = browser.firefox;
+ var supportsValueSetOverride = false;
+
+ var enableWidthWithTransform;
+
+ if (Object.getOwnPropertyDescriptor && Object.defineProperty) {
+
+ var descriptor = Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, 'value');
+ // descriptor returning null in webos
+ if (descriptor && descriptor.configurable) {
+ supportsValueSetOverride = true;
+ }
+ }
function updateValues() {
- var range = this,
- value = range.value;
- requestAnimationFrame(function() {
+
+ var range = this;
+ var value = range.value;
+
+ // put this on a callback. Doing it within the event sometimes causes the slider to get hung up and not respond
+ requestAnimationFrame(function () {
+
var backgroundLower = range.backgroundLower;
+
if (backgroundLower) {
var fraction = (value - range.min) / (range.max - range.min);
- enableWidthWithTransform ? backgroundLower.style.transform = "scaleX(" + fraction + ")" : (fraction *= 100, backgroundLower.style.width = fraction + "%")
+
+ if (enableWidthWithTransform) {
+ backgroundLower.style.transform = 'scaleX(' + (fraction) + ')';
+ } else {
+ fraction *= 100;
+ backgroundLower.style.width = fraction + '%';
+ }
}
- })
+ });
}
function updateBubble(range, value, bubble, bubbleText) {
- requestAnimationFrame(function() {
- bubble.style.left = value + "%", range.getBubbleHtml ? value = range.getBubbleHtml(value) : (value = range.getBubbleText ? range.getBubbleText(value) : Math.round(value), value = '
' + value + " "), bubble.innerHTML = value
- })
+
+ requestAnimationFrame(function () {
+
+ bubble.style.left = value + '%';
+
+ if (range.getBubbleHtml) {
+ value = range.getBubbleHtml(value);
+ } else {
+ if (range.getBubbleText) {
+ value = range.getBubbleText(value);
+ } else {
+ value = Math.round(value);
+ }
+ value = '
' + value + ' ';
+ }
+
+ bubble.innerHTML = value;
+ });
}
+ EmbySliderPrototype.attachedCallback = function () {
+
+ if (this.getAttribute('data-embyslider') === 'true') {
+ return;
+ }
+
+ if (enableWidthWithTransform == null) {
+ //enableWidthWithTransform = browser.supportsCssAnimation();
+ }
+
+ this.setAttribute('data-embyslider', 'true');
+
+ this.classList.add('mdl-slider');
+ this.classList.add('mdl-js-slider');
+
+ if (browser.noFlex) {
+ this.classList.add('slider-no-webkit-thumb');
+ }
+ if (!layoutManager.mobile) {
+ this.classList.add('mdl-slider-hoverthumb');
+ }
+
+ var containerElement = this.parentNode;
+ containerElement.classList.add('mdl-slider-container');
+
+ var htmlToInsert = '';
+
+ if (!supportsNativeProgressStyle) {
+ htmlToInsert += '
';
+ htmlToInsert += '
';
+
+ // the more of these, the more ranges we can display
+ htmlToInsert += '
';
+
+ if (enableWidthWithTransform) {
+ htmlToInsert += '
';
+ } else {
+ htmlToInsert += '
';
+ }
+
+ htmlToInsert += '
';
+ htmlToInsert += '
';
+ }
+
+ htmlToInsert += '
';
+
+ containerElement.insertAdjacentHTML('beforeend', htmlToInsert);
+
+ this.backgroundLower = containerElement.querySelector('.mdl-slider-background-lower');
+ this.backgroundUpper = containerElement.querySelector('.mdl-slider-background-upper');
+ var sliderBubble = containerElement.querySelector('.sliderBubble');
+
+ var hasHideClass = sliderBubble.classList.contains('hide');
+
+ dom.addEventListener(this, 'input', function (e) {
+ this.dragging = true;
+
+ updateBubble(this, this.value, sliderBubble);
+
+ if (hasHideClass) {
+ sliderBubble.classList.remove('hide');
+ hasHideClass = false;
+ }
+ }, {
+ passive: true
+ });
+
+ dom.addEventListener(this, 'change', function () {
+ this.dragging = false;
+ updateValues.call(this);
+
+ sliderBubble.classList.add('hide');
+ hasHideClass = true;
+
+ }, {
+ passive: true
+ });
+
+ // In firefox this feature disrupts the ability to move the slider
+ if (!browser.firefox) {
+ dom.addEventListener(this, (window.PointerEvent ? 'pointermove' : 'mousemove'), function (e) {
+
+ if (!this.dragging) {
+ var rect = this.getBoundingClientRect();
+ var clientX = e.clientX;
+ var bubbleValue = (clientX - rect.left) / rect.width;
+ bubbleValue *= 100;
+ updateBubble(this, bubbleValue, sliderBubble);
+
+ if (hasHideClass) {
+ sliderBubble.classList.remove('hide');
+ hasHideClass = false;
+ }
+ }
+
+ }, {
+ passive: true
+ });
+
+ dom.addEventListener(this, (window.PointerEvent ? 'pointerleave' : 'mouseleave'), function () {
+ sliderBubble.classList.add('hide');
+ hasHideClass = true;
+ }, {
+ passive: true
+ });
+ }
+
+ if (!supportsNativeProgressStyle) {
+
+ if (supportsValueSetOverride) {
+ this.addEventListener('valueset', updateValues);
+ } else {
+ startInterval(this);
+ }
+ }
+ };
+
function setRange(elem, startPercent, endPercent) {
+
var style = elem.style;
- style.left = Math.max(startPercent, 0) + "%";
+ style.left = Math.max(startPercent, 0) + '%';
+
var widthPercent = endPercent - startPercent;
- style.width = Math.max(Math.min(widthPercent, 100), 0) + "%"
+ style.width = Math.max(Math.min(widthPercent, 100), 0) + '%';
}
function mapRangesFromRuntimeToPercent(ranges, runtime) {
- return runtime ? ranges.map(function(r) {
+
+ if (!runtime) {
+ return [];
+ }
+
+ return ranges.map(function (r) {
+
return {
- start: r.start / runtime * 100,
- end: r.end / runtime * 100
- }
- }) : []
+ start: (r.start / runtime) * 100,
+ end: (r.end / runtime) * 100
+ };
+ });
}
+ EmbySliderPrototype.setBufferedRanges = function (ranges, runtime, position) {
+
+ var elem = this.backgroundUpper;
+ if (!elem) {
+ return;
+ }
+
+ if (runtime != null) {
+ ranges = mapRangesFromRuntimeToPercent(ranges, runtime);
+
+ position = (position / runtime) * 100;
+ }
+
+ for (var i = 0, length = ranges.length; i < length; i++) {
+
+ var range = ranges[i];
+
+ if (position != null) {
+ if (position >= range.end) {
+ continue;
+ }
+ }
+
+ setRange(elem, range.start, range.end);
+ return;
+ }
+
+ setRange(elem, 0, 0);
+ };
+
+ EmbySliderPrototype.setIsClear = function (isClear) {
+
+ var backgroundLower = this.backgroundLower;
+ if (backgroundLower) {
+ if (isClear) {
+ backgroundLower.classList.add('mdl-slider-background-lower-clear');
+ } else {
+ backgroundLower.classList.remove('mdl-slider-background-lower-clear');
+ }
+ }
+ };
+
function startInterval(range) {
var interval = range.interval;
- interval && clearInterval(interval), range.interval = setInterval(updateValues.bind(range), 100)
- }
- var enableWidthWithTransform, EmbySliderPrototype = Object.create(HTMLInputElement.prototype),
- supportsNativeProgressStyle = browser.firefox,
- supportsValueSetOverride = !1;
- if (Object.getOwnPropertyDescriptor && Object.defineProperty) {
- var descriptor = Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, "value");
- descriptor && descriptor.configurable && (supportsValueSetOverride = !0)
- }
- EmbySliderPrototype.attachedCallback = function() {
- if ("true" !== this.getAttribute("data-embyslider")) {
- this.setAttribute("data-embyslider", "true"), this.classList.add("mdl-slider"), this.classList.add("mdl-js-slider"), browser.noFlex && this.classList.add("slider-no-webkit-thumb"), layoutManager.mobile || this.classList.add("mdl-slider-hoverthumb");
- var containerElement = this.parentNode;
- containerElement.classList.add("mdl-slider-container");
- var htmlToInsert = "";
- supportsNativeProgressStyle || (htmlToInsert += '
', htmlToInsert += '
', htmlToInsert += '
', htmlToInsert += enableWidthWithTransform ? '
' : '
', htmlToInsert += "
", htmlToInsert += "
"), htmlToInsert += '
', containerElement.insertAdjacentHTML("beforeend", htmlToInsert), this.backgroundLower = containerElement.querySelector(".mdl-slider-background-lower"), this.backgroundUpper = containerElement.querySelector(".mdl-slider-background-upper");
- var sliderBubble = containerElement.querySelector(".sliderBubble"),
- hasHideClass = sliderBubble.classList.contains("hide");
- dom.addEventListener(this, "input", function(e) {
- this.dragging = !0, updateBubble(this, this.value, sliderBubble), hasHideClass && (sliderBubble.classList.remove("hide"), hasHideClass = !1)
- }, {
- passive: !0
- }), dom.addEventListener(this, "change", function() {
- this.dragging = !1, updateValues.call(this), sliderBubble.classList.add("hide"), hasHideClass = !0
- }, {
- passive: !0
- }), browser.firefox || (dom.addEventListener(this, window.PointerEvent ? "pointermove" : "mousemove", function(e) {
- if (!this.dragging) {
- var rect = this.getBoundingClientRect(),
- clientX = e.clientX,
- bubbleValue = (clientX - rect.left) / rect.width;
- bubbleValue *= 100, updateBubble(this, bubbleValue, sliderBubble), hasHideClass && (sliderBubble.classList.remove("hide"), hasHideClass = !1)
- }
- }, {
- passive: !0
- }), dom.addEventListener(this, window.PointerEvent ? "pointerleave" : "mouseleave", function() {
- sliderBubble.classList.add("hide"), hasHideClass = !0
- }, {
- passive: !0
- })), supportsNativeProgressStyle || (supportsValueSetOverride ? this.addEventListener("valueset", updateValues) : startInterval(this))
+ if (interval) {
+ clearInterval(interval);
}
- }, EmbySliderPrototype.setBufferedRanges = function(ranges, runtime, position) {
- var elem = this.backgroundUpper;
- if (elem) {
- null != runtime && (ranges = mapRangesFromRuntimeToPercent(ranges, runtime), position = position / runtime * 100);
- for (var i = 0, length = ranges.length; i < length; i++) {
- var range = ranges[i];
- if (!(null != position && position >= range.end)) return void setRange(elem, range.start, range.end)
- }
- setRange(elem, 0, 0)
- }
- }, EmbySliderPrototype.setIsClear = function(isClear) {
- var backgroundLower = this.backgroundLower;
- backgroundLower && (isClear ? backgroundLower.classList.add("mdl-slider-background-lower-clear") : backgroundLower.classList.remove("mdl-slider-background-lower-clear"))
- }, EmbySliderPrototype.detachedCallback = function() {
+ range.interval = setInterval(updateValues.bind(range), 100);
+ }
+
+ EmbySliderPrototype.detachedCallback = function () {
+
var interval = this.interval;
- interval && clearInterval(interval), this.interval = null, this.backgroundUpper = null, this.backgroundLower = null
- }, document.registerElement("emby-slider", {
+ if (interval) {
+ clearInterval(interval);
+ }
+ this.interval = null;
+ this.backgroundUpper = null;
+ this.backgroundLower = null;
+ };
+
+ document.registerElement('emby-slider', {
prototype: EmbySliderPrototype,
- extends: "input"
- })
+ extends: 'input'
+ });
});
\ No newline at end of file
diff --git a/src/bower_components/emby-webcomponents/emby-tabs/emby-tabs.css b/src/bower_components/emby-webcomponents/emby-tabs/emby-tabs.css
index 56b5124d11..49881994bd 100644
--- a/src/bower_components/emby-webcomponents/emby-tabs/emby-tabs.css
+++ b/src/bower_components/emby-webcomponents/emby-tabs/emby-tabs.css
@@ -1,43 +1,47 @@
-.emby-tab-button,
-.emby-tabs-slider {
- position: relative
-}
-
-.emby-tab-button {
- background: 0 0;
- -webkit-box-shadow: none;
+.emby-tab-button {
+ background: transparent;
box-shadow: none;
cursor: pointer;
- outline: 0 !important;
+ outline: none !important;
width: auto;
font-family: inherit;
font-size: inherit;
display: inline-block;
vertical-align: middle;
- -webkit-flex-shrink: 0;
flex-shrink: 0;
margin: 0;
padding: 1em .9em;
+ position: relative;
height: auto;
min-width: initial;
line-height: initial;
- -webkit-border-radius: 0 !important;
border-radius: 0 !important;
overflow: hidden;
- font-weight: 600
+ font-weight: 600;
}
-.emby-tab-button.emby-button-tv:focus {
- -webkit-transform: scale(1.32);
- transform: scale(1.32);
- -webkit-transform-origin: center center;
- transform-origin: center center
+ /*.emby-tab-button-active {
+ color: #52B54B;
+}
+
+ .emby-tab-button-active.emby-button-tv {
+ color: #fff;
+ }*/
+
+ .emby-tab-button.emby-button-tv:focus {
+ /*color: #52B54B;*/
+ transform: scale(1.32);
+ transform-origin: center center;
+ }
+
+.emby-tabs-slider {
+ position: relative;
}
.emby-tab-button-ripple-effect {
- background: rgba(0, 0, 0, .7) !important
+ background: rgba(0,0,0,.7) !important;
}
.tabContent:not(.is-active) {
- display: none
-}
\ No newline at end of file
+ display: none;
+}
diff --git a/src/bower_components/emby-webcomponents/emby-tabs/emby-tabs.js b/src/bower_components/emby-webcomponents/emby-tabs/emby-tabs.js
index 3408072a8a..3642facd2a 100644
--- a/src/bower_components/emby-webcomponents/emby-tabs/emby-tabs.js
+++ b/src/bower_components/emby-webcomponents/emby-tabs/emby-tabs.js
@@ -1,191 +1,370 @@
-define(["dom", "scroller", "browser", "layoutManager", "focusManager", "registerElement", "css!./emby-tabs", "scrollStyles"], function(dom, scroller, browser, layoutManager, focusManager) {
- "use strict";
+define(['dom', 'scroller', 'browser', 'layoutManager', 'focusManager', 'registerElement', 'css!./emby-tabs', 'scrollStyles'], function (dom, scroller, browser, layoutManager, focusManager) {
+ 'use strict';
+
+ var EmbyTabs = Object.create(HTMLDivElement.prototype);
+ var buttonClass = 'emby-tab-button';
+ var activeButtonClass = buttonClass + '-active';
function setActiveTabButton(tabs, newButton, oldButton, animate) {
- newButton.classList.add(activeButtonClass)
+
+ newButton.classList.add(activeButtonClass);
}
function getFocusCallback(tabs, e) {
- return function() {
- onClick.call(tabs, e)
- }
+ return function () {
+ onClick.call(tabs, e);
+ };
}
function onFocus(e) {
- layoutManager.tv && (this.focusTimeout && clearTimeout(this.focusTimeout), this.focusTimeout = setTimeout(getFocusCallback(this, e), 700))
+
+ if (layoutManager.tv) {
+
+ if (this.focusTimeout) {
+ clearTimeout(this.focusTimeout);
+ }
+ this.focusTimeout = setTimeout(getFocusCallback(this, e), 700);
+ }
}
function getTabPanel(tabs, index) {
- return null
+
+ return null;
}
function removeActivePanelClass(tabs, index) {
var tabPanel = getTabPanel(tabs, index);
- tabPanel && tabPanel.classList.remove("is-active")
+ if (tabPanel) {
+ tabPanel.classList.remove('is-active');
+ }
+ }
+
+ function addActivePanelClass(tabs, index) {
+ var tabPanel = getTabPanel(tabs, index);
+ if (tabPanel) {
+ tabPanel.classList.add('is-active');
+ }
}
function fadeInRight(elem) {
- var pct = browser.mobile ? "4%" : "0.5%",
- keyframes = [{
- opacity: "0",
- transform: "translate3d(" + pct + ", 0, 0)",
- offset: 0
- }, {
- opacity: "1",
- transform: "none",
- offset: 1
- }];
+
+ var pct = browser.mobile ? '4%' : '0.5%';
+
+ var keyframes = [
+ { opacity: '0', transform: 'translate3d(' + pct + ', 0, 0)', offset: 0 },
+ { opacity: '1', transform: 'none', offset: 1 }];
+
elem.animate(keyframes, {
duration: 160,
iterations: 1,
- easing: "ease-out"
- })
+ easing: 'ease-out'
+ });
}
function triggerBeforeTabChange(tabs, index, previousIndex) {
+
tabs.dispatchEvent(new CustomEvent("beforetabchange", {
detail: {
selectedTabIndex: index,
previousIndex: previousIndex
}
- })), null != previousIndex && previousIndex !== index && removeActivePanelClass(tabs, previousIndex);
+ }));
+ if (previousIndex != null && previousIndex !== index) {
+ removeActivePanelClass(tabs, previousIndex);
+ }
+
var newPanel = getTabPanel(tabs, index);
- newPanel && (newPanel.animate && fadeInRight(newPanel), newPanel.classList.add("is-active"))
+
+ if (newPanel) {
+ // animate new panel ?
+ if (newPanel.animate) {
+ fadeInRight(newPanel);
+ }
+
+ newPanel.classList.add('is-active');
+ }
}
function onClick(e) {
- this.focusTimeout && clearTimeout(this.focusTimeout);
- var tabs = this,
- current = tabs.querySelector("." + activeButtonClass),
- tabButton = dom.parentWithClass(e.target, buttonClass);
+
+ if (this.focusTimeout) {
+ clearTimeout(this.focusTimeout);
+ }
+
+ var tabs = this;
+
+ var current = tabs.querySelector('.' + activeButtonClass);
+ var tabButton = dom.parentWithClass(e.target, buttonClass);
+
if (tabButton && tabButton !== current) {
- current && current.classList.remove(activeButtonClass);
- var previousIndex = current ? parseInt(current.getAttribute("data-index")) : null;
- setActiveTabButton(tabs, tabButton, current, !0);
- var index = parseInt(tabButton.getAttribute("data-index"));
- triggerBeforeTabChange(tabs, index, previousIndex), setTimeout(function() {
- tabs.selectedTabIndex = index, tabs.dispatchEvent(new CustomEvent("tabchange", {
+
+ if (current) {
+ current.classList.remove(activeButtonClass);
+ }
+
+ var previousIndex = current ? parseInt(current.getAttribute('data-index')) : null;
+
+ setActiveTabButton(tabs, tabButton, current, true);
+
+ var index = parseInt(tabButton.getAttribute('data-index'));
+
+ triggerBeforeTabChange(tabs, index, previousIndex);
+
+ // If toCenter is called syncronously within the click event, it sometimes ends up canceling it
+ setTimeout(function () {
+
+ tabs.selectedTabIndex = index;
+
+ tabs.dispatchEvent(new CustomEvent("tabchange", {
detail: {
selectedTabIndex: index,
previousIndex: previousIndex
}
- }))
- }, 120), tabs.scroller && tabs.scroller.toCenter(tabButton, !1)
+ }));
+ }, 120);
+
+ if (tabs.scroller) {
+ tabs.scroller.toCenter(tabButton, false);
+ }
+
}
}
function initScroller(tabs) {
- if (!tabs.scroller) {
- var contentScrollSlider = tabs.querySelector(".emby-tabs-slider");
- contentScrollSlider ? (tabs.scroller = new scroller(tabs, {
+
+ if (tabs.scroller) {
+ return;
+ }
+
+ var contentScrollSlider = tabs.querySelector('.emby-tabs-slider');
+ if (contentScrollSlider) {
+ tabs.scroller = new scroller(tabs, {
horizontal: 1,
itemNav: 0,
mouseDragging: 1,
touchDragging: 1,
slidee: contentScrollSlider,
- smart: !0,
- releaseSwing: !0,
+ smart: true,
+ releaseSwing: true,
scrollBy: 200,
speed: 120,
elasticBounds: 1,
dragHandle: 1,
dynamicHandle: 1,
clickBar: 1,
- hiddenScroll: !0,
+ hiddenScroll: true,
+
+ // In safari the transform is causing the headers to occasionally disappear or flicker
requireAnimation: !browser.safari,
- allowNativeSmoothScroll: !0
- }), tabs.scroller.init()) : (tabs.classList.add("scrollX"), tabs.classList.add("hiddenScrollX"), tabs.classList.add("smoothScrollX"))
- }
+ allowNativeSmoothScroll: true
+ });
+ tabs.scroller.init();
+ } else {
+ tabs.classList.add('scrollX');
+ tabs.classList.add('hiddenScrollX');
+ tabs.classList.add('smoothScrollX');
+ }
}
+ EmbyTabs.createdCallback = function () {
+
+ if (this.classList.contains('emby-tabs')) {
+ return;
+ }
+ this.classList.add('emby-tabs');
+ this.classList.add('focusable');
+
+ dom.addEventListener(this, 'click', onClick, {
+ passive: true
+ });
+ dom.addEventListener(this, 'focus', onFocus, {
+ passive: true,
+ capture: true
+ });
+ };
+
+ EmbyTabs.focus = function () {
+
+ var selected = this.querySelector('.' + activeButtonClass);
+
+ if (selected) {
+ focusManager.focus(selected);
+ } else {
+ focusManager.autoFocus(this);
+ }
+ };
+
+ EmbyTabs.refresh = function () {
+
+ if (this.scroller) {
+ this.scroller.reload();
+ }
+ };
+
+ EmbyTabs.attachedCallback = function () {
+
+ initScroller(this);
+
+ var current = this.querySelector('.' + activeButtonClass);
+ var currentIndex = current ? parseInt(current.getAttribute('data-index')) : parseInt(this.getAttribute('data-index') || '0');
+
+ if (currentIndex !== -1) {
+
+ this.selectedTabIndex = currentIndex;
+
+ var tabButtons = this.querySelectorAll('.' + buttonClass);
+
+ var newTabButton = tabButtons[currentIndex];
+
+ if (newTabButton) {
+ setActiveTabButton(this, newTabButton, current, false);
+ }
+ }
+
+ if (!this.readyFired) {
+ this.readyFired = true;
+ this.dispatchEvent(new CustomEvent("ready", {}));
+ }
+ };
+
+ EmbyTabs.detachedCallback = function () {
+
+ if (this.scroller) {
+ this.scroller.destroy();
+ this.scroller = null;
+ }
+
+ dom.removeEventListener(this, 'click', onClick, {
+ passive: true
+ });
+ dom.removeEventListener(this, 'focus', onFocus, {
+ passive: true,
+ capture: true
+ });
+ };
+
function getSelectedTabButton(elem) {
- return elem.querySelector("." + activeButtonClass)
+
+ return elem.querySelector('.' + activeButtonClass);
}
- function getSibling(elem, method) {
- for (var sibling = elem[method]; sibling;) {
- if (sibling.classList.contains(buttonClass) && !sibling.classList.contains("hide")) return sibling;
- sibling = sibling[method]
- }
- return null
- }
- var EmbyTabs = Object.create(HTMLDivElement.prototype),
- buttonClass = "emby-tab-button",
- activeButtonClass = buttonClass + "-active";
- EmbyTabs.createdCallback = function() {
- this.classList.contains("emby-tabs") || (this.classList.add("emby-tabs"), this.classList.add("focusable"), dom.addEventListener(this, "click", onClick, {
- passive: !0
- }), dom.addEventListener(this, "focus", onFocus, {
- passive: !0,
- capture: !0
- }))
- }, EmbyTabs.focus = function() {
- var selected = this.querySelector("." + activeButtonClass);
- selected ? focusManager.focus(selected) : focusManager.autoFocus(this)
- }, EmbyTabs.refresh = function() {
- this.scroller && this.scroller.reload()
- }, EmbyTabs.attachedCallback = function() {
- initScroller(this);
- var current = this.querySelector("." + activeButtonClass),
- currentIndex = current ? parseInt(current.getAttribute("data-index")) : parseInt(this.getAttribute("data-index") || "0");
- if (-1 !== currentIndex) {
- this.selectedTabIndex = currentIndex;
- var tabButtons = this.querySelectorAll("." + buttonClass),
- newTabButton = tabButtons[currentIndex];
- newTabButton && setActiveTabButton(this, newTabButton, current, !1)
- }
- this.readyFired || (this.readyFired = !0, this.dispatchEvent(new CustomEvent("ready", {})))
- }, EmbyTabs.detachedCallback = function() {
- this.scroller && (this.scroller.destroy(), this.scroller = null), dom.removeEventListener(this, "click", onClick, {
- passive: !0
- }), dom.removeEventListener(this, "focus", onFocus, {
- passive: !0,
- capture: !0
- })
- }, EmbyTabs.selectedIndex = function(selected, triggerEvent) {
+ EmbyTabs.selectedIndex = function (selected, triggerEvent) {
+
var tabs = this;
- if (null == selected) return tabs.selectedTabIndex || 0;
+
+ if (selected == null) {
+
+ return tabs.selectedTabIndex || 0;
+ }
+
var current = tabs.selectedIndex();
+
tabs.selectedTabIndex = selected;
- var tabButtons = tabs.querySelectorAll("." + buttonClass);
- if (current === selected || !1 === triggerEvent) {
- triggerBeforeTabChange(tabs, selected, current), tabs.dispatchEvent(new CustomEvent("tabchange", {
+
+ var tabButtons = tabs.querySelectorAll('.' + buttonClass);
+
+ if (current === selected || triggerEvent === false) {
+
+ triggerBeforeTabChange(tabs, selected, current);
+
+ tabs.dispatchEvent(new CustomEvent("tabchange", {
detail: {
selectedTabIndex: selected
}
}));
+
var currentTabButton = tabButtons[current];
- setActiveTabButton(tabs, tabButtons[selected], currentTabButton, !1), current !== selected && currentTabButton && currentTabButton.classList.remove(activeButtonClass)
- } else onClick.call(tabs, {
- target: tabButtons[selected]
- })
- }, EmbyTabs.selectNext = function() {
- var current = getSelectedTabButton(this),
- sibling = getSibling(current, "nextSibling");
- sibling && onClick.call(this, {
- target: sibling
- })
- }, EmbyTabs.selectPrevious = function() {
- var current = getSelectedTabButton(this),
- sibling = getSibling(current, "previousSibling");
- sibling && onClick.call(this, {
- target: sibling
- })
- }, EmbyTabs.triggerBeforeTabChange = function(selected) {
+ setActiveTabButton(tabs, tabButtons[selected], currentTabButton, false);
+
+ if (current !== selected && currentTabButton) {
+ currentTabButton.classList.remove(activeButtonClass);
+ }
+
+ } else {
+
+ onClick.call(tabs, {
+ target: tabButtons[selected]
+ });
+ //tabButtons[selected].click();
+ }
+ };
+
+ function getSibling(elem, method) {
+
+ var sibling = elem[method];
+
+ while (sibling) {
+ if (sibling.classList.contains(buttonClass)) {
+
+ if (!sibling.classList.contains('hide')) {
+ return sibling;
+ }
+ }
+
+ sibling = sibling[method];
+ }
+
+ return null;
+ }
+
+ EmbyTabs.selectNext = function () {
+
+ var current = getSelectedTabButton(this);
+
+ var sibling = getSibling(current, 'nextSibling');
+
+ if (sibling) {
+ onClick.call(this, {
+ target: sibling
+ });
+ }
+ };
+
+ EmbyTabs.selectPrevious = function () {
+
+ var current = getSelectedTabButton(this);
+
+ var sibling = getSibling(current, 'previousSibling');
+
+ if (sibling) {
+ onClick.call(this, {
+ target: sibling
+ });
+ }
+ };
+
+ EmbyTabs.triggerBeforeTabChange = function (selected) {
+
var tabs = this;
- triggerBeforeTabChange(tabs, tabs.selectedIndex())
- }, EmbyTabs.triggerTabChange = function(selected) {
+
+ triggerBeforeTabChange(tabs, tabs.selectedIndex());
+ };
+
+ EmbyTabs.triggerTabChange = function (selected) {
+
var tabs = this;
+
tabs.dispatchEvent(new CustomEvent("tabchange", {
detail: {
selectedTabIndex: tabs.selectedIndex()
}
- }))
- }, EmbyTabs.setTabEnabled = function(index, enabled) {
+ }));
+ };
+
+ EmbyTabs.setTabEnabled = function (index, enabled) {
+
+ var tabs = this;
var btn = this.querySelector('.emby-tab-button[data-index="' + index + '"]');
- enabled ? btn.classList.remove("hide") : btn.classList.remove("add")
- }, document.registerElement("emby-tabs", {
+
+ if (enabled) {
+ btn.classList.remove('hide');
+ } else {
+ btn.classList.remove('add');
+ }
+ };
+
+ document.registerElement('emby-tabs', {
prototype: EmbyTabs,
- extends: "div"
- })
+ extends: 'div'
+ });
});
\ No newline at end of file
diff --git a/src/bower_components/emby-webcomponents/emby-textarea/emby-textarea.css b/src/bower_components/emby-webcomponents/emby-textarea/emby-textarea.css
index 18313cffd1..6ac8262236 100644
--- a/src/bower_components/emby-webcomponents/emby-textarea/emby-textarea.css
+++ b/src/bower_components/emby-webcomponents/emby-textarea/emby-textarea.css
@@ -2,30 +2,31 @@
display: block;
margin: 0;
margin-bottom: 0 !important;
+ /* Remove select styling */
+ /* Font size must the 16px or larger to prevent iOS page zoom on focus */
font-size: inherit;
+ /* General select styles: change as needed */
font-family: inherit;
font-weight: inherit;
color: inherit;
padding: .35em .25em;
- -webkit-box-sizing: border-box;
+ /* Prevent padding from causing width overflow */
box-sizing: border-box;
- outline: 0 !important;
- -webkit-tap-highlight-color: transparent;
- width: 100%
+ outline: none !important;
+ -webkit-tap-highlight-color: rgba(0,0,0,0);
+ width: 100%;
}
-.emby-textarea::-moz-focus-inner {
- border: 0
-}
+ .emby-textarea::-moz-focus-inner {
+ border: 0;
+ }
.textareaLabel {
display: inline-block;
- -webkit-transition: all .2s ease-out;
- -o-transition: all .2s ease-out;
transition: all .2s ease-out;
- margin-bottom: .25em
+ margin-bottom: .25em;
}
-.emby-textarea+.fieldDescription {
- margin-top: .25em
-}
\ No newline at end of file
+.emby-textarea + .fieldDescription {
+ margin-top: .25em;
+}
diff --git a/src/bower_components/emby-webcomponents/emby-textarea/emby-textarea.js b/src/bower_components/emby-webcomponents/emby-textarea/emby-textarea.js
index f5725c2301..130d6c3980 100644
--- a/src/bower_components/emby-webcomponents/emby-textarea/emby-textarea.js
+++ b/src/bower_components/emby-webcomponents/emby-textarea/emby-textarea.js
@@ -1,55 +1,138 @@
-define(["layoutManager", "browser", "css!./emby-textarea", "registerElement", "emby-input"], function(layoutManager, browser) {
- "use strict";
+define(['layoutManager', 'browser', 'css!./emby-textarea', 'registerElement', 'emby-input'], function (layoutManager, browser) {
+ 'use strict';
function autoGrow(textarea, maxLines) {
+ var self = this;
+
+ if (maxLines === undefined) {
+ maxLines = 999;
+ }
+
+ /**
+ * Calculates the vertical padding of the element
+ * @param textarea
+ * @returns {number}
+ */
+ self.getOffset = function (textarea) {
+ var style = window.getComputedStyle(textarea, null),
+ props = ['paddingTop', 'paddingBottom'],
+ offset = 0;
+
+ for (var i = 0; i < props.length; i++) {
+ offset += parseInt(style[props[i]]);
+ }
+ return offset;
+ };
+
+ var offset;
function reset() {
- textarea.rows = 1, offset = self.getOffset(textarea), self.rows = textarea.rows || 1, self.lineHeight = textarea.scrollHeight / self.rows - offset / self.rows, self.maxAllowedHeight = self.lineHeight * maxLines - offset
+ textarea.rows = 1;
+ offset = self.getOffset(textarea);
+ self.rows = textarea.rows || 1;
+ self.lineHeight = (textarea.scrollHeight / self.rows) - (offset / self.rows);
+ self.maxAllowedHeight = (self.lineHeight * maxLines) - offset;
}
function autogrowFn() {
- if ((!self.lineHeight || self.lineHeight <= 0) && reset(), self.lineHeight <= 0) return textarea.style.overflowY = "scroll", textarea.style.height = "auto", void(textarea.rows = 3);
- var newHeight = 0;
- textarea.scrollHeight - offset > self.maxAllowedHeight ? (textarea.style.overflowY = "scroll", newHeight = self.maxAllowedHeight) : (textarea.style.overflowY = "hidden", textarea.style.height = "auto", newHeight = textarea.scrollHeight), textarea.style.height = newHeight + "px"
+ if (!self.lineHeight || self.lineHeight <= 0) {
+ reset();
+ }
+ if (self.lineHeight <= 0) {
+ textarea.style.overflowY = 'scroll';
+ textarea.style.height = 'auto';
+ textarea.rows = 3;
+ return;
+ }
+ var newHeight = 0, hasGrown = false;
+
+ if ((textarea.scrollHeight - offset) > self.maxAllowedHeight) {
+ textarea.style.overflowY = 'scroll';
+ newHeight = self.maxAllowedHeight;
+ }
+ else {
+ textarea.style.overflowY = 'hidden';
+ textarea.style.height = 'auto';
+ newHeight = textarea.scrollHeight/* - offset*/;
+ hasGrown = true;
+ }
+ textarea.style.height = newHeight + 'px';
}
- var self = this;
- void 0 === maxLines && (maxLines = 999), self.getOffset = function(textarea) {
- for (var style = window.getComputedStyle(textarea, null), props = ["paddingTop", "paddingBottom"], offset = 0, i = 0; i < props.length; i++) offset += parseInt(style[props[i]]);
- return offset
- };
- var offset;
- textarea.addEventListener("input", autogrowFn), textarea.addEventListener("focus", autogrowFn), textarea.addEventListener("valueset", autogrowFn), autogrowFn()
+
+ // Call autogrowFn() when textarea's value is changed
+ textarea.addEventListener('input', autogrowFn);
+ textarea.addEventListener('focus', autogrowFn);
+ textarea.addEventListener('valueset', autogrowFn);
+
+ autogrowFn();
}
- var EmbyTextAreaPrototype = Object.create(HTMLTextAreaElement.prototype),
- elementId = 0;
+
+ var EmbyTextAreaPrototype = Object.create(HTMLTextAreaElement.prototype);
+
+ var elementId = 0;
+
if (Object.getOwnPropertyDescriptor && Object.defineProperty) {
- var descriptor = Object.getOwnPropertyDescriptor(HTMLTextAreaElement.prototype, "value");
+
+ var descriptor = Object.getOwnPropertyDescriptor(HTMLTextAreaElement.prototype, 'value');
+
+ // descriptor returning null in webos
if (descriptor && descriptor.configurable) {
var baseSetMethod = descriptor.set;
- descriptor.set = function(value) {
- baseSetMethod.call(this, value), this.dispatchEvent(new CustomEvent("valueset", {
- bubbles: !1,
- cancelable: !1
- }))
- }, Object.defineProperty(HTMLTextAreaElement.prototype, "value", descriptor)
+ descriptor.set = function (value) {
+ baseSetMethod.call(this, value);
+
+ this.dispatchEvent(new CustomEvent('valueset', {
+ bubbles: false,
+ cancelable: false
+ }));
+ };
+
+ Object.defineProperty(HTMLTextAreaElement.prototype, 'value', descriptor);
}
}
- EmbyTextAreaPrototype.createdCallback = function() {
- this.id || (this.id = "embytextarea" + elementId, elementId++)
- }, EmbyTextAreaPrototype.attachedCallback = function() {
- if (!this.classList.contains("emby-textarea")) {
- this.rows = 1, this.classList.add("emby-textarea");
- var parentNode = this.parentNode,
- label = this.ownerDocument.createElement("label");
- label.innerHTML = this.getAttribute("label") || "", label.classList.add("textareaLabel"), label.htmlFor = this.id, parentNode.insertBefore(label, this), this.addEventListener("focus", function() {
- label.classList.add("textareaLabelFocused"), label.classList.remove("textareaLabelUnfocused")
- }), this.addEventListener("blur", function() {
- label.classList.remove("textareaLabelFocused"), label.classList.add("textareaLabelUnfocused")
- }), this.label = function(text) {
- label.innerHTML = text
- }, new autoGrow(this)
+
+ EmbyTextAreaPrototype.createdCallback = function () {
+
+ if (!this.id) {
+ this.id = 'embytextarea' + elementId;
+ elementId++;
}
- }, document.registerElement("emby-textarea", {
+ };
+
+ EmbyTextAreaPrototype.attachedCallback = function () {
+
+ if (this.classList.contains('emby-textarea')) {
+ return;
+ }
+
+ this.rows = 1;
+ this.classList.add('emby-textarea');
+
+ var parentNode = this.parentNode;
+ var label = this.ownerDocument.createElement('label');
+ label.innerHTML = this.getAttribute('label') || '';
+ label.classList.add('textareaLabel');
+
+ label.htmlFor = this.id;
+ parentNode.insertBefore(label, this);
+
+ this.addEventListener('focus', function () {
+ label.classList.add('textareaLabelFocused');
+ label.classList.remove('textareaLabelUnfocused');
+ });
+ this.addEventListener('blur', function () {
+ label.classList.remove('textareaLabelFocused');
+ label.classList.add('textareaLabelUnfocused');
+ });
+
+ this.label = function (text) {
+ label.innerHTML = text;
+ };
+
+ new autoGrow(this);
+ };
+
+ document.registerElement('emby-textarea', {
prototype: EmbyTextAreaPrototype,
- extends: "textarea"
- })
+ extends: 'textarea'
+ });
});
\ No newline at end of file
diff --git a/src/bower_components/emby-webcomponents/emby-toggle/emby-toggle.css b/src/bower_components/emby-webcomponents/emby-toggle/emby-toggle.css
index c03115e976..fc3d04ebc9 100644
--- a/src/bower_components/emby-webcomponents/emby-toggle/emby-toggle.css
+++ b/src/bower_components/emby-webcomponents/emby-toggle/emby-toggle.css
@@ -2,13 +2,8 @@
position: relative;
z-index: 1;
vertical-align: middle;
- display: -webkit-inline-box;
- display: -webkit-inline-flex;
display: inline-flex;
- -webkit-box-align: center;
- -webkit-align-items: center;
align-items: center;
- -webkit-box-sizing: border-box;
box-sizing: border-box;
width: 100%;
margin: 0;
@@ -19,17 +14,12 @@
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
- -webkit-box-orient: horizontal;
- -webkit-box-direction: reverse;
- -webkit-flex-direction: row-reverse;
flex-direction: row-reverse;
- -webkit-box-pack: end;
- -webkit-justify-content: flex-end;
- justify-content: flex-end
+ justify-content: flex-end;
}
.toggleContainer {
- margin-bottom: 1.8em
+ margin-bottom: 1.8em;
}
.mdl-switch__input {
@@ -42,29 +32,28 @@
-moz-appearance: none;
-webkit-appearance: none;
appearance: none;
- border: none
+ border: none;
}
.mdl-switch__trackContainer {
position: relative;
- width: 2.9em
+ width: 2.9em;
}
.mdl-switch__track {
- background: rgba(0, 0, 0, .2);
+ background: rgba(0,0,0, 0.2);
height: 1em;
- -webkit-border-radius: 1em;
border-radius: 1em;
- cursor: pointer
+ cursor: pointer;
}
-.mdl-switch__input:checked+.mdl-switch__label+.mdl-switch__trackContainer>.mdl-switch__track {
- background: rgba(0,164,220, .5)
+.mdl-switch__input:checked + .mdl-switch__label + .mdl-switch__trackContainer > .mdl-switch__track {
+ background: rgba(0, 164, 220, 0.5);
}
-.mdl-switch__input[disabled]+.mdl-switch__label+.mdl-switch__trackContainer>.mdl-switch__track {
- background: rgba(0, 0, 0, .12);
- cursor: auto
+.mdl-switch__input[disabled] + .mdl-switch__label + .mdl-switch__trackContainer > .mdl-switch__track {
+ background: rgba(0,0,0, 0.12);
+ cursor: auto;
}
.mdl-switch__thumb {
@@ -74,41 +63,26 @@
top: -.25em;
height: 1.44em;
width: 1.44em;
- -webkit-border-radius: 50%;
border-radius: 50%;
cursor: pointer;
- -webkit-box-shadow: 0 2px 2px 0 rgba(0, 0, 0, .14), 0 3px 1px -2px rgba(0, 0, 0, .2), 0 1px 5px 0 rgba(0, 0, 0, .12);
- box-shadow: 0 2px 2px 0 rgba(0, 0, 0, .14), 0 3px 1px -2px rgba(0, 0, 0, .2), 0 1px 5px 0 rgba(0, 0, 0, .12);
- -webkit-transition-duration: .28s;
- -o-transition-duration: .28s;
- transition-duration: .28s;
- -webkit-transition-timing-function: cubic-bezier(.4, 0, .2, 1);
- -o-transition-timing-function: cubic-bezier(.4, 0, .2, 1);
- transition-timing-function: cubic-bezier(.4, 0, .2, 1);
- -webkit-transition-property: left;
- -o-transition-property: left;
+ box-shadow: 0 2px 2px 0 rgba(0, 0, 0, 0.14), 0 3px 1px -2px rgba(0, 0, 0, 0.2), 0 1px 5px 0 rgba(0, 0, 0, 0.12);
+ transition-duration: 0.28s;
+ transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
transition-property: left;
- display: -webkit-box;
- display: -webkit-flex;
display: flex;
- -webkit-box-align: center;
- -webkit-align-items: center;
align-items: center;
- -webkit-box-pack: center;
- -webkit-justify-content: center;
- justify-content: center
+ justify-content: center;
}
-.mdl-switch__input:checked+.mdl-switch__label+.mdl-switch__trackContainer>.mdl-switch__thumb {
+.mdl-switch__input:checked + .mdl-switch__label + .mdl-switch__trackContainer > .mdl-switch__thumb {
background: #00a4dc;
left: 1.466em;
- -webkit-box-shadow: 0 3px .28em 0 rgba(0, 0, 0, .14), 0 3px 3px -2px rgba(0, 0, 0, .2), 0 1px .56em 0 rgba(0, 0, 0, .12);
- box-shadow: 0 3px .28em 0 rgba(0, 0, 0, .14), 0 3px 3px -2px rgba(0, 0, 0, .2), 0 1px .56em 0 rgba(0, 0, 0, .12)
+ box-shadow: 0 3px 0.28em 0 rgba(0, 0, 0, 0.14), 0 3px 3px -2px rgba(0, 0, 0, 0.2), 0 1px .56em 0 rgba(0, 0, 0, 0.12);
}
-.mdl-switch__input[disabled]+.mdl-switch__label+.mdl-switch__trackContainer>.mdl-switch__thumb {
- background: #bdbdbd;
- cursor: auto
+.mdl-switch__input[disabled] + .mdl-switch__label + .mdl-switch__trackContainer > .mdl-switch__thumb {
+ background: rgb(189,189,189);
+ cursor: auto;
}
.mdl-switch__focus-helper {
@@ -118,38 +92,31 @@
-webkit-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
display: inline-block;
- -webkit-box-sizing: border-box;
box-sizing: border-box;
width: .6em;
height: .6em;
- -webkit-border-radius: 50%;
border-radius: 50%;
- background-color: transparent
+ background-color: transparent;
}
-.mdl-switch__input:focus+.mdl-switch__label+.mdl-switch__trackContainer .mdl-switch__focus-helper {
- -webkit-box-shadow: 0 0 0 1.39em rgba(0, 0, 0, .05);
- box-shadow: 0 0 0 1.39em rgba(0, 0, 0, .05)
+.mdl-switch__input:focus + .mdl-switch__label + .mdl-switch__trackContainer .mdl-switch__focus-helper {
+ box-shadow: 0 0 0 1.39em rgba(0, 0, 0, .05);
}
-.mdl-switch__input:checked:focus+.mdl-switch__label+.mdl-switch__trackContainer .mdl-switch__focus-helper {
- -webkit-box-shadow: 0 0 0 1.39em rgba(0,164,220, .26);
- box-shadow: 0 0 0 1.39em rgba(0,164,220, .26);
- background-color: rgba(0,164,220, .26)
+.mdl-switch__input:checked:focus + .mdl-switch__label + .mdl-switch__trackContainer .mdl-switch__focus-helper {
+ box-shadow: 0 0 0 1.39em rgba(0, 164, 220, 0.26);
+ background-color: rgba(0, 164, 220, 0.26);
}
.mdl-switch__label {
cursor: pointer;
- margin: 0 0 0 .7em;
- display: -webkit-inline-box;
- display: -webkit-inline-flex;
+ margin: 0;
display: inline-flex;
- -webkit-box-align: center;
- -webkit-align-items: center;
- align-items: center
+ align-items: center;
+ margin-left: .7em;
}
.mdl-switch__input[disabled] .mdl-switch__label {
- color: #bdbdbd;
- cursor: auto
-}
\ No newline at end of file
+ color: rgb(189,189,189);
+ cursor: auto;
+}
diff --git a/src/bower_components/emby-webcomponents/emby-toggle/emby-toggle.js b/src/bower_components/emby-webcomponents/emby-toggle/emby-toggle.js
index f62899902d..d6d31957b2 100644
--- a/src/bower_components/emby-webcomponents/emby-toggle/emby-toggle.js
+++ b/src/bower_components/emby-webcomponents/emby-toggle/emby-toggle.js
@@ -1,22 +1,50 @@
-define(["css!./emby-toggle", "registerElement"], function() {
- "use strict";
+define(['css!./emby-toggle', 'registerElement'], function () {
+ 'use strict';
+
+ var EmbyTogglePrototype = Object.create(HTMLInputElement.prototype);
function onKeyDown(e) {
- if (13 === e.keyCode) return e.preventDefault(), this.checked = !this.checked, this.dispatchEvent(new CustomEvent("change", {
- bubbles: !0
- })), !1
- }
- var EmbyTogglePrototype = Object.create(HTMLInputElement.prototype);
- EmbyTogglePrototype.attachedCallback = function() {
- if ("true" !== this.getAttribute("data-embytoggle")) {
- this.setAttribute("data-embytoggle", "true"), this.classList.add("mdl-switch__input");
- var labelElement = this.parentNode;
- labelElement.classList.add("mdl-switch"), labelElement.classList.add("mdl-js-switch");
- var labelTextElement = labelElement.querySelector("span");
- labelElement.insertAdjacentHTML("beforeend", '
'), labelTextElement.classList.add("toggleButtonLabel"), labelTextElement.classList.add("mdl-switch__label"), this.addEventListener("keydown", onKeyDown)
+
+ // Don't submit form on enter
+ if (e.keyCode === 13) {
+ e.preventDefault();
+
+ this.checked = !this.checked;
+
+ this.dispatchEvent(new CustomEvent('change', {
+ bubbles: true
+ }));
+
+ return false;
}
- }, document.registerElement("emby-toggle", {
+ }
+
+ EmbyTogglePrototype.attachedCallback = function () {
+
+ if (this.getAttribute('data-embytoggle') === 'true') {
+ return;
+ }
+
+ this.setAttribute('data-embytoggle', 'true');
+
+ this.classList.add('mdl-switch__input');
+
+ var labelElement = this.parentNode;
+ labelElement.classList.add('mdl-switch');
+ labelElement.classList.add('mdl-js-switch');
+
+ var labelTextElement = labelElement.querySelector('span');
+
+ labelElement.insertAdjacentHTML('beforeend', '
');
+
+ labelTextElement.classList.add('toggleButtonLabel');
+ labelTextElement.classList.add('mdl-switch__label');
+
+ this.addEventListener('keydown', onKeyDown);
+ };
+
+ document.registerElement('emby-toggle', {
prototype: EmbyTogglePrototype,
- extends: "input"
- })
+ extends: 'input'
+ });
});
\ No newline at end of file
diff --git a/src/bower_components/emby-webcomponents/fetchhelper.js b/src/bower_components/emby-webcomponents/fetchhelper.js
index ed0c74d6c4..64bd5159a5 100644
--- a/src/bower_components/emby-webcomponents/fetchhelper.js
+++ b/src/bower_components/emby-webcomponents/fetchhelper.js
@@ -1,54 +1,132 @@
-define([], function() {
- "use strict";
+define([], function () {
+ 'use strict';
function getFetchPromise(request) {
+
var headers = request.headers || {};
- "json" === request.dataType && (headers.accept = "application/json");
+
+ if (request.dataType === 'json') {
+ headers.accept = 'application/json';
+ }
+
var fetchRequest = {
- headers: headers,
- method: request.type,
- credentials: "same-origin"
- },
- contentType = request.contentType;
- request.data && ("string" == typeof request.data ? fetchRequest.body = request.data : (fetchRequest.body = paramsToString(request.data), contentType = contentType || "application/x-www-form-urlencoded; charset=UTF-8")), contentType && (headers["Content-Type"] = contentType);
+ headers: headers,
+ method: request.type,
+ credentials: 'same-origin'
+ };
+
+ var contentType = request.contentType;
+
+ if (request.data) {
+
+ if (typeof request.data === 'string') {
+ fetchRequest.body = request.data;
+ } else {
+ fetchRequest.body = paramsToString(request.data);
+
+ contentType = contentType || 'application/x-www-form-urlencoded; charset=UTF-8';
+ }
+ }
+
+ if (contentType) {
+
+ headers['Content-Type'] = contentType;
+ }
+
var url = request.url;
+
if (request.query) {
var paramString = paramsToString(request.query);
- paramString && (url += "?" + paramString)
+ if (paramString) {
+ url += '?' + paramString;
+ }
}
- return request.timeout ? fetchWithTimeout(url, fetchRequest, request.timeout) : fetch(url, fetchRequest)
+
+ if (!request.timeout) {
+ return fetch(url, fetchRequest);
+ }
+
+ return fetchWithTimeout(url, fetchRequest, request.timeout);
}
function fetchWithTimeout(url, options, timeoutMs) {
- return console.log("fetchWithTimeout: timeoutMs: " + timeoutMs + ", url: " + url), new Promise(function(resolve, reject) {
+
+ console.log('fetchWithTimeout: timeoutMs: ' + timeoutMs + ', url: ' + url);
+
+ return new Promise(function (resolve, reject) {
+
var timeout = setTimeout(reject, timeoutMs);
- options = options || {}, options.credentials = "same-origin", fetch(url, options).then(function(response) {
- clearTimeout(timeout), console.log("fetchWithTimeout: succeeded connecting to url: " + url), resolve(response)
- }, function(error) {
- clearTimeout(timeout), console.log("fetchWithTimeout: timed out connecting to url: " + url), reject()
- })
- })
+
+ options = options || {};
+ options.credentials = 'same-origin';
+
+ fetch(url, options).then(function (response) {
+ clearTimeout(timeout);
+
+ console.log('fetchWithTimeout: succeeded connecting to url: ' + url);
+
+ resolve(response);
+ }, function (error) {
+
+ clearTimeout(timeout);
+
+ console.log('fetchWithTimeout: timed out connecting to url: ' + url);
+
+ reject();
+ });
+ });
}
function paramsToString(params) {
+
var values = [];
+
for (var key in params) {
+
var value = params[key];
- null !== value && void 0 !== value && "" !== value && values.push(encodeURIComponent(key) + "=" + encodeURIComponent(value))
+
+ if (value !== null && value !== undefined && value !== '') {
+ values.push(encodeURIComponent(key) + "=" + encodeURIComponent(value));
+ }
}
- return values.join("&")
+ return values.join('&');
}
function ajax(request) {
- if (!request) throw new Error("Request cannot be null");
- return request.headers = request.headers || {}, console.log("requesting url: " + request.url), getFetchPromise(request).then(function(response) {
- return console.log("response status: " + response.status + ", url: " + request.url), response.status < 400 ? "json" === request.dataType || "application/json" === request.headers.accept ? response.json() : "text" === request.dataType || 0 === (response.headers.get("Content-Type") || "").toLowerCase().indexOf("text/") ? response.text() : response : Promise.reject(response)
- }, function(err) {
- throw console.log("request failed to url: " + request.url), err
- })
+
+ if (!request) {
+ throw new Error("Request cannot be null");
+ }
+
+ request.headers = request.headers || {};
+
+ console.log('requesting url: ' + request.url);
+
+ return getFetchPromise(request).then(function (response) {
+
+ console.log('response status: ' + response.status + ', url: ' + request.url);
+
+ if (response.status < 400) {
+
+ if (request.dataType === 'json' || request.headers.accept === 'application/json') {
+ return response.json();
+ } else if (request.dataType === 'text' || (response.headers.get('Content-Type') || '').toLowerCase().indexOf('text/') === 0) {
+ return response.text();
+ } else {
+ return response;
+ }
+ } else {
+ return Promise.reject(response);
+ }
+
+ }, function (err) {
+
+ console.log('request failed to url: ' + request.url);
+ throw err;
+ });
}
return {
getFetchPromise: getFetchPromise,
ajax: ajax
- }
+ };
});
\ No newline at end of file
diff --git a/src/bower_components/emby-webcomponents/filedownloader.js b/src/bower_components/emby-webcomponents/filedownloader.js
index ea7a1ff99f..ebd004da68 100644
--- a/src/bower_components/emby-webcomponents/filedownloader.js
+++ b/src/bower_components/emby-webcomponents/filedownloader.js
@@ -1,10 +1,12 @@
-define(["multi-download"], function(multiDownload) {
- "use strict";
+define(['multi-download'], function (multiDownload) {
+ 'use strict';
+
return {
- download: function(items) {
- multiDownload(items.map(function(item) {
- return item.url
- }))
+ download: function (items) {
+
+ multiDownload(items.map(function (item) {
+ return item.url;
+ }));
}
- }
+ };
});
\ No newline at end of file
diff --git a/src/bower_components/emby-webcomponents/filesystem.js b/src/bower_components/emby-webcomponents/filesystem.js
index 7f9599cc14..4489d2921f 100644
--- a/src/bower_components/emby-webcomponents/filesystem.js
+++ b/src/bower_components/emby-webcomponents/filesystem.js
@@ -1,11 +1,12 @@
-define([], function() {
- "use strict";
+define([], function () {
+ 'use strict';
+
return {
- fileExists: function(path) {
- return Promise.reject()
+ fileExists: function (path) {
+ return Promise.reject();
},
- directoryExists: function(path) {
- return Promise.reject()
+ directoryExists: function (path) {
+ return Promise.reject();
}
- }
+ };
});
\ No newline at end of file
diff --git a/src/bower_components/emby-webcomponents/filtermenu/filtermenu.js b/src/bower_components/emby-webcomponents/filtermenu/filtermenu.js
index e0fe446ebe..e405cc0943 100644
--- a/src/bower_components/emby-webcomponents/filtermenu/filtermenu.js
+++ b/src/bower_components/emby-webcomponents/filtermenu/filtermenu.js
@@ -1,125 +1,348 @@
-define(["require", "dom", "focusManager", "dialogHelper", "loading", "apphost", "inputManager", "layoutManager", "connectionManager", "appRouter", "globalize", "userSettings", "emby-checkbox", "emby-input", "paper-icon-button-light", "emby-select", "material-icons", "css!./../formdialog", "emby-button", "emby-linkbutton", "flexStyles"], function(require, dom, focusManager, dialogHelper, loading, appHost, inputManager, layoutManager, connectionManager, appRouter, globalize, userSettings) {
- "use strict";
+define(['require', 'dom', 'focusManager', 'dialogHelper', 'loading', 'apphost', 'inputManager', 'layoutManager', 'connectionManager', 'appRouter', 'globalize', 'userSettings', 'emby-checkbox', 'emby-input', 'paper-icon-button-light', 'emby-select', 'material-icons', 'css!./../formdialog', 'emby-button', 'emby-linkbutton', 'flexStyles'], function (require, dom, focusManager, dialogHelper, loading, appHost, inputManager, layoutManager, connectionManager, appRouter, globalize, userSettings) {
+ 'use strict';
function onSubmit(e) {
- return e.preventDefault(), !1
+
+ e.preventDefault();
+ return false;
}
function renderOptions(context, selector, cssClass, items, isCheckedFn) {
+
var elem = context.querySelector(selector);
- items.length ? elem.classList.remove("hide") : elem.classList.add("hide");
- var html = "";
- html += items.map(function(filter) {
- var itemHtml = "",
- checkedHtml = isCheckedFn(filter) ? " checked" : "";
- return itemHtml += "
", itemHtml += ' ', itemHtml += "" + filter.Name + " ", itemHtml += " "
- }).join(""), elem.querySelector(".filterOptions").innerHTML = html
+
+ if (items.length) {
+
+ elem.classList.remove('hide');
+
+ } else {
+ elem.classList.add('hide');
+ }
+
+ var html = '';
+
+ html += items.map(function (filter) {
+
+ var itemHtml = '';
+
+ var checkedHtml = isCheckedFn(filter) ? ' checked' : '';
+ itemHtml += '
';
+ itemHtml += ' ';
+ itemHtml += '' + filter.Name + ' ';
+ itemHtml += ' ';
+
+ return itemHtml;
+
+ }).join('');
+
+ elem.querySelector('.filterOptions').innerHTML = html;
}
function renderDynamicFilters(context, result, options) {
- renderOptions(context, ".genreFilters", "chkGenreFilter", result.Genres, function(i) {
- var delimeter = -1 === (options.settings.GenreIds || "").indexOf("|") ? "," : "|";
- return -1 !== (delimeter + (options.settings.GenreIds || "") + delimeter).indexOf(delimeter + i.Id + delimeter)
- })
+
+ // If there's a huge number of these they will be really show to render
+ //if (result.Tags) {
+ // result.Tags.length = Math.min(result.Tags.length, 50);
+ //}
+
+ renderOptions(context, '.genreFilters', 'chkGenreFilter', result.Genres, function (i) {
+
+ // Switching from | to ,
+ var delimeter = (options.settings.GenreIds || '').indexOf('|') === -1 ? ',' : '|';
+ return (delimeter + (options.settings.GenreIds || '') + delimeter).indexOf(delimeter + i.Id + delimeter) !== -1;
+ });
+
+ //renderOptions(context, '.officialRatingFilters', 'chkOfficialRatingFilter', result.OfficialRatings, function (i) {
+ // var delimeter = '|';
+ // return (delimeter + (query.OfficialRatings || '') + delimeter).indexOf(delimeter + i + delimeter) != -1;
+ //});
+
+ //renderOptions(context, '.tagFilters', 'chkTagFilter', result.Tags, function (i) {
+ // var delimeter = '|';
+ // return (delimeter + (query.Tags || '') + delimeter).indexOf(delimeter + i + delimeter) != -1;
+ //});
+
+ //renderOptions(context, '.yearFilters', 'chkYearFilter', result.Years, function (i) {
+
+ // var delimeter = ',';
+ // return (delimeter + (query.Years || '') + delimeter).indexOf(delimeter + i + delimeter) != -1;
+ //});
}
function loadDynamicFilters(context, options) {
- var apiClient = connectionManager.getApiClient(options.serverId),
- filterMenuOptions = Object.assign(options.filterMenuOptions, {
- UserId: apiClient.getCurrentUserId(),
- ParentId: options.parentId,
- IncludeItemTypes: options.itemTypes.join(",")
- });
- apiClient.getFilters(filterMenuOptions).then(function(result) {
- renderDynamicFilters(context, result, options)
- }, function() {})
+
+ var apiClient = connectionManager.getApiClient(options.serverId);
+
+ var filterMenuOptions = Object.assign(options.filterMenuOptions, {
+
+ UserId: apiClient.getCurrentUserId(),
+ ParentId: options.parentId,
+ IncludeItemTypes: options.itemTypes.join(',')
+ });
+
+ apiClient.getFilters(filterMenuOptions).then(function (result) {
+
+ renderDynamicFilters(context, result, options);
+ }, function () {
+
+ // older server
+ });
}
function initEditor(context, settings) {
- context.querySelector("form").addEventListener("submit", onSubmit);
- var i, length, elems = context.querySelectorAll(".simpleFilter");
- for (i = 0, length = elems.length; i < length; i++) "INPUT" === elems[i].tagName ? elems[i].checked = settings[elems[i].getAttribute("data-settingname")] || !1 : elems[i].querySelector("input").checked = settings[elems[i].getAttribute("data-settingname")] || !1;
- var videoTypes = settings.VideoTypes ? settings.VideoTypes.split(",") : [];
- for (elems = context.querySelectorAll(".chkVideoTypeFilter"), i = 0, length = elems.length; i < length; i++) elems[i].checked = -1 !== videoTypes.indexOf(elems[i].getAttribute("data-filter"));
- var seriesStatuses = settings.SeriesStatus ? settings.SeriesStatus.split(",") : [];
- for (elems = context.querySelectorAll(".chkSeriesStatus"), i = 0, length = elems.length; i < length; i++) elems[i].checked = -1 !== seriesStatuses.indexOf(elems[i].getAttribute("data-filter"));
- context.querySelector(".basicFilterSection .viewSetting:not(.hide)") ? context.querySelector(".basicFilterSection").classList.remove("hide") : context.querySelector(".basicFilterSection").classList.add("hide"), context.querySelector(".featureSection .viewSetting:not(.hide)") ? context.querySelector(".featureSection").classList.remove("hide") : context.querySelector(".featureSection").classList.add("hide")
+
+ context.querySelector('form').addEventListener('submit', onSubmit);
+
+ var elems = context.querySelectorAll('.simpleFilter');
+ var i, length;
+
+ for (i = 0, length = elems.length; i < length; i++) {
+
+ if (elems[i].tagName === 'INPUT') {
+ elems[i].checked = settings[elems[i].getAttribute('data-settingname')] || false;
+ } else {
+ elems[i].querySelector('input').checked = settings[elems[i].getAttribute('data-settingname')] || false;
+ }
+ }
+
+ var videoTypes = settings.VideoTypes ? settings.VideoTypes.split(',') : [];
+ elems = context.querySelectorAll('.chkVideoTypeFilter');
+
+ for (i = 0, length = elems.length; i < length; i++) {
+
+ elems[i].checked = videoTypes.indexOf(elems[i].getAttribute('data-filter')) !== -1;
+ }
+
+ var seriesStatuses = settings.SeriesStatus ? settings.SeriesStatus.split(',') : [];
+ elems = context.querySelectorAll('.chkSeriesStatus');
+
+ for (i = 0, length = elems.length; i < length; i++) {
+
+ elems[i].checked = seriesStatuses.indexOf(elems[i].getAttribute('data-filter')) !== -1;
+ }
+
+ if (context.querySelector('.basicFilterSection .viewSetting:not(.hide)')) {
+ context.querySelector('.basicFilterSection').classList.remove('hide');
+ } else {
+ context.querySelector('.basicFilterSection').classList.add('hide');
+ }
+
+ if (context.querySelector('.featureSection .viewSetting:not(.hide)')) {
+ context.querySelector('.featureSection').classList.remove('hide');
+ } else {
+ context.querySelector('.featureSection').classList.add('hide');
+ }
}
function saveValues(context, settings, settingsKey) {
- var i, length, elems = context.querySelectorAll(".simpleFilter");
- for (i = 0, length = elems.length; i < length; i++) "INPUT" === elems[i].tagName ? setBasicFilter(context, settingsKey + "-filter-" + elems[i].getAttribute("data-settingname"), elems[i]) : setBasicFilter(context, settingsKey + "-filter-" + elems[i].getAttribute("data-settingname"), elems[i].querySelector("input"));
+
+ var elems = context.querySelectorAll('.simpleFilter');
+ var i, length;
+ for (i = 0, length = elems.length; i < length; i++) {
+
+ if (elems[i].tagName === 'INPUT') {
+ setBasicFilter(context, settingsKey + '-filter-' + elems[i].getAttribute('data-settingname'), elems[i]);
+ } else {
+ setBasicFilter(context, settingsKey + '-filter-' + elems[i].getAttribute('data-settingname'), elems[i].querySelector('input'));
+ }
+ }
+
+ // Video type
var videoTypes = [];
- for (elems = context.querySelectorAll(".chkVideoTypeFilter"), i = 0, length = elems.length; i < length; i++) elems[i].checked && videoTypes.push(elems[i].getAttribute("data-filter"));
- userSettings.setFilter(settingsKey + "-filter-VideoTypes", videoTypes.join(","));
+ elems = context.querySelectorAll('.chkVideoTypeFilter');
+
+ for (i = 0, length = elems.length; i < length; i++) {
+
+ if (elems[i].checked) {
+ videoTypes.push(elems[i].getAttribute('data-filter'));
+ }
+ }
+ userSettings.setFilter(settingsKey + '-filter-VideoTypes', videoTypes.join(','));
+
+ // Series status
var seriesStatuses = [];
- for (elems = context.querySelectorAll(".chkSeriesStatus"), i = 0, length = elems.length; i < length; i++) elems[i].checked && seriesStatuses.push(elems[i].getAttribute("data-filter"));
+ elems = context.querySelectorAll('.chkSeriesStatus');
+
+ for (i = 0, length = elems.length; i < length; i++) {
+
+ if (elems[i].checked) {
+ seriesStatuses.push(elems[i].getAttribute('data-filter'));
+ }
+ }
+
+ // Genres
var genres = [];
- for (elems = context.querySelectorAll(".chkGenreFilter"), i = 0, length = elems.length; i < length; i++) elems[i].checked && genres.push(elems[i].getAttribute("data-filter"));
- userSettings.setFilter(settingsKey + "-filter-GenreIds", genres.join(","))
+ elems = context.querySelectorAll('.chkGenreFilter');
+
+ for (i = 0, length = elems.length; i < length; i++) {
+
+ if (elems[i].checked) {
+ genres.push(elems[i].getAttribute('data-filter'));
+ }
+ }
+ userSettings.setFilter(settingsKey + '-filter-GenreIds', genres.join(','));
}
function setBasicFilter(context, key, elem) {
+
var value = elem.checked;
- value = value || null, userSettings.setFilter(key, value)
+ value = value ? value : null;
+ userSettings.setFilter(key, value);
}
function centerFocus(elem, horiz, on) {
- require(["scrollHelper"], function(scrollHelper) {
- var fn = on ? "on" : "off";
- scrollHelper.centerFocus[fn](elem, horiz)
- })
+ require(['scrollHelper'], function (scrollHelper) {
+ var fn = on ? 'on' : 'off';
+ scrollHelper.centerFocus[fn](elem, horiz);
+ });
}
function moveCheckboxFocus(elem, offset) {
- for (var parent = dom.parentWithClass(elem, "checkboxList-verticalwrap"), elems = focusManager.getFocusableElements(parent), index = -1, i = 0, length = elems.length; i < length; i++)
+
+ var parent = dom.parentWithClass(elem, 'checkboxList-verticalwrap');
+ var elems = focusManager.getFocusableElements(parent);
+
+ var index = -1;
+ for (var i = 0, length = elems.length; i < length; i++) {
if (elems[i] === elem) {
index = i;
- break
- } index += offset, index = Math.min(elems.length - 1, index), index = Math.max(0, index);
+ break;
+ }
+ }
+
+ index += offset;
+
+ index = Math.min(elems.length - 1, index);
+ index = Math.max(0, index);
+
var newElem = elems[index];
- newElem && focusManager.focus(newElem)
+ if (newElem) {
+ focusManager.focus(newElem);
+ }
}
function onInputCommand(e) {
switch (e.detail.command) {
- case "left":
- moveCheckboxFocus(e.target, -1), e.preventDefault();
+
+ case 'left':
+ moveCheckboxFocus(e.target, -1);
+ e.preventDefault();
+ break;
+ case 'right':
+ moveCheckboxFocus(e.target, 1);
+ e.preventDefault();
+ break;
+ default:
break;
- case "right":
- moveCheckboxFocus(e.target, 1), e.preventDefault()
}
}
- function FilterMenu() {}
+ function FilterMenu() {
+
+ }
function bindCheckboxInput(context, on) {
- for (var elems = context.querySelectorAll(".checkboxList-verticalwrap"), i = 0, length = elems.length; i < length; i++) on ? inputManager.on(elems[i], onInputCommand) : inputManager.off(elems[i], onInputCommand)
+
+ var elems = context.querySelectorAll('.checkboxList-verticalwrap');
+ for (var i = 0, length = elems.length; i < length; i++) {
+ if (on) {
+ inputManager.on(elems[i], onInputCommand);
+ } else {
+ inputManager.off(elems[i], onInputCommand);
+ }
+ }
}
- return FilterMenu.prototype.show = function(options) {
- return new Promise(function(resolve, reject) {
- require(["text!./filtermenu.template.html"], function(template) {
+
+ FilterMenu.prototype.show = function (options) {
+
+ return new Promise(function (resolve, reject) {
+
+ require(['text!./filtermenu.template.html'], function (template) {
+
var dialogOptions = {
- removeOnClose: !0,
- scrollY: !1
+ removeOnClose: true,
+ scrollY: false
};
- layoutManager.tv ? dialogOptions.size = "fullscreen" : dialogOptions.size = "small";
+
+ if (layoutManager.tv) {
+ dialogOptions.size = 'fullscreen';
+ } else {
+ dialogOptions.size = 'small';
+ }
+
var dlg = dialogHelper.createDialog(dialogOptions);
- dlg.classList.add("formDialog");
- var html = "";
- html += '", html += template, dlg.innerHTML = globalize.translateDocument(html, "sharedcomponents");
- for (var settingElements = dlg.querySelectorAll(".viewSetting"), i = 0, length = settingElements.length; i < length; i++) - 1 === options.visibleSettings.indexOf(settingElements[i].getAttribute("data-settingname")) ? settingElements[i].classList.add("hide") : settingElements[i].classList.remove("hide");
- initEditor(dlg, options.settings), loadDynamicFilters(dlg, options), bindCheckboxInput(dlg, !0), dlg.querySelector(".btnCancel").addEventListener("click", function() {
- dialogHelper.close(dlg)
- }), layoutManager.tv && centerFocus(dlg.querySelector(".formDialogContent"), !1, !0);
+
+ dlg.classList.add('formDialog');
+
+ var html = '';
+
+ html += '';
+
+ html += template;
+
+ dlg.innerHTML = globalize.translateDocument(html, 'sharedcomponents');
+
+ var settingElements = dlg.querySelectorAll('.viewSetting');
+ for (var i = 0, length = settingElements.length; i < length; i++) {
+ if (options.visibleSettings.indexOf(settingElements[i].getAttribute('data-settingname')) === -1) {
+ settingElements[i].classList.add('hide');
+ } else {
+ settingElements[i].classList.remove('hide');
+ }
+ }
+
+ initEditor(dlg, options.settings);
+ loadDynamicFilters(dlg, options);
+
+ bindCheckboxInput(dlg, true);
+
+ dlg.querySelector('.btnCancel').addEventListener('click', function () {
+
+ dialogHelper.close(dlg);
+ });
+
+ if (layoutManager.tv) {
+ centerFocus(dlg.querySelector('.formDialogContent'), false, true);
+ }
+
var submitted;
- dlg.querySelector("form").addEventListener("change", function() {
- submitted = !0
- }, !0), dialogHelper.open(dlg).then(function() {
- if (bindCheckboxInput(dlg, !1), layoutManager.tv && centerFocus(dlg.querySelector(".formDialogContent"), !1, !1), submitted) return saveValues(dlg, options.settings, options.settingsKey), void resolve();
- reject()
- })
- })
- })
- }, FilterMenu
+
+ dlg.querySelector('form').addEventListener('change', function () {
+
+ submitted = true;
+ //if (options.onChange) {
+ // saveValues(dlg, options.settings, options.settingsKey);
+ // options.onChange();
+ //}
+
+ }, true);
+
+ dialogHelper.open(dlg).then(function () {
+
+ bindCheckboxInput(dlg, false);
+
+ if (layoutManager.tv) {
+ centerFocus(dlg.querySelector('.formDialogContent'), false, false);
+ }
+
+ if (submitted) {
+
+ //if (!options.onChange) {
+ saveValues(dlg, options.settings, options.settingsKey);
+ resolve();
+ //}
+ return;
+ }
+
+ reject();
+ });
+ });
+ });
+ };
+
+ return FilterMenu;
});
\ No newline at end of file
diff --git a/src/bower_components/emby-webcomponents/flexstyles.css b/src/bower_components/emby-webcomponents/flexstyles.css
index b801609a6f..b35e25d57b 100644
--- a/src/bower_components/emby-webcomponents/flexstyles.css
+++ b/src/bower_components/emby-webcomponents/flexstyles.css
@@ -1,70 +1,47 @@
.flex {
- display: -webkit-box;
- display: -webkit-flex;
- display: flex
+ display: flex;
}
.inline-flex {
- display: -webkit-inline-box;
- display: -webkit-inline-flex;
- display: inline-flex
+ display: inline-flex;
}
.flex-direction-column {
- -webkit-box-orient: vertical;
- -webkit-box-direction: normal;
- -webkit-flex-direction: column;
- flex-direction: column
+ flex-direction: column;
}
.flex-direction-row {
- -webkit-box-orient: horizontal;
- -webkit-box-direction: normal;
- -webkit-flex-direction: row;
- flex-direction: row
+ flex-direction: row;
}
.flex-grow {
- -webkit-box-flex: 1;
- -webkit-flex-grow: 1;
- flex-grow: 1
+ flex-grow: 1;
}
.flex-shrink-zero {
- -webkit-flex-shrink: 0;
- flex-shrink: 0
+ flex-shrink: 0;
}
.align-items-center {
- -webkit-box-align: center;
- -webkit-align-items: center;
- align-items: center
+ align-items: center;
}
.align-items-flex-start {
- -webkit-box-align: start;
- -webkit-align-items: flex-start;
- align-items: flex-start
+ align-items: flex-start;
}
.justify-content-center {
- -webkit-box-pack: center;
- -webkit-justify-content: center;
- justify-content: center
+ justify-content: center;
}
.justify-content-flex-end {
- -webkit-box-pack: end;
- -webkit-justify-content: flex-end;
- justify-content: flex-end
+ justify-content: flex-end;
}
.flex-wrap-wrap {
- -webkit-flex-wrap: wrap;
- flex-wrap: wrap
+ flex-wrap: wrap;
}
.align-self-flex-end {
- -webkit-align-self: flex-end;
- align-self: flex-end
+ align-self: flex-end;
}
\ No newline at end of file
diff --git a/src/bower_components/emby-webcomponents/flvjs/flv.min.js b/src/bower_components/emby-webcomponents/flvjs/flv.min.js
index bc71e64626..4a3efed93f 100644
--- a/src/bower_components/emby-webcomponents/flvjs/flv.min.js
+++ b/src/bower_components/emby-webcomponents/flvjs/flv.min.js
@@ -1,6277 +1,7 @@
-! function(e) {
- if ("object" == typeof exports && "undefined" != typeof module) module.exports = e();
- else if ("function" == typeof define && define.amd) define([], e);
- else {
- var t;
- t = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof self ? self : this, t.flvjs = e()
- }
-}(function() {
- var e;
- return function e(t, n, i) {
- function r(a, o) {
- if (!n[a]) {
- if (!t[a]) {
- var u = "function" == typeof require && require;
- if (!o && u) return u(a, !0);
- if (s) return s(a, !0);
- var l = new Error("Cannot find module '" + a + "'");
- throw l.code = "MODULE_NOT_FOUND", l
- }
- var d = n[a] = {
- exports: {}
- };
- t[a][0].call(d.exports, function(e) {
- var n = t[a][1][e];
- return r(n || e)
- }, d, d.exports, e, t, n, i)
- }
- return n[a].exports
- }
- for (var s = "function" == typeof require && require, a = 0; a < i.length; a++) r(i[a]);
- return r
- }({
- 1: [function(t, n, i) {
- (function(r, s) {
- ! function(t, r) {
- "object" == typeof i && void 0 !== n ? n.exports = r() : "function" == typeof e && e.amd ? e(r) : t.ES6Promise = r()
- }(this, function() {
- "use strict";
-
- function e(e) {
- return "function" == typeof e || "object" == typeof e && null !== e
- }
-
- function n(e) {
- return "function" == typeof e
- }
-
- function i(e) {
- K = e
- }
-
- function a(e) {
- q = e
- }
-
- function o() {
- return void 0 !== H ? function() {
- H(l)
- } : u()
- }
-
- function u() {
- var e = setTimeout;
- return function() {
- return e(l, 1)
- }
- }
-
- function l() {
- for (var e = 0; e < z; e += 2) {
- (0, J[e])(J[e + 1]), J[e] = void 0, J[e + 1] = void 0
- }
- z = 0
- }
-
- function d(e, t) {
- var n = arguments,
- i = this,
- r = new this.constructor(f);
- void 0 === r[ee] && I(r);
- var s = i._state;
- return s ? function() {
- var e = n[s - 1];
- q(function() {
- return O(s, r, e, i._result)
- })
- }() : L(i, r, e, t), r
- }
-
- function h(e) {
- var t = this;
- if (e && "object" == typeof e && e.constructor === t) return e;
- var n = new t(f);
- return E(n, e), n
- }
-
- function f() {}
-
- function c() {
- return new TypeError("You cannot resolve a promise with itself")
- }
-
- function _() {
- return new TypeError("A promises callback cannot return that same promise.")
- }
-
- function m(e) {
- try {
- return e.then
- } catch (e) {
- return re.error = e, re
- }
- }
-
- function p(e, t, n, i) {
- try {
- e.call(t, n, i)
- } catch (e) {
- return e
- }
- }
-
- function v(e, t, n) {
- q(function(e) {
- var i = !1,
- r = p(n, t, function(n) {
- i || (i = !0, t !== n ? E(e, n) : S(e, n))
- }, function(t) {
- i || (i = !0, k(e, t))
- }, "Settle: " + (e._label || " unknown promise"));
- !i && r && (i = !0, k(e, r))
- }, e)
- }
-
- function g(e, t) {
- t._state === ne ? S(e, t._result) : t._state === ie ? k(e, t._result) : L(t, void 0, function(t) {
- return E(e, t)
- }, function(t) {
- return k(e, t)
- })
- }
-
- function y(e, t, i) {
- t.constructor === e.constructor && i === d && t.constructor.resolve === h ? g(e, t) : i === re ? (k(e, re.error), re.error = null) : void 0 === i ? S(e, t) : n(i) ? v(e, t, i) : S(e, t)
- }
-
- function E(t, n) {
- t === n ? k(t, c()) : e(n) ? y(t, n, m(n)) : S(t, n)
- }
-
- function b(e) {
- e._onerror && e._onerror(e._result), w(e)
- }
-
- function S(e, t) {
- e._state === te && (e._result = t, e._state = ne, 0 !== e._subscribers.length && q(w, e))
- }
-
- function k(e, t) {
- e._state === te && (e._state = ie, e._result = t, q(b, e))
- }
-
- function L(e, t, n, i) {
- var r = e._subscribers,
- s = r.length;
- e._onerror = null, r[s] = t, r[s + ne] = n, r[s + ie] = i, 0 === s && e._state && q(w, e)
- }
-
- function w(e) {
- var t = e._subscribers,
- n = e._state;
- if (0 !== t.length) {
- for (var i = void 0, r = void 0, s = e._result, a = 0; a < t.length; a += 3) i = t[a], r = t[a + n], i ? O(n, i, r, s) : r(s);
- e._subscribers.length = 0
- }
- }
-
- function R() {
- this.error = null
- }
-
- function A(e, t) {
- try {
- return e(t)
- } catch (e) {
- return se.error = e, se
- }
- }
-
- function O(e, t, i, r) {
- var s = n(i),
- a = void 0,
- o = void 0,
- u = void 0,
- l = void 0;
- if (s) {
- if (a = A(i, r), a === se ? (l = !0, o = a.error, a.error = null) : u = !0, t === a) return void k(t, _())
- } else a = r, u = !0;
- t._state !== te || (s && u ? E(t, a) : l ? k(t, o) : e === ne ? S(t, a) : e === ie && k(t, a))
- }
-
- function T(e, t) {
- try {
- t(function(t) {
- E(e, t)
- }, function(t) {
- k(e, t)
- })
- } catch (t) {
- k(e, t)
- }
- }
-
- function C() {
- return ae++
- }
-
- function I(e) {
- e[ee] = ae++, e._state = void 0, e._result = void 0, e._subscribers = []
- }
-
- function x(e, t) {
- this._instanceConstructor = e, this.promise = new e(f), this.promise[ee] || I(this.promise), V(t) ? (this._input = t, this.length = t.length, this._remaining = t.length, this._result = new Array(this.length), 0 === this.length ? S(this.promise, this._result) : (this.length = this.length || 0, this._enumerate(), 0 === this._remaining && S(this.promise, this._result))) : k(this.promise, M())
- }
-
- function M() {
- return new Error("Array Methods must be provided an Array")
- }
-
- function D(e) {
- return new x(this, e).promise
- }
-
- function B(e) {
- var t = this;
- return new t(V(e) ? function(n, i) {
- for (var r = e.length, s = 0; s < r; s++) t.resolve(e[s]).then(n, i)
- } : function(e, t) {
- return t(new TypeError("You must pass an array to race."))
- })
- }
-
- function j(e) {
- var t = this,
- n = new t(f);
- return k(n, e), n
- }
-
- function P() {
- throw new TypeError("You must pass a resolver function as the first argument to the promise constructor")
- }
-
- function U() {
- throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.")
- }
-
- function N(e) {
- this[ee] = C(), this._result = this._state = void 0, this._subscribers = [], f !== e && ("function" != typeof e && P(), this instanceof N ? T(this, e) : U())
- }
-
- function F() {
- var e = void 0;
- if (void 0 !== s) e = s;
- else if ("undefined" != typeof self) e = self;
- else try {
- e = Function("return this")()
- } catch (e) {
- throw new Error("polyfill failed because global object is unavailable in this environment")
- }
- var t = e.Promise;
- if (t) {
- var n = null;
- try {
- n = Object.prototype.toString.call(t.resolve())
- } catch (e) {}
- if ("[object Promise]" === n && !t.cast) return
- }
- e.Promise = N
- }
- var G = void 0;
- G = Array.isArray ? Array.isArray : function(e) {
- return "[object Array]" === Object.prototype.toString.call(e)
- };
- var V = G,
- z = 0,
- H = void 0,
- K = void 0,
- q = function(e, t) {
- J[z] = e, J[z + 1] = t, 2 === (z += 2) && (K ? K(l) : $())
- },
- W = "undefined" != typeof window ? window : void 0,
- X = W || {},
- Y = X.MutationObserver || X.WebKitMutationObserver,
- Z = "undefined" == typeof self && void 0 !== r && "[object process]" === {}.toString.call(r),
- Q = "undefined" != typeof Uint8ClampedArray && "undefined" != typeof importScripts && "undefined" != typeof MessageChannel,
- J = new Array(1e3),
- $ = void 0;
- $ = Z ? function() {
- return function() {
- return r.nextTick(l)
- }
- }() : Y ? function() {
- var e = 0,
- t = new Y(l),
- n = document.createTextNode("");
- return t.observe(n, {
- characterData: !0
- }),
- function() {
- n.data = e = ++e % 2
- }
- }() : Q ? function() {
- var e = new MessageChannel;
- return e.port1.onmessage = l,
- function() {
- return e.port2.postMessage(0)
- }
- }() : void 0 === W && "function" == typeof t ? function() {
- try {
- var e = t,
- n = e("vertx");
- return H = n.runOnLoop || n.runOnContext, o()
- } catch (e) {
- return u()
- }
- }() : u();
- var ee = Math.random().toString(36).substring(16),
- te = void 0,
- ne = 1,
- ie = 2,
- re = new R,
- se = new R,
- ae = 0;
- return x.prototype._enumerate = function() {
- for (var e = this.length, t = this._input, n = 0; this._state === te && n < e; n++) this._eachEntry(t[n], n)
- }, x.prototype._eachEntry = function(e, t) {
- var n = this._instanceConstructor,
- i = n.resolve;
- if (i === h) {
- var r = m(e);
- if (r === d && e._state !== te) this._settledAt(e._state, t, e._result);
- else if ("function" != typeof r) this._remaining--, this._result[t] = e;
- else if (n === N) {
- var s = new n(f);
- y(s, e, r), this._willSettleAt(s, t)
- } else this._willSettleAt(new n(function(t) {
- return t(e)
- }), t)
- } else this._willSettleAt(i(e), t)
- }, x.prototype._settledAt = function(e, t, n) {
- var i = this.promise;
- i._state === te && (this._remaining--, e === ie ? k(i, n) : this._result[t] = n), 0 === this._remaining && S(i, this._result)
- }, x.prototype._willSettleAt = function(e, t) {
- var n = this;
- L(e, void 0, function(e) {
- return n._settledAt(ne, t, e)
- }, function(e) {
- return n._settledAt(ie, t, e)
- })
- }, N.all = D, N.race = B, N.resolve = h, N.reject = j, N._setScheduler = i, N._setAsap = a, N._asap = q, N.prototype = {
- constructor: N,
- then: d,
- catch: function(e) {
- return this.then(null, e)
- }
- }, N.polyfill = F, N.Promise = N, N
- })
- }).call(this, t("_process"), "undefined" != typeof global ? global : "undefined" != typeof self ? self : "undefined" != typeof window ? window : {})
- }, {
- _process: 3
- }],
- 2: [function(e, t, n) {
- function i() {
- this._events = this._events || {}, this._maxListeners = this._maxListeners || void 0
- }
-
- function r(e) {
- return "function" == typeof e
- }
-
- function s(e) {
- return "number" == typeof e
- }
-
- function a(e) {
- return "object" == typeof e && null !== e
- }
-
- function o(e) {
- return void 0 === e
- }
- t.exports = i, i.EventEmitter = i, i.prototype._events = void 0, i.prototype._maxListeners = void 0, i.defaultMaxListeners = 10, i.prototype.setMaxListeners = function(e) {
- if (!s(e) || e < 0 || isNaN(e)) throw TypeError("n must be a positive number");
- return this._maxListeners = e, this
- }, i.prototype.emit = function(e) {
- var t, n, i, s, u, l;
- if (this._events || (this._events = {}), "error" === e && (!this._events.error || a(this._events.error) && !this._events.error.length)) {
- if ((t = arguments[1]) instanceof Error) throw t;
- var d = new Error('Uncaught, unspecified "error" event. (' + t + ")");
- throw d.context = t, d
- }
- if (n = this._events[e], o(n)) return !1;
- if (r(n)) switch (arguments.length) {
- case 1:
- n.call(this);
- break;
- case 2:
- n.call(this, arguments[1]);
- break;
- case 3:
- n.call(this, arguments[1], arguments[2]);
- break;
- default:
- s = Array.prototype.slice.call(arguments, 1), n.apply(this, s)
- } else if (a(n))
- for (s = Array.prototype.slice.call(arguments, 1), l = n.slice(), i = l.length, u = 0; u < i; u++) l[u].apply(this, s);
- return !0
- }, i.prototype.addListener = function(e, t) {
- var n;
- if (!r(t)) throw TypeError("listener must be a function");
- return this._events || (this._events = {}), this._events.newListener && this.emit("newListener", e, r(t.listener) ? t.listener : t), this._events[e] ? a(this._events[e]) ? this._events[e].push(t) : this._events[e] = [this._events[e], t] : this._events[e] = t, a(this._events[e]) && !this._events[e].warned && (n = o(this._maxListeners) ? i.defaultMaxListeners : this._maxListeners) && n > 0 && this._events[e].length > n && (this._events[e].warned = !0, console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.", this._events[e].length), "function" == typeof console.trace && console.trace()), this
- }, i.prototype.on = i.prototype.addListener, i.prototype.once = function(e, t) {
- function n() {
- this.removeListener(e, n), i || (i = !0, t.apply(this, arguments))
- }
- if (!r(t)) throw TypeError("listener must be a function");
- var i = !1;
- return n.listener = t, this.on(e, n), this
- }, i.prototype.removeListener = function(e, t) {
- var n, i, s, o;
- if (!r(t)) throw TypeError("listener must be a function");
- if (!this._events || !this._events[e]) return this;
- if (n = this._events[e], s = n.length, i = -1, n === t || r(n.listener) && n.listener === t) delete this._events[e], this._events.removeListener && this.emit("removeListener", e, t);
- else if (a(n)) {
- for (o = s; o-- > 0;)
- if (n[o] === t || n[o].listener && n[o].listener === t) {
- i = o;
- break
- } if (i < 0) return this;
- 1 === n.length ? (n.length = 0, delete this._events[e]) : n.splice(i, 1), this._events.removeListener && this.emit("removeListener", e, t)
- }
- return this
- }, i.prototype.removeAllListeners = function(e) {
- var t, n;
- if (!this._events) return this;
- if (!this._events.removeListener) return 0 === arguments.length ? this._events = {} : this._events[e] && delete this._events[e], this;
- if (0 === arguments.length) {
- for (t in this._events) "removeListener" !== t && this.removeAllListeners(t);
- return this.removeAllListeners("removeListener"), this._events = {}, this
- }
- if (n = this._events[e], r(n)) this.removeListener(e, n);
- else if (n)
- for (; n.length;) this.removeListener(e, n[n.length - 1]);
- return delete this._events[e], this
- }, i.prototype.listeners = function(e) {
- return this._events && this._events[e] ? r(this._events[e]) ? [this._events[e]] : this._events[e].slice() : []
- }, i.prototype.listenerCount = function(e) {
- if (this._events) {
- var t = this._events[e];
- if (r(t)) return 1;
- if (t) return t.length
- }
- return 0
- }, i.listenerCount = function(e, t) {
- return e.listenerCount(t)
- }
- }, {}],
- 3: [function(e, t, n) {
- function i() {
- throw new Error("setTimeout has not been defined")
- }
-
- function r() {
- throw new Error("clearTimeout has not been defined")
- }
-
- function s(e) {
- if (h === setTimeout) return setTimeout(e, 0);
- if ((h === i || !h) && setTimeout) return h = setTimeout, setTimeout(e, 0);
- try {
- return h(e, 0)
- } catch (t) {
- try {
- return h.call(null, e, 0)
- } catch (t) {
- return h.call(this, e, 0)
- }
- }
- }
-
- function a(e) {
- if (f === clearTimeout) return clearTimeout(e);
- if ((f === r || !f) && clearTimeout) return f = clearTimeout, clearTimeout(e);
- try {
- return f(e)
- } catch (t) {
- try {
- return f.call(null, e)
- } catch (t) {
- return f.call(this, e)
- }
- }
- }
-
- function o() {
- p && _ && (p = !1, _.length ? m = _.concat(m) : v = -1, m.length && u())
- }
-
- function u() {
- if (!p) {
- var e = s(o);
- p = !0;
- for (var t = m.length; t;) {
- for (_ = m, m = []; ++v < t;) _ && _[v].run();
- v = -1, t = m.length
- }
- _ = null, p = !1, a(e)
- }
- }
-
- function l(e, t) {
- this.fun = e, this.array = t
- }
-
- function d() {}
- var h, f, c = t.exports = {};
- ! function() {
- try {
- h = "function" == typeof setTimeout ? setTimeout : i
- } catch (e) {
- h = i
- }
- try {
- f = "function" == typeof clearTimeout ? clearTimeout : r
- } catch (e) {
- f = r
- }
- }();
- var _, m = [],
- p = !1,
- v = -1;
- c.nextTick = function(e) {
- var t = new Array(arguments.length - 1);
- if (arguments.length > 1)
- for (var n = 1; n < arguments.length; n++) t[n - 1] = arguments[n];
- m.push(new l(e, t)), 1 !== m.length || p || s(u)
- }, l.prototype.run = function() {
- this.fun.apply(null, this.array)
- }, c.title = "browser", c.browser = !0, c.env = {}, c.argv = [], c.version = "", c.versions = {}, c.on = d, c.addListener = d, c.once = d, c.off = d, c.removeListener = d, c.removeAllListeners = d, c.emit = d, c.prependListener = d, c.prependOnceListener = d, c.listeners = function(e) {
- return []
- }, c.binding = function(e) {
- throw new Error("process.binding is not supported")
- }, c.cwd = function() {
- return "/"
- }, c.chdir = function(e) {
- throw new Error("process.chdir is not supported")
- }, c.umask = function() {
- return 0
- }
- }, {}],
- 4: [function(e, t, n) {
- var i = arguments[3],
- r = arguments[4],
- s = arguments[5],
- a = JSON.stringify;
- t.exports = function(e, t) {
- function n(e) {
- p[e] = !0;
- for (var t in r[e][1]) {
- var i = r[e][1][t];
- p[i] || n(i)
- }
- }
- for (var o, u = Object.keys(s), l = 0, d = u.length; l < d; l++) {
- var h = u[l],
- f = s[h].exports;
- if (f === e || f && f.default === e) {
- o = h;
- break
- }
- }
- if (!o) {
- o = Math.floor(Math.pow(16, 8) * Math.random()).toString(16);
- for (var c = {}, l = 0, d = u.length; l < d; l++) {
- var h = u[l];
- c[h] = h
- }
- r[o] = [Function(["require", "module", "exports"], "(" + e + ")(self)"), c]
- }
- var _ = Math.floor(Math.pow(16, 8) * Math.random()).toString(16),
- m = {};
- m[o] = o, r[_] = [Function(["require"], "var f = require(" + a(o) + ");(f.default ? f.default : f)(self);"), m];
- var p = {};
- n(_);
- var v = "(" + i + ")({" + Object.keys(p).map(function(e) {
- return a(e) + ":[" + r[e][0] + "," + a(r[e][1]) + "]"
- }).join(",") + "},{},[" + a(_) + "])",
- g = window.URL || window.webkitURL || window.mozURL || window.msURL,
- y = new Blob([v], {
- type: "text/javascript"
- });
- if (t && t.bare) return y;
- var E = g.createObjectURL(y),
- b = new Worker(E);
- return b.objectURL = E, b
- }
- }, {}],
- 5: [function(e, t, n) {
- "use strict";
-
- function i() {
- return Object.assign({}, r)
- }
- Object.defineProperty(n, "__esModule", {
- value: !0
- }), n.createDefaultConfig = i;
- var r = n.defaultConfig = {
- enableWorker: !1,
- enableStashBuffer: !0,
- stashInitialSize: void 0,
- isLive: !1,
- lazyLoad: !0,
- lazyLoadMaxDuration: 180,
- lazyLoadRecoverDuration: 30,
- deferLoadAfterSourceOpen: !0,
- autoCleanupMaxBackwardDuration: 180,
- autoCleanupMinBackwardDuration: 120,
- statisticsInfoReportInterval: 600,
- fixAudioTimestampGap: !0,
- accurateSeek: !1,
- seekType: "range",
- seekParamStart: "bstart",
- seekParamEnd: "bend",
- rangeLoadZeroStart: !1,
- customSeekHandler: void 0,
- reuseRedirectedURL: !1
- }
- }, {}],
- 6: [function(e, t, n) {
- "use strict";
-
- function i(e, t) {
- if (!(e instanceof t)) throw new TypeError("Cannot call a class as a function")
- }
- Object.defineProperty(n, "__esModule", {
- value: !0
- });
- var r = function() {
- function e(e, t) {
- for (var n = 0; n < t.length; n++) {
- var i = t[n];
- i.enumerable = i.enumerable || !1, i.configurable = !0, "value" in i && (i.writable = !0), Object.defineProperty(e, i.key, i)
- }
- }
- return function(t, n, i) {
- return n && e(t.prototype, n), i && e(t, i), t
- }
- }(),
- s = e("../io/io-controller.js"),
- a = function(e) {
- return e && e.__esModule ? e : {
- default: e
- }
- }(s),
- o = e("../config.js"),
- u = function() {
- function e() {
- i(this, e)
- }
- return r(e, null, [{
- key: "supportMSEH264Playback",
- value: function() {
- return window.MediaSource && window.MediaSource.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"')
- }
- }, {
- key: "supportNetworkStreamIO",
- value: function() {
- var e = new a.default({}, (0, o.createDefaultConfig)()),
- t = e.loaderType;
- return e.destroy(), "fetch-stream-loader" == t || "xhr-moz-chunked-loader" == t
- }
- }, {
- key: "getNetworkLoaderTypeName",
- value: function() {
- var e = new a.default({}, (0, o.createDefaultConfig)()),
- t = e.loaderType;
- return e.destroy(), t
- }
- }, {
- key: "supportNativeMediaPlayback",
- value: function(t) {
- void 0 == e.videoElement && (e.videoElement = window.document.createElement("video"));
- var n = e.videoElement.canPlayType(t);
- return "probably" === n || "maybe" == n
- }
- }, {
- key: "getFeatureList",
- value: function() {
- var t = {
- mseFlvPlayback: !1,
- mseLiveFlvPlayback: !1,
- networkStreamIO: !1,
- networkLoaderName: "",
- nativeMP4H264Playback: !1,
- nativeWebmVP8Playback: !1,
- nativeWebmVP9Playback: !1
- };
- return t.mseFlvPlayback = e.supportMSEH264Playback(), t.networkStreamIO = e.supportNetworkStreamIO(), t.networkLoaderName = e.getNetworkLoaderTypeName(), t.mseLiveFlvPlayback = t.mseFlvPlayback && t.networkStreamIO, t.nativeMP4H264Playback = e.supportNativeMediaPlayback('video/mp4; codecs="avc1.42001E, mp4a.40.2"'), t.nativeWebmVP8Playback = e.supportNativeMediaPlayback('video/webm; codecs="vp8.0, vorbis"'), t.nativeWebmVP9Playback = e.supportNativeMediaPlayback('video/webm; codecs="vp9"'), t
- }
- }]), e
- }();
- n.default = u
- }, {
- "../config.js": 5,
- "../io/io-controller.js": 23
- }],
- 7: [function(e, t, n) {
- "use strict";
-
- function i(e, t) {
- if (!(e instanceof t)) throw new TypeError("Cannot call a class as a function")
- }
- Object.defineProperty(n, "__esModule", {
- value: !0
- });
- var r = function() {
- function e(e, t) {
- for (var n = 0; n < t.length; n++) {
- var i = t[n];
- i.enumerable = i.enumerable || !1, i.configurable = !0, "value" in i && (i.writable = !0), Object.defineProperty(e, i.key, i)
- }
- }
- return function(t, n, i) {
- return n && e(t.prototype, n), i && e(t, i), t
- }
- }(),
- s = function() {
- function e() {
- i(this, e), this.mimeType = null, this.duration = null, this.hasAudio = null, this.hasVideo = null, this.audioCodec = null, this.videoCodec = null, this.audioDataRate = null, this.videoDataRate = null, this.audioSampleRate = null, this.audioChannelCount = null, this.width = null, this.height = null, this.fps = null, this.profile = null, this.level = null, this.refFrames = null, this.chromaFormat = null, this.sarNum = null, this.sarDen = null, this.metadata = null, this.segments = null, this.segmentCount = null, this.hasKeyframesIndex = null, this.keyframesIndex = null
- }
- return r(e, [{
- key: "isComplete",
- value: function() {
- var e = !1 === this.hasAudio || !0 === this.hasAudio && null != this.audioCodec && null != this.audioSampleRate && null != this.audioChannelCount,
- t = !1 === this.hasVideo || !0 === this.hasVideo && null != this.videoCodec && null != this.width && null != this.height && null != this.fps && null != this.profile && null != this.level && null != this.refFrames && null != this.chromaFormat && null != this.sarNum && null != this.sarDen;
- return null != this.mimeType && null != this.duration && null != this.metadata && null != this.hasKeyframesIndex && e && t
- }
- }, {
- key: "isSeekable",
- value: function() {
- return !0 === this.hasKeyframesIndex
- }
- }, {
- key: "getNearestKeyframe",
- value: function(e) {
- if (null == this.keyframesIndex) return null;
- var t = this.keyframesIndex,
- n = this._search(t.times, e);
- return {
- index: n,
- milliseconds: t.times[n],
- fileposition: t.filepositions[n]
- }
- }
- }, {
- key: "_search",
- value: function(e, t) {
- var n = 0,
- i = e.length - 1,
- r = 0,
- s = 0,
- a = i;
- for (t < e[0] && (n = 0, s = a + 1); s <= a;) {
- if ((r = s + Math.floor((a - s) / 2)) === i || t >= e[r] && t < e[r + 1]) {
- n = r;
- break
- }
- e[r] < t ? s = r + 1 : a = r - 1
- }
- return n
- }
- }]), e
- }();
- n.default = s
- }, {}],
- 8: [function(e, t, n) {
- "use strict";
-
- function i(e, t) {
- if (!(e instanceof t)) throw new TypeError("Cannot call a class as a function")
- }
- Object.defineProperty(n, "__esModule", {
- value: !0
- });
- var r = function() {
- function e(e, t) {
- for (var n = 0; n < t.length; n++) {
- var i = t[n];
- i.enumerable = i.enumerable || !1, i.configurable = !0, "value" in i && (i.writable = !0), Object.defineProperty(e, i.key, i)
- }
- }
- return function(t, n, i) {
- return n && e(t.prototype, n), i && e(t, i), t
- }
- }();
- n.SampleInfo = function e(t, n, r, s, a) {
- i(this, e), this.dts = t, this.pts = n, this.duration = r, this.originalDts = s, this.isSyncPoint = a, this.fileposition = null
- }, n.MediaSegmentInfo = function() {
- function e() {
- i(this, e), this.beginDts = 0, this.endDts = 0, this.beginPts = 0, this.endPts = 0, this.originalBeginDts = 0, this.originalEndDts = 0, this.syncPoints = [], this.firstSample = null, this.lastSample = null
- }
- return r(e, [{
- key: "appendSyncPoint",
- value: function(e) {
- e.isSyncPoint = !0, this.syncPoints.push(e)
- }
- }]), e
- }(), n.IDRSampleList = function() {
- function e() {
- i(this, e), this._list = []
- }
- return r(e, [{
- key: "clear",
- value: function() {
- this._list = []
- }
- }, {
- key: "appendArray",
- value: function(e) {
- var t = this._list;
- 0 !== e.length && (t.length > 0 && e[0].originalDts < t[t.length - 1].originalDts && this.clear(), Array.prototype.push.apply(t, e))
- }
- }, {
- key: "getLastSyncPointBeforeDts",
- value: function(e) {
- if (0 == this._list.length) return null;
- var t = this._list,
- n = 0,
- i = t.length - 1,
- r = 0,
- s = 0,
- a = i;
- for (e < t[0].dts && (n = 0, s = a + 1); s <= a;) {
- if ((r = s + Math.floor((a - s) / 2)) === i || e >= t[r].dts && e < t[r + 1].dts) {
- n = r;
- break
- }
- t[r].dts < e ? s = r + 1 : a = r - 1
- }
- return this._list[n]
- }
- }]), e
- }(), n.MediaSegmentInfoList = function() {
- function e(t) {
- i(this, e), this._type = t, this._list = [], this._lastAppendLocation = -1
- }
- return r(e, [{
- key: "isEmpty",
- value: function() {
- return 0 === this._list.length
- }
- }, {
- key: "clear",
- value: function() {
- this._list = [], this._lastAppendLocation = -1
- }
- }, {
- key: "_searchNearestSegmentBefore",
- value: function(e) {
- var t = this._list;
- if (0 === t.length) return -2;
- var n = t.length - 1,
- i = 0,
- r = 0,
- s = n,
- a = 0;
- if (e < t[0].originalBeginDts) return a = -1;
- for (; r <= s;) {
- if ((i = r + Math.floor((s - r) / 2)) === n || e > t[i].lastSample.originalDts && e < t[i + 1].originalBeginDts) {
- a = i;
- break
- }
- t[i].originalBeginDts < e ? r = i + 1 : s = i - 1
- }
- return a
- }
- }, {
- key: "_searchNearestSegmentAfter",
- value: function(e) {
- return this._searchNearestSegmentBefore(e) + 1
- }
- }, {
- key: "append",
- value: function(e) {
- var t = this._list,
- n = e,
- i = this._lastAppendLocation,
- r = 0; - 1 !== i && i < t.length && n.originalBeginDts >= t[i].lastSample.originalDts && (i === t.length - 1 || i < t.length - 1 && n.originalBeginDts < t[i + 1].originalBeginDts) ? r = i + 1 : t.length > 0 && (r = this._searchNearestSegmentBefore(n.originalBeginDts) + 1), this._lastAppendLocation = r, this._list.splice(r, 0, n)
- }
- }, {
- key: "getLastSegmentBefore",
- value: function(e) {
- var t = this._searchNearestSegmentBefore(e);
- return t >= 0 ? this._list[t] : null
- }
- }, {
- key: "getLastSampleBefore",
- value: function(e) {
- var t = this.getLastSegmentBefore(e);
- return null != t ? t.lastSample : null
- }
- }, {
- key: "getLastSyncPointBefore",
- value: function(e) {
- for (var t = this._searchNearestSegmentBefore(e), n = this._list[t].syncPoints; 0 === n.length && t > 0;) t--, n = this._list[t].syncPoints;
- return n.length > 0 ? n[n.length - 1] : null
- }
- }, {
- key: "type",
- get: function() {
- return this._type
- }
- }, {
- key: "length",
- get: function() {
- return this._list.length
- }
- }]), e
- }()
- }, {}],
- 9: [function(e, t, n) {
- "use strict";
-
- function i(e) {
- return e && e.__esModule ? e : {
- default: e
- }
- }
-
- function r(e, t) {
- if (!(e instanceof t)) throw new TypeError("Cannot call a class as a function")
- }
- Object.defineProperty(n, "__esModule", {
- value: !0
- });
- var s = function() {
- function e(e, t) {
- for (var n = 0; n < t.length; n++) {
- var i = t[n];
- i.enumerable = i.enumerable || !1, i.configurable = !0, "value" in i && (i.writable = !0), Object.defineProperty(e, i.key, i)
- }
- }
- return function(t, n, i) {
- return n && e(t.prototype, n), i && e(t, i), t
- }
- }(),
- a = e("events"),
- o = i(a),
- u = e("../utils/logger.js"),
- l = i(u),
- d = e("../utils/browser.js"),
- h = i(d),
- f = e("./mse-events.js"),
- c = i(f),
- _ = e("./media-segment-info.js"),
- m = e("../utils/exception.js"),
- p = function() {
- function e(t) {
- r(this, e), this.TAG = "MSEController", this._config = t, this._emitter = new o.default, this._config.isLive && void 0 == this._config.autoCleanupSourceBuffer && (this._config.autoCleanupSourceBuffer = !0), this.e = {
- onSourceOpen: this._onSourceOpen.bind(this),
- onSourceEnded: this._onSourceEnded.bind(this),
- onSourceClose: this._onSourceClose.bind(this),
- onSourceBufferError: this._onSourceBufferError.bind(this),
- onSourceBufferUpdateEnd: this._onSourceBufferUpdateEnd.bind(this)
- }, this._mediaSource = null, this._mediaSourceObjectURL = null, this._mediaElement = null, this._isBufferFull = !1, this._hasPendingEos = !1, this._requireSetMediaDuration = !1, this._pendingMediaDuration = 0, this._pendingSourceBufferInit = [], this._mimeTypes = {
- video: null,
- audio: null
- }, this._sourceBuffers = {
- video: null,
- audio: null
- }, this._lastInitSegments = {
- video: null,
- audio: null
- }, this._pendingSegments = {
- video: [],
- audio: []
- }, this._pendingRemoveRanges = {
- video: [],
- audio: []
- }, this._idrList = new _.IDRSampleList
- }
- return s(e, [{
- key: "destroy",
- value: function() {
- (this._mediaElement || this._mediaSource) && this.detachMediaElement(), this.e = null, this._emitter.removeAllListeners(), this._emitter = null
- }
- }, {
- key: "on",
- value: function(e, t) {
- this._emitter.addListener(e, t)
- }
- }, {
- key: "off",
- value: function(e, t) {
- this._emitter.removeListener(e, t)
- }
- }, {
- key: "attachMediaElement",
- value: function(e) {
- if (this._mediaSource) throw new m.IllegalStateException("MediaSource has been attached to an HTMLMediaElement!");
- var t = this._mediaSource = new window.MediaSource;
- t.addEventListener("sourceopen", this.e.onSourceOpen), t.addEventListener("sourceended", this.e.onSourceEnded), t.addEventListener("sourceclose", this.e.onSourceClose), this._mediaElement = e, this._mediaSourceObjectURL = window.URL.createObjectURL(this._mediaSource), e.src = this._mediaSourceObjectURL
- }
- }, {
- key: "detachMediaElement",
- value: function() {
- if (this._mediaSource) {
- var e = this._mediaSource;
- for (var t in this._sourceBuffers) {
- var n = this._pendingSegments[t];
- n.splice(0, n.length), this._pendingSegments[t] = null, this._pendingRemoveRanges[t] = null, this._lastInitSegments[t] = null;
- var i = this._sourceBuffers[t];
- i && ("closed" !== e.readyState && (e.removeSourceBuffer(i), i.removeEventListener("error", this.e.onSourceBufferError), i.removeEventListener("updateend", this.e.onSourceBufferUpdateEnd)), this._mimeTypes[t] = null, this._sourceBuffers[t] = null)
- }
- if ("open" === e.readyState) try {
- e.endOfStream()
- } catch (e) {
- l.default.e(this.TAG, e.message)
- }
- e.removeEventListener("sourceopen", this.e.onSourceOpen), e.removeEventListener("sourceended", this.e.onSourceEnded), e.removeEventListener("sourceclose", this.e.onSourceClose), this._pendingSourceBufferInit = [], this._isBufferFull = !1, this._idrList.clear(), this._mediaSource = null
- }
- this._mediaElement && (this._mediaElement.src = "", this._mediaElement.removeAttribute("src"), this._mediaElement = null), this._mediaSourceObjectURL && (window.URL.revokeObjectURL(this._mediaSourceObjectURL), this._mediaSourceObjectURL = null)
- }
- }, {
- key: "appendInitSegment",
- value: function(e, t) {
- if (!this._mediaSource || "open" !== this._mediaSource.readyState) return this._pendingSourceBufferInit.push(e), void this._pendingSegments[e.type].push(e);
- var n = e,
- i = "" + n.container;
- n.codec && n.codec.length > 0 && (i += ";codecs=" + n.codec);
- var r = !1;
- if (l.default.v(this.TAG, "Received Initialization Segment, mimeType: " + i), this._lastInitSegments[n.type] = n, i !== this._mimeTypes[n.type]) {
- if (this._mimeTypes[n.type]) l.default.v(this.TAG, "Notice: " + n.type + " mimeType changed, origin: " + this._mimeTypes[n.type] + ", target: " + i);
- else {
- r = !0;
- try {
- var s = this._sourceBuffers[n.type] = this._mediaSource.addSourceBuffer(i);
- s.addEventListener("error", this.e.onSourceBufferError), s.addEventListener("updateend", this.e.onSourceBufferUpdateEnd)
- } catch (e) {
- return l.default.e(this.TAG, e.message), void this._emitter.emit(c.default.ERROR, {
- code: e.code,
- msg: e.message
- })
- }
- }
- this._mimeTypes[n.type] = i
- }
- t || this._pendingSegments[n.type].push(n), r || this._sourceBuffers[n.type] && !this._sourceBuffers[n.type].updating && this._doAppendSegments(), h.default.safari && "audio/mpeg" === n.container && n.mediaDuration > 0 && (this._requireSetMediaDuration = !0, this._pendingMediaDuration = n.mediaDuration / 1e3, this._updateMediaSourceDuration())
- }
- }, {
- key: "appendMediaSegment",
- value: function(e) {
- var t = e;
- this._pendingSegments[t.type].push(t), this._config.autoCleanupSourceBuffer && this._needCleanupSourceBuffer() && this._doCleanupSourceBuffer();
- var n = this._sourceBuffers[t.type];
- !n || n.updating || this._hasPendingRemoveRanges() || this._doAppendSegments()
- }
- }, {
- key: "seek",
- value: function(e) {
- for (var t in this._sourceBuffers)
- if (this._sourceBuffers[t]) {
- var n = this._sourceBuffers[t];
- if ("open" === this._mediaSource.readyState) try {
- n.abort()
- } catch (e) {
- l.default.e(this.TAG, e.message)
- }
- this._idrList.clear();
- var i = this._pendingSegments[t];
- if (i.splice(0, i.length), "closed" !== this._mediaSource.readyState) {
- for (var r = 0; r < n.buffered.length; r++) {
- var s = n.buffered.start(r),
- a = n.buffered.end(r);
- this._pendingRemoveRanges[t].push({
- start: s,
- end: a
- })
- }
- if (n.updating || this._doRemoveRanges(), h.default.safari) {
- var o = this._lastInitSegments[t];
- o && (this._pendingSegments[t].push(o), n.updating || this._doAppendSegments())
- }
- }
- }
- }
- }, {
- key: "endOfStream",
- value: function() {
- var e = this._mediaSource,
- t = this._sourceBuffers;
- if (!e || "open" !== e.readyState) return void(e && "closed" === e.readyState && this._hasPendingSegments() && (this._hasPendingEos = !0));
- t.video && t.video.updating || t.audio && t.audio.updating ? this._hasPendingEos = !0 : (this._hasPendingEos = !1, e.endOfStream())
- }
- }, {
- key: "getNearestKeyframe",
- value: function(e) {
- return this._idrList.getLastSyncPointBeforeDts(e)
- }
- }, {
- key: "_needCleanupSourceBuffer",
- value: function() {
- if (!this._config.autoCleanupSourceBuffer) return !1;
- var e = this._mediaElement.currentTime;
- for (var t in this._sourceBuffers) {
- var n = this._sourceBuffers[t];
- if (n) {
- var i = n.buffered;
- if (i.length >= 1 && e - i.start(0) >= this._config.autoCleanupMaxBackwardDuration) return !0
- }
- }
- return !1
- }
- }, {
- key: "_doCleanupSourceBuffer",
- value: function() {
- var e = this._mediaElement.currentTime;
- for (var t in this._sourceBuffers) {
- var n = this._sourceBuffers[t];
- if (n) {
- for (var i = n.buffered, r = !1, s = 0; s < i.length; s++) {
- var a = i.start(s),
- o = i.end(s);
- if (a <= e && e < o + 3) {
- if (e - a >= this._config.autoCleanupMaxBackwardDuration) {
- r = !0;
- var u = e - this._config.autoCleanupMinBackwardDuration;
- this._pendingRemoveRanges[t].push({
- start: a,
- end: u
- })
- }
- } else o < e && (r = !0, this._pendingRemoveRanges[t].push({
- start: a,
- end: o
- }))
- }
- r && !n.updating && this._doRemoveRanges()
- }
- }
- }
- }, {
- key: "_updateMediaSourceDuration",
- value: function() {
- var e = this._sourceBuffers;
- if (0 !== this._mediaElement.readyState && "open" === this._mediaSource.readyState && !(e.video && e.video.updating || e.audio && e.audio.updating)) {
- var t = this._mediaSource.duration,
- n = this._pendingMediaDuration;
- n > 0 && (isNaN(t) || n > t) && (l.default.v(this.TAG, "Update MediaSource duration from " + t + " to " + n), this._mediaSource.duration = n), this._requireSetMediaDuration = !1, this._pendingMediaDuration = 0
- }
- }
- }, {
- key: "_doRemoveRanges",
- value: function() {
- for (var e in this._pendingRemoveRanges)
- if (this._sourceBuffers[e] && !this._sourceBuffers[e].updating)
- for (var t = this._sourceBuffers[e], n = this._pendingRemoveRanges[e]; n.length && !t.updating;) {
- var i = n.shift();
- t.remove(i.start, i.end)
- }
- }
- }, {
- key: "_doAppendSegments",
- value: function() {
- var e = this._pendingSegments;
- for (var t in e)
- if (this._sourceBuffers[t] && !this._sourceBuffers[t].updating && e[t].length > 0) {
- var n = e[t].shift();
- if (n.timestampOffset) {
- var i = this._sourceBuffers[t].timestampOffset,
- r = n.timestampOffset / 1e3,
- s = Math.abs(i - r);
- s > .1 && (l.default.v(this.TAG, "Update MPEG audio timestampOffset from " + i + " to " + r), this._sourceBuffers[t].timestampOffset = r), delete n.timestampOffset
- }
- if (!n.data || 0 === n.data.byteLength) continue;
- try {
- this._sourceBuffers[t].appendBuffer(n.data), this._isBufferFull = !1, "video" === t && n.hasOwnProperty("info") && this._idrList.appendArray(n.info.syncPoints)
- } catch (e) {
- this._pendingSegments[t].unshift(n), 22 === e.code ? (this._isBufferFull || this._emitter.emit(c.default.BUFFER_FULL), this._isBufferFull = !0) : (l.default.e(this.TAG, e.message), this._emitter.emit(c.default.ERROR, {
- code: e.code,
- msg: e.message
- }))
- }
- }
- }
- }, {
- key: "_onSourceOpen",
- value: function() {
- if (l.default.v(this.TAG, "MediaSource onSourceOpen"), this._mediaSource.removeEventListener("sourceopen", this.e.onSourceOpen), this._pendingSourceBufferInit.length > 0)
- for (var e = this._pendingSourceBufferInit; e.length;) {
- var t = e.shift();
- this.appendInitSegment(t, !0)
- }
- this._hasPendingSegments() && this._doAppendSegments(), this._emitter.emit(c.default.SOURCE_OPEN)
- }
- }, {
- key: "_onSourceEnded",
- value: function() {
- l.default.v(this.TAG, "MediaSource onSourceEnded")
- }
- }, {
- key: "_onSourceClose",
- value: function() {
- l.default.v(this.TAG, "MediaSource onSourceClose"), this._mediaSource && null != this.e && (this._mediaSource.removeEventListener("sourceopen", this.e.onSourceOpen), this._mediaSource.removeEventListener("sourceended", this.e.onSourceEnded), this._mediaSource.removeEventListener("sourceclose", this.e.onSourceClose))
- }
- }, {
- key: "_hasPendingSegments",
- value: function() {
- var e = this._pendingSegments;
- return e.video.length > 0 || e.audio.length > 0
- }
- }, {
- key: "_hasPendingRemoveRanges",
- value: function() {
- var e = this._pendingRemoveRanges;
- return e.video.length > 0 || e.audio.length > 0
- }
- }, {
- key: "_onSourceBufferUpdateEnd",
- value: function() {
- this._requireSetMediaDuration ? this._updateMediaSourceDuration() : this._hasPendingRemoveRanges() ? this._doRemoveRanges() : this._hasPendingSegments() ? this._doAppendSegments() : this._hasPendingEos && this.endOfStream(), this._emitter.emit(c.default.UPDATE_END)
- }
- }, {
- key: "_onSourceBufferError",
- value: function(e) {
- l.default.e(this.TAG, "SourceBuffer Error: " + e)
- }
- }]), e
- }();
- n.default = p
- }, {
- "../utils/browser.js": 39,
- "../utils/exception.js": 40,
- "../utils/logger.js": 41,
- "./media-segment-info.js": 8,
- "./mse-events.js": 10,
- events: 2
- }],
- 10: [function(e, t, n) {
- "use strict";
- Object.defineProperty(n, "__esModule", {
- value: !0
- });
- var i = {
- ERROR: "error",
- SOURCE_OPEN: "source_open",
- UPDATE_END: "update_end",
- BUFFER_FULL: "buffer_full"
- };
- n.default = i
- }, {}],
- 11: [function(e, t, n) {
- "use strict";
-
- function i(e) {
- return e && e.__esModule ? e : {
- default: e
- }
- }
-
- function r(e, t) {
- if (!(e instanceof t)) throw new TypeError("Cannot call a class as a function")
- }
- Object.defineProperty(n, "__esModule", {
- value: !0
- });
- var s = function() {
- function e(e, t) {
- for (var n = 0; n < t.length; n++) {
- var i = t[n];
- i.enumerable = i.enumerable || !1, i.configurable = !0, "value" in i && (i.writable = !0), Object.defineProperty(e, i.key, i)
- }
- }
- return function(t, n, i) {
- return n && e(t.prototype, n), i && e(t, i), t
- }
- }(),
- a = e("events"),
- o = i(a),
- u = e("../utils/logger.js"),
- l = i(u),
- d = e("../utils/logging-control.js"),
- h = i(d),
- f = e("./transmuxing-controller.js"),
- c = i(f),
- _ = e("./transmuxing-events.js"),
- m = i(_),
- p = e("./transmuxing-worker.js"),
- v = i(p),
- g = e("./media-info.js"),
- y = i(g),
- E = function() {
- function t(n, i) {
- if (r(this, t), this.TAG = "Transmuxer", this._emitter = new o.default, i.enableWorker && "undefined" != typeof Worker) try {
- var s = e("webworkify");
- this._worker = s(v.default), this._workerDestroying = !1, this._worker.addEventListener("message", this._onWorkerMessage.bind(this)), this._worker.postMessage({
- cmd: "init",
- param: [n, i]
- }), this.e = {
- onLoggingConfigChanged: this._onLoggingConfigChanged.bind(this)
- }, h.default.registerListener(this.e.onLoggingConfigChanged), this._worker.postMessage({
- cmd: "logging_config",
- param: h.default.getConfig()
- })
- } catch (e) {
- l.default.e(this.TAG, "Error while initialize transmuxing worker, fallback to inline transmuxing"), this._worker = null, this._controller = new c.default(n, i)
- } else this._controller = new c.default(n, i);
- if (this._controller) {
- var a = this._controller;
- a.on(m.default.IO_ERROR, this._onIOError.bind(this)), a.on(m.default.DEMUX_ERROR, this._onDemuxError.bind(this)), a.on(m.default.INIT_SEGMENT, this._onInitSegment.bind(this)), a.on(m.default.MEDIA_SEGMENT, this._onMediaSegment.bind(this)), a.on(m.default.LOADING_COMPLETE, this._onLoadingComplete.bind(this)), a.on(m.default.RECOVERED_EARLY_EOF, this._onRecoveredEarlyEof.bind(this)), a.on(m.default.MEDIA_INFO, this._onMediaInfo.bind(this)), a.on(m.default.STATISTICS_INFO, this._onStatisticsInfo.bind(this)), a.on(m.default.RECOMMEND_SEEKPOINT, this._onRecommendSeekpoint.bind(this))
- }
- }
- return s(t, [{
- key: "destroy",
- value: function() {
- this._worker ? this._workerDestroying || (this._workerDestroying = !0, this._worker.postMessage({
- cmd: "destroy"
- }), h.default.removeListener(this.e.onLoggingConfigChanged), this.e = null) : (this._controller.destroy(), this._controller = null), this._emitter.removeAllListeners(), this._emitter = null
- }
- }, {
- key: "on",
- value: function(e, t) {
- this._emitter.addListener(e, t)
- }
- }, {
- key: "off",
- value: function(e, t) {
- this._emitter.removeListener(e, t)
- }
- }, {
- key: "hasWorker",
- value: function() {
- return null != this._worker
- }
- }, {
- key: "open",
- value: function() {
- this._worker ? this._worker.postMessage({
- cmd: "start"
- }) : this._controller.start()
- }
- }, {
- key: "close",
- value: function() {
- this._worker ? this._worker.postMessage({
- cmd: "stop"
- }) : this._controller.stop()
- }
- }, {
- key: "seek",
- value: function(e) {
- this._worker ? this._worker.postMessage({
- cmd: "seek",
- param: e
- }) : this._controller.seek(e)
- }
- }, {
- key: "pause",
- value: function() {
- this._worker ? this._worker.postMessage({
- cmd: "pause"
- }) : this._controller.pause()
- }
- }, {
- key: "resume",
- value: function() {
- this._worker ? this._worker.postMessage({
- cmd: "resume"
- }) : this._controller.resume()
- }
- }, {
- key: "_onInitSegment",
- value: function(e, t) {
- var n = this;
- Promise.resolve().then(function() {
- n._emitter.emit(m.default.INIT_SEGMENT, e, t)
- })
- }
- }, {
- key: "_onMediaSegment",
- value: function(e, t) {
- var n = this;
- Promise.resolve().then(function() {
- n._emitter.emit(m.default.MEDIA_SEGMENT, e, t)
- })
- }
- }, {
- key: "_onLoadingComplete",
- value: function() {
- var e = this;
- Promise.resolve().then(function() {
- e._emitter.emit(m.default.LOADING_COMPLETE)
- })
- }
- }, {
- key: "_onRecoveredEarlyEof",
- value: function() {
- var e = this;
- Promise.resolve().then(function() {
- e._emitter.emit(m.default.RECOVERED_EARLY_EOF)
- })
- }
- }, {
- key: "_onMediaInfo",
- value: function(e) {
- var t = this;
- Promise.resolve().then(function() {
- t._emitter.emit(m.default.MEDIA_INFO, e)
- })
- }
- }, {
- key: "_onStatisticsInfo",
- value: function(e) {
- var t = this;
- Promise.resolve().then(function() {
- t._emitter.emit(m.default.STATISTICS_INFO, e)
- })
- }
- }, {
- key: "_onIOError",
- value: function(e, t) {
- var n = this;
- Promise.resolve().then(function() {
- n._emitter.emit(m.default.IO_ERROR, e, t)
- })
- }
- }, {
- key: "_onDemuxError",
- value: function(e, t) {
- var n = this;
- Promise.resolve().then(function() {
- n._emitter.emit(m.default.DEMUX_ERROR, e, t)
- })
- }
- }, {
- key: "_onRecommendSeekpoint",
- value: function(e) {
- var t = this;
- Promise.resolve().then(function() {
- t._emitter.emit(m.default.RECOMMEND_SEEKPOINT, e)
- })
- }
- }, {
- key: "_onLoggingConfigChanged",
- value: function(e) {
- this._worker && this._worker.postMessage({
- cmd: "logging_config",
- param: e
- })
- }
- }, {
- key: "_onWorkerMessage",
- value: function(e) {
- var t = e.data,
- n = t.data;
- if ("destroyed" === t.msg || this._workerDestroying) return this._workerDestroying = !1, this._worker.terminate(), void(this._worker = null);
- switch (t.msg) {
- case m.default.INIT_SEGMENT:
- case m.default.MEDIA_SEGMENT:
- this._emitter.emit(t.msg, n.type, n.data);
- break;
- case m.default.LOADING_COMPLETE:
- case m.default.RECOVERED_EARLY_EOF:
- this._emitter.emit(t.msg);
- break;
- case m.default.MEDIA_INFO:
- Object.setPrototypeOf(n, y.default.prototype), this._emitter.emit(t.msg, n);
- break;
- case m.default.STATISTICS_INFO:
- this._emitter.emit(t.msg, n);
- break;
- case m.default.IO_ERROR:
- case m.default.DEMUX_ERROR:
- this._emitter.emit(t.msg, n.type, n.info);
- break;
- case m.default.RECOMMEND_SEEKPOINT:
- this._emitter.emit(t.msg, n);
- break;
- case "logcat_callback":
- l.default.emitter.emit("log", n.type, n.logcat)
- }
- }
- }]), t
- }();
- n.default = E
- }, {
- "../utils/logger.js": 41,
- "../utils/logging-control.js": 42,
- "./media-info.js": 7,
- "./transmuxing-controller.js": 12,
- "./transmuxing-events.js": 13,
- "./transmuxing-worker.js": 14,
- events: 2,
- webworkify: 4
- }],
- 12: [function(e, t, n) {
- "use strict";
-
- function i(e) {
- return e && e.__esModule ? e : {
- default: e
- }
- }
-
- function r(e, t) {
- if (!(e instanceof t)) throw new TypeError("Cannot call a class as a function")
- }
- Object.defineProperty(n, "__esModule", {
- value: !0
- });
- var s = function() {
- function e(e, t) {
- for (var n = 0; n < t.length; n++) {
- var i = t[n];
- i.enumerable = i.enumerable || !1, i.configurable = !0, "value" in i && (i.writable = !0), Object.defineProperty(e, i.key, i)
- }
- }
- return function(t, n, i) {
- return n && e(t.prototype, n), i && e(t, i), t
- }
- }(),
- a = e("events"),
- o = i(a),
- u = e("../utils/logger.js"),
- l = i(u),
- d = e("../utils/browser.js"),
- h = i(d),
- f = e("./media-info.js"),
- c = i(f),
- _ = e("../demux/flv-demuxer.js"),
- m = i(_),
- p = e("../remux/mp4-remuxer.js"),
- v = i(p),
- g = e("../demux/demux-errors.js"),
- y = i(g),
- E = e("../io/io-controller.js"),
- b = i(E),
- S = e("./transmuxing-events.js"),
- k = i(S),
- L = (e("../io/loader.js"), function() {
- function e(t, n) {
- r(this, e), this.TAG = "TransmuxingController", this._emitter = new o.default, this._config = n, t.segments || (t.segments = [{
- duration: t.duration,
- filesize: t.filesize,
- url: t.url
- }]), "boolean" != typeof t.cors && (t.cors = !0), "boolean" != typeof t.withCredentials && (t.withCredentials = !1), this._mediaDataSource = t, this._currentSegmentIndex = 0;
- var i = 0;
- this._mediaDataSource.segments.forEach(function(e) {
- e.timestampBase = i, i += e.duration, e.cors = t.cors, e.withCredentials = t.withCredentials, n.referrerPolicy && (e.referrerPolicy = n.referrerPolicy)
- }), isNaN(i) || this._mediaDataSource.duration === i || (this._mediaDataSource.duration = i), this._mediaInfo = null, this._demuxer = null, this._remuxer = null, this._ioctl = null, this._pendingSeekTime = null, this._pendingResolveSeekPoint = null, this._statisticsReporter = null
- }
- return s(e, [{
- key: "destroy",
- value: function() {
- this._mediaInfo = null, this._mediaDataSource = null, this._statisticsReporter && this._disableStatisticsReporter(), this._ioctl && (this._ioctl.destroy(), this._ioctl = null), this._demuxer && (this._demuxer.destroy(), this._demuxer = null), this._remuxer && (this._remuxer.destroy(), this._remuxer = null), this._emitter.removeAllListeners(), this._emitter = null
- }
- }, {
- key: "on",
- value: function(e, t) {
- this._emitter.addListener(e, t)
- }
- }, {
- key: "off",
- value: function(e, t) {
- this._emitter.removeListener(e, t)
- }
- }, {
- key: "start",
- value: function() {
- this._loadSegment(0), this._enableStatisticsReporter()
- }
- }, {
- key: "_loadSegment",
- value: function(e, t) {
- this._currentSegmentIndex = e;
- var n = this._mediaDataSource.segments[e],
- i = this._ioctl = new b.default(n, this._config, e);
- i.onError = this._onIOException.bind(this), i.onSeeked = this._onIOSeeked.bind(this), i.onComplete = this._onIOComplete.bind(this), i.onRedirect = this._onIORedirect.bind(this), i.onRecoveredEarlyEof = this._onIORecoveredEarlyEof.bind(this), t ? this._demuxer.bindDataSource(this._ioctl) : i.onDataArrival = this._onInitChunkArrival.bind(this), i.open(t)
- }
- }, {
- key: "stop",
- value: function() {
- this._internalAbort(), this._disableStatisticsReporter()
- }
- }, {
- key: "_internalAbort",
- value: function() {
- this._ioctl && (this._ioctl.destroy(), this._ioctl = null)
- }
- }, {
- key: "pause",
- value: function() {
- this._ioctl && this._ioctl.isWorking() && (this._ioctl.pause(), this._disableStatisticsReporter())
- }
- }, {
- key: "resume",
- value: function() {
- this._ioctl && this._ioctl.isPaused() && (this._ioctl.resume(), this._enableStatisticsReporter())
- }
- }, {
- key: "seek",
- value: function(e) {
- if (null != this._mediaInfo && this._mediaInfo.isSeekable()) {
- var t = this._searchSegmentIndexContains(e);
- if (t === this._currentSegmentIndex) {
- var n = this._mediaInfo.segments[t];
- if (void 0 == n) this._pendingSeekTime = e;
- else {
- var i = n.getNearestKeyframe(e);
- this._remuxer.seek(i.milliseconds), this._ioctl.seek(i.fileposition), this._pendingResolveSeekPoint = i.milliseconds
- }
- } else {
- var r = this._mediaInfo.segments[t];
- if (void 0 == r) this._pendingSeekTime = e, this._internalAbort(), this._remuxer.seek(), this._remuxer.insertDiscontinuity(), this._loadSegment(t);
- else {
- var s = r.getNearestKeyframe(e);
- this._internalAbort(), this._remuxer.seek(e), this._remuxer.insertDiscontinuity(), this._demuxer.resetMediaInfo(), this._demuxer.timestampBase = this._mediaDataSource.segments[t].timestampBase, this._loadSegment(t, s.fileposition), this._pendingResolveSeekPoint = s.milliseconds, this._reportSegmentMediaInfo(t)
- }
- }
- this._enableStatisticsReporter()
- }
- }
- }, {
- key: "_searchSegmentIndexContains",
- value: function(e) {
- for (var t = this._mediaDataSource.segments, n = t.length - 1, i = 0; i < t.length; i++)
- if (e < t[i].timestampBase) {
- n = i - 1;
- break
- } return n
- }
- }, {
- key: "_onInitChunkArrival",
- value: function(e, t) {
- var n = this,
- i = null,
- r = 0;
- if (t > 0) this._demuxer.bindDataSource(this._ioctl), this._demuxer.timestampBase = this._mediaDataSource.segments[this._currentSegmentIndex].timestampBase, r = this._demuxer.parseChunks(e, t);
- else if ((i = m.default.probe(e)).match) {
- this._demuxer = new m.default(i, this._config), this._remuxer || (this._remuxer = new v.default(this._config));
- var s = this._mediaDataSource;
- void 0 == s.duration || isNaN(s.duration) || (this._demuxer.overridedDuration = s.duration), "boolean" == typeof s.hasAudio && (this._demuxer.overridedHasAudio = s.hasAudio), "boolean" == typeof s.hasVideo && (this._demuxer.overridedHasVideo = s.hasVideo), this._demuxer.timestampBase = s.segments[this._currentSegmentIndex].timestampBase, this._demuxer.onError = this._onDemuxException.bind(this), this._demuxer.onMediaInfo = this._onMediaInfo.bind(this), this._remuxer.bindDataSource(this._demuxer.bindDataSource(this._ioctl)), this._remuxer.onInitSegment = this._onRemuxerInitSegmentArrival.bind(this), this._remuxer.onMediaSegment = this._onRemuxerMediaSegmentArrival.bind(this), r = this._demuxer.parseChunks(e, t)
- } else i = null, l.default.e(this.TAG, "Non-FLV, Unsupported media type!"), Promise.resolve().then(function() {
- n._internalAbort()
- }), this._emitter.emit(k.default.DEMUX_ERROR, y.default.FORMAT_UNSUPPORTED, "Non-FLV, Unsupported media type"), r = 0;
- return r
- }
- }, {
- key: "_onMediaInfo",
- value: function(e) {
- var t = this;
- null == this._mediaInfo && (this._mediaInfo = Object.assign({}, e), this._mediaInfo.keyframesIndex = null, this._mediaInfo.segments = [], this._mediaInfo.segmentCount = this._mediaDataSource.segments.length, Object.setPrototypeOf(this._mediaInfo, c.default.prototype));
- var n = Object.assign({}, e);
- Object.setPrototypeOf(n, c.default.prototype), this._mediaInfo.segments[this._currentSegmentIndex] = n, this._reportSegmentMediaInfo(this._currentSegmentIndex), null != this._pendingSeekTime && Promise.resolve().then(function() {
- var e = t._pendingSeekTime;
- t._pendingSeekTime = null, t.seek(e)
- })
- }
- }, {
- key: "_onIOSeeked",
- value: function() {
- this._remuxer.insertDiscontinuity()
- }
- }, {
- key: "_onIOComplete",
- value: function(e) {
- var t = e,
- n = t + 1;
- n < this._mediaDataSource.segments.length ? (this._internalAbort(), this._remuxer.flushStashedSamples(), this._loadSegment(n)) : (this._remuxer.flushStashedSamples(), this._emitter.emit(k.default.LOADING_COMPLETE), this._disableStatisticsReporter())
- }
- }, {
- key: "_onIORedirect",
- value: function(e) {
- var t = this._ioctl.extraData;
- this._mediaDataSource.segments[t].redirectedURL = e
- }
- }, {
- key: "_onIORecoveredEarlyEof",
- value: function() {
- this._emitter.emit(k.default.RECOVERED_EARLY_EOF)
- }
- }, {
- key: "_onIOException",
- value: function(e, t) {
- l.default.e(this.TAG, "IOException: type = " + e + ", code = " + t.code + ", msg = " + t.msg), this._emitter.emit(k.default.IO_ERROR, e, t), this._disableStatisticsReporter()
- }
- }, {
- key: "_onDemuxException",
- value: function(e, t) {
- l.default.e(this.TAG, "DemuxException: type = " + e + ", info = " + t), this._emitter.emit(k.default.DEMUX_ERROR, e, t)
- }
- }, {
- key: "_onRemuxerInitSegmentArrival",
- value: function(e, t) {
- this._emitter.emit(k.default.INIT_SEGMENT, e, t)
- }
- }, {
- key: "_onRemuxerMediaSegmentArrival",
- value: function(e, t) {
- if (null == this._pendingSeekTime && (this._emitter.emit(k.default.MEDIA_SEGMENT, e, t), null != this._pendingResolveSeekPoint && "video" === e)) {
- var n = t.info.syncPoints,
- i = this._pendingResolveSeekPoint;
- this._pendingResolveSeekPoint = null, h.default.safari && n.length > 0 && n[0].originalDts === i && (i = n[0].pts), this._emitter.emit(k.default.RECOMMEND_SEEKPOINT, i)
- }
- }
- }, {
- key: "_enableStatisticsReporter",
- value: function() {
- null == this._statisticsReporter && (this._statisticsReporter = self.setInterval(this._reportStatisticsInfo.bind(this), this._config.statisticsInfoReportInterval))
- }
- }, {
- key: "_disableStatisticsReporter",
- value: function() {
- this._statisticsReporter && (self.clearInterval(this._statisticsReporter), this._statisticsReporter = null)
- }
- }, {
- key: "_reportSegmentMediaInfo",
- value: function(e) {
- var t = this._mediaInfo.segments[e],
- n = Object.assign({}, t);
- n.duration = this._mediaInfo.duration, n.segmentCount = this._mediaInfo.segmentCount, delete n.segments, delete n.keyframesIndex, this._emitter.emit(k.default.MEDIA_INFO, n)
- }
- }, {
- key: "_reportStatisticsInfo",
- value: function() {
- var e = {};
- e.url = this._ioctl.currentURL, e.hasRedirect = this._ioctl.hasRedirect, e.hasRedirect && (e.redirectedURL = this._ioctl.currentRedirectedURL), e.speed = this._ioctl.currentSpeed, e.loaderType = this._ioctl.loaderType, e.currentSegmentIndex = this._currentSegmentIndex, e.totalSegmentCount = this._mediaDataSource.segments.length, this._emitter.emit(k.default.STATISTICS_INFO, e)
- }
- }]), e
- }());
- n.default = L
- }, {
- "../demux/demux-errors.js": 16,
- "../demux/flv-demuxer.js": 18,
- "../io/io-controller.js": 23,
- "../io/loader.js": 24,
- "../remux/mp4-remuxer.js": 38,
- "../utils/browser.js": 39,
- "../utils/logger.js": 41,
- "./media-info.js": 7,
- "./transmuxing-events.js": 13,
- events: 2
- }],
- 13: [function(e, t, n) {
- "use strict";
- Object.defineProperty(n, "__esModule", {
- value: !0
- });
- var i = {
- IO_ERROR: "io_error",
- DEMUX_ERROR: "demux_error",
- INIT_SEGMENT: "init_segment",
- MEDIA_SEGMENT: "media_segment",
- LOADING_COMPLETE: "loading_complete",
- RECOVERED_EARLY_EOF: "recovered_early_eof",
- MEDIA_INFO: "media_info",
- STATISTICS_INFO: "statistics_info",
- RECOMMEND_SEEKPOINT: "recommend_seekpoint"
- };
- n.default = i
- }, {}],
- 14: [function(e, t, n) {
- "use strict";
-
- function i(e) {
- return e && e.__esModule ? e : {
- default: e
- }
- }
- Object.defineProperty(n, "__esModule", {
- value: !0
- });
- var r = e("../utils/logger.js"),
- s = (i(r), e("../utils/logging-control.js")),
- a = i(s),
- o = e("../utils/polyfill.js"),
- u = i(o),
- l = e("./transmuxing-controller.js"),
- d = i(l),
- h = e("./transmuxing-events.js"),
- f = i(h),
- c = function(e) {
- function t(t, n) {
- var i = {
- msg: f.default.INIT_SEGMENT,
- data: {
- type: t,
- data: n
- }
- };
- e.postMessage(i, [n.data])
- }
-
- function n(t, n) {
- var i = {
- msg: f.default.MEDIA_SEGMENT,
- data: {
- type: t,
- data: n
- }
- };
- e.postMessage(i, [n.data])
- }
-
- function i() {
- var t = {
- msg: f.default.LOADING_COMPLETE
- };
- e.postMessage(t)
- }
-
- function r() {
- var t = {
- msg: f.default.RECOVERED_EARLY_EOF
- };
- e.postMessage(t)
- }
-
- function s(t) {
- var n = {
- msg: f.default.MEDIA_INFO,
- data: t
- };
- e.postMessage(n)
- }
-
- function o(t) {
- var n = {
- msg: f.default.STATISTICS_INFO,
- data: t
- };
- e.postMessage(n)
- }
-
- function l(t, n) {
- e.postMessage({
- msg: f.default.IO_ERROR,
- data: {
- type: t,
- info: n
- }
- })
- }
-
- function h(t, n) {
- e.postMessage({
- msg: f.default.DEMUX_ERROR,
- data: {
- type: t,
- info: n
- }
- })
- }
-
- function c(t) {
- e.postMessage({
- msg: f.default.RECOMMEND_SEEKPOINT,
- data: t
- })
- }
-
- function _(t, n) {
- e.postMessage({
- msg: "logcat_callback",
- data: {
- type: t,
- logcat: n
- }
- })
- }
- var m = null,
- p = _.bind(this);
- u.default.install(), e.addEventListener("message", function(u) {
- switch (u.data.cmd) {
- case "init":
- m = new d.default(u.data.param[0], u.data.param[1]), m.on(f.default.IO_ERROR, l.bind(this)), m.on(f.default.DEMUX_ERROR, h.bind(this)), m.on(f.default.INIT_SEGMENT, t.bind(this)), m.on(f.default.MEDIA_SEGMENT, n.bind(this)), m.on(f.default.LOADING_COMPLETE, i.bind(this)), m.on(f.default.RECOVERED_EARLY_EOF, r.bind(this)), m.on(f.default.MEDIA_INFO, s.bind(this)), m.on(f.default.STATISTICS_INFO, o.bind(this)), m.on(f.default.RECOMMEND_SEEKPOINT, c.bind(this));
- break;
- case "destroy":
- m && (m.destroy(), m = null), e.postMessage({
- msg: "destroyed"
- });
- break;
- case "start":
- m.start();
- break;
- case "stop":
- m.stop();
- break;
- case "seek":
- m.seek(u.data.param);
- break;
- case "pause":
- m.pause();
- break;
- case "resume":
- m.resume();
- break;
- case "logging_config":
- var _ = u.data.param;
- a.default.applyConfig(_), !0 === _.enableCallback ? a.default.addLogListener(p) : a.default.removeLogListener(p)
- }
- })
- };
- n.default = c
- }, {
- "../utils/logger.js": 41,
- "../utils/logging-control.js": 42,
- "../utils/polyfill.js": 43,
- "./transmuxing-controller.js": 12,
- "./transmuxing-events.js": 13
- }],
- 15: [function(e, t, n) {
- "use strict";
-
- function i(e) {
- return e && e.__esModule ? e : {
- default: e
- }
- }
-
- function r(e, t) {
- if (!(e instanceof t)) throw new TypeError("Cannot call a class as a function")
- }
- Object.defineProperty(n, "__esModule", {
- value: !0
- });
- var s = function() {
- function e(e, t) {
- for (var n = 0; n < t.length; n++) {
- var i = t[n];
- i.enumerable = i.enumerable || !1, i.configurable = !0, "value" in i && (i.writable = !0), Object.defineProperty(e, i.key, i)
- }
- }
- return function(t, n, i) {
- return n && e(t.prototype, n), i && e(t, i), t
- }
- }(),
- a = e("../utils/logger.js"),
- o = i(a),
- u = e("../utils/utf8-conv.js"),
- l = i(u),
- d = e("../utils/exception.js"),
- h = function() {
- var e = new ArrayBuffer(2);
- return new DataView(e).setInt16(0, 256, !0), 256 === new Int16Array(e)[0]
- }(),
- f = function() {
- function e() {
- r(this, e)
- }
- return s(e, null, [{
- key: "parseScriptData",
- value: function(t, n, i) {
- var r = {};
- try {
- var s = e.parseValue(t, n, i),
- a = e.parseValue(t, n + s.size, i - s.size);
- r[s.data] = a.data
- } catch (e) {
- o.default.e("AMF", e.toString())
- }
- return r
- }
- }, {
- key: "parseObject",
- value: function(t, n, i) {
- if (i < 3) throw new d.IllegalStateException("Data not enough when parse ScriptDataObject");
- var r = e.parseString(t, n, i),
- s = e.parseValue(t, n + r.size, i - r.size),
- a = s.objectEnd;
- return {
- data: {
- name: r.data,
- value: s.data
- },
- size: r.size + s.size,
- objectEnd: a
- }
- }
- }, {
- key: "parseVariable",
- value: function(t, n, i) {
- return e.parseObject(t, n, i)
- }
- }, {
- key: "parseString",
- value: function(e, t, n) {
- if (n < 2) throw new d.IllegalStateException("Data not enough when parse String");
- var i = new DataView(e, t, n),
- r = i.getUint16(0, !h),
- s = void 0;
- return s = r > 0 ? (0, l.default)(new Uint8Array(e, t + 2, r)) : "", {
- data: s,
- size: 2 + r
- }
- }
- }, {
- key: "parseLongString",
- value: function(e, t, n) {
- if (n < 4) throw new d.IllegalStateException("Data not enough when parse LongString");
- var i = new DataView(e, t, n),
- r = i.getUint32(0, !h),
- s = void 0;
- return s = r > 0 ? (0, l.default)(new Uint8Array(e, t + 4, r)) : "", {
- data: s,
- size: 4 + r
- }
- }
- }, {
- key: "parseDate",
- value: function(e, t, n) {
- if (n < 10) throw new d.IllegalStateException("Data size invalid when parse Date");
- var i = new DataView(e, t, n),
- r = i.getFloat64(0, !h);
- return r += 60 * i.getInt16(8, !h) * 1e3, {
- data: new Date(r),
- size: 10
- }
- }
- }, {
- key: "parseValue",
- value: function(t, n, i) {
- if (i < 1) throw new d.IllegalStateException("Data not enough when parse Value");
- var r = new DataView(t, n, i),
- s = 1,
- a = r.getUint8(0),
- u = void 0,
- l = !1;
- try {
- switch (a) {
- case 0:
- u = r.getFloat64(1, !h), s += 8;
- break;
- case 1:
- u = !!r.getUint8(1), s += 1;
- break;
- case 2:
- var f = e.parseString(t, n + 1, i - 1);
- u = f.data, s += f.size;
- break;
- case 3:
- u = {};
- var c = 0;
- for (9 == (16777215 & r.getUint32(i - 4, !h)) && (c = 3); s < i - 4;) {
- var _ = e.parseObject(t, n + s, i - s - c);
- if (_.objectEnd) break;
- u[_.data.name] = _.data.value, s += _.size
- }
- if (s <= i - 3) {
- 9 === (16777215 & r.getUint32(s - 1, !h)) && (s += 3)
- }
- break;
- case 8:
- u = {}, s += 4;
- var m = 0;
- for (9 == (16777215 & r.getUint32(i - 4, !h)) && (m = 3); s < i - 8;) {
- var p = e.parseVariable(t, n + s, i - s - m);
- if (p.objectEnd) break;
- u[p.data.name] = p.data.value, s += p.size
- }
- if (s <= i - 3) {
- 9 === (16777215 & r.getUint32(s - 1, !h)) && (s += 3)
- }
- break;
- case 9:
- u = void 0, s = 1, l = !0;
- break;
- case 10:
- u = [];
- var v = r.getUint32(1, !h);
- s += 4;
- for (var g = 0; g < v; g++) {
- var y = e.parseValue(t, n + s, i - s);
- u.push(y.data), s += y.size
- }
- break;
- case 11:
- var E = e.parseDate(t, n + 1, i - 1);
- u = E.data, s += E.size;
- break;
- case 12:
- var b = e.parseString(t, n + 1, i - 1);
- u = b.data, s += b.size;
- break;
- default:
- s = i, o.default.w("AMF", "Unsupported AMF value type " + a)
- }
- } catch (e) {
- o.default.e("AMF", e.toString())
- }
- return {
- data: u,
- size: s,
- objectEnd: l
- }
- }
- }]), e
- }();
- n.default = f
- }, {
- "../utils/exception.js": 40,
- "../utils/logger.js": 41,
- "../utils/utf8-conv.js": 44
- }],
- 16: [function(e, t, n) {
- "use strict";
- Object.defineProperty(n, "__esModule", {
- value: !0
- });
- var i = {
- OK: "OK",
- FORMAT_ERROR: "FormatError",
- FORMAT_UNSUPPORTED: "FormatUnsupported",
- CODEC_UNSUPPORTED: "CodecUnsupported"
- };
- n.default = i
- }, {}],
- 17: [function(e, t, n) {
- "use strict";
-
- function i(e, t) {
- if (!(e instanceof t)) throw new TypeError("Cannot call a class as a function")
- }
- Object.defineProperty(n, "__esModule", {
- value: !0
- });
- var r = function() {
- function e(e, t) {
- for (var n = 0; n < t.length; n++) {
- var i = t[n];
- i.enumerable = i.enumerable || !1, i.configurable = !0, "value" in i && (i.writable = !0), Object.defineProperty(e, i.key, i)
- }
- }
- return function(t, n, i) {
- return n && e(t.prototype, n), i && e(t, i), t
- }
- }(),
- s = e("../utils/exception.js"),
- a = function() {
- function e(t) {
- i(this, e), this.TAG = "ExpGolomb", this._buffer = t, this._buffer_index = 0, this._total_bytes = t.byteLength, this._total_bits = 8 * t.byteLength, this._current_word = 0, this._current_word_bits_left = 0
- }
- return r(e, [{
- key: "destroy",
- value: function() {
- this._buffer = null
- }
- }, {
- key: "_fillCurrentWord",
- value: function() {
- var e = this._total_bytes - this._buffer_index;
- if (e <= 0) throw new s.IllegalStateException("ExpGolomb: _fillCurrentWord() but no bytes available");
- var t = Math.min(4, e),
- n = new Uint8Array(4);
- n.set(this._buffer.subarray(this._buffer_index, this._buffer_index + t)), this._current_word = new DataView(n.buffer).getUint32(0, !1), this._buffer_index += t, this._current_word_bits_left = 8 * t
- }
- }, {
- key: "readBits",
- value: function(e) {
- if (e > 32) throw new s.InvalidArgumentException("ExpGolomb: readBits() bits exceeded max 32bits!");
- if (e <= this._current_word_bits_left) {
- var t = this._current_word >>> 32 - e;
- return this._current_word <<= e, this._current_word_bits_left -= e, t
- }
- var n = this._current_word_bits_left ? this._current_word : 0;
- n >>>= 32 - this._current_word_bits_left;
- var i = e - this._current_word_bits_left;
- this._fillCurrentWord();
- var r = Math.min(i, this._current_word_bits_left),
- a = this._current_word >>> 32 - r;
- return this._current_word <<= r, this._current_word_bits_left -= r, n = n << r | a
- }
- }, {
- key: "readBool",
- value: function() {
- return 1 === this.readBits(1)
- }
- }, {
- key: "readByte",
- value: function() {
- return this.readBits(8)
- }
- }, {
- key: "_skipLeadingZero",
- value: function() {
- var e = void 0;
- for (e = 0; e < this._current_word_bits_left; e++)
- if (0 != (this._current_word & 2147483648 >>> e)) return this._current_word <<= e, this._current_word_bits_left -= e, e;
- return this._fillCurrentWord(), e + this._skipLeadingZero()
- }
- }, {
- key: "readUEG",
- value: function() {
- var e = this._skipLeadingZero();
- return this.readBits(e + 1) - 1
- }
- }, {
- key: "readSEG",
- value: function() {
- var e = this.readUEG();
- return 1 & e ? e + 1 >>> 1 : -1 * (e >>> 1)
- }
- }]), e
- }();
- n.default = a
- }, {
- "../utils/exception.js": 40
- }],
- 18: [function(e, t, n) {
- "use strict";
-
- function i(e) {
- return e && e.__esModule ? e : {
- default: e
- }
- }
-
- function r(e, t) {
- if (!(e instanceof t)) throw new TypeError("Cannot call a class as a function")
- }
-
- function s(e, t) {
- return e[t] << 24 | e[t + 1] << 16 | e[t + 2] << 8 | e[t + 3]
- }
- Object.defineProperty(n, "__esModule", {
- value: !0
- });
- var a = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(e) {
- return typeof e
- } : function(e) {
- return e && "function" == typeof Symbol && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : typeof e
- },
- o = function() {
- function e(e, t) {
- for (var n = 0; n < t.length; n++) {
- var i = t[n];
- i.enumerable = i.enumerable || !1, i.configurable = !0, "value" in i && (i.writable = !0), Object.defineProperty(e, i.key, i)
- }
- }
- return function(t, n, i) {
- return n && e(t.prototype, n), i && e(t, i), t
- }
- }(),
- u = e("../utils/logger.js"),
- l = i(u),
- d = e("./amf-parser.js"),
- h = i(d),
- f = e("./sps-parser.js"),
- c = i(f),
- _ = e("./demux-errors.js"),
- m = i(_),
- p = e("../core/media-info.js"),
- v = i(p),
- g = e("../utils/exception.js"),
- y = function() {
- function e(t, n) {
- r(this, e), this.TAG = "FLVDemuxer", this._config = n, this._onError = null, this._onMediaInfo = null, this._onTrackMetadata = null, this._onDataAvailable = null, this._dataOffset = t.dataOffset, this._firstParse = !0, this._dispatch = !1, this._hasAudio = t.hasAudioTrack, this._hasVideo = t.hasVideoTrack, this._hasAudioFlagOverrided = !1, this._hasVideoFlagOverrided = !1, this._audioInitialMetadataDispatched = !1, this._videoInitialMetadataDispatched = !1, this._mediaInfo = new v.default, this._mediaInfo.hasAudio = this._hasAudio, this._mediaInfo.hasVideo = this._hasVideo, this._metadata = null, this._audioMetadata = null, this._videoMetadata = null, this._naluLengthSize = 4, this._timestampBase = 0, this._timescale = 1e3, this._duration = 0, this._durationOverrided = !1, this._referenceFrameRate = {
- fixed: !0,
- fps: 23.976,
- fps_num: 23976,
- fps_den: 1e3
- }, this._flvSoundRateTable = [5500, 11025, 22050, 44100, 48e3], this._mpegSamplingRates = [96e3, 88200, 64e3, 48e3, 44100, 32e3, 24e3, 22050, 16e3, 12e3, 11025, 8e3, 7350], this._mpegAudioV10SampleRateTable = [44100, 48e3, 32e3, 0], this._mpegAudioV20SampleRateTable = [22050, 24e3, 16e3, 0], this._mpegAudioV25SampleRateTable = [11025, 12e3, 8e3, 0], this._mpegAudioL1BitRateTable = [0, 32, 64, 96, 128, 160, 192, 224, 256, 288, 320, 352, 384, 416, 448, -1], this._mpegAudioL2BitRateTable = [0, 32, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 384, -1], this._mpegAudioL3BitRateTable = [0, 32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, -1], this._videoTrack = {
- type: "video",
- id: 1,
- sequenceNumber: 0,
- samples: [],
- length: 0
- }, this._audioTrack = {
- type: "audio",
- id: 2,
- sequenceNumber: 0,
- samples: [],
- length: 0
- }, this._littleEndian = function() {
- var e = new ArrayBuffer(2);
- return new DataView(e).setInt16(0, 256, !0), 256 === new Int16Array(e)[0]
- }()
- }
- return o(e, [{
- key: "destroy",
- value: function() {
- this._mediaInfo = null, this._metadata = null, this._audioMetadata = null, this._videoMetadata = null, this._videoTrack = null, this._audioTrack = null, this._onError = null, this._onMediaInfo = null, this._onTrackMetadata = null, this._onDataAvailable = null
- }
- }, {
- key: "bindDataSource",
- value: function(e) {
- return e.onDataArrival = this.parseChunks.bind(this), this
- }
- }, {
- key: "resetMediaInfo",
- value: function() {
- this._mediaInfo = new v.default
- }
- }, {
- key: "_isInitialMetadataDispatched",
- value: function() {
- return this._hasAudio && this._hasVideo ? this._audioInitialMetadataDispatched && this._videoInitialMetadataDispatched : this._hasAudio && !this._hasVideo ? this._audioInitialMetadataDispatched : !(this._hasAudio || !this._hasVideo) && this._videoInitialMetadataDispatched
- }
- }, {
- key: "parseChunks",
- value: function(t, n) {
- if (!(this._onError && this._onMediaInfo && this._onTrackMetadata && this._onDataAvailable)) throw new g.IllegalStateException("Flv: onError & onMediaInfo & onTrackMetadata & onDataAvailable callback must be specified");
- var i = 0,
- r = this._littleEndian;
- if (0 === n) {
- if (!(t.byteLength > 13)) return 0;
- i = e.probe(t).dataOffset
- }
- if (this._firstParse) {
- this._firstParse = !1, n + i !== this._dataOffset && l.default.w(this.TAG, "First time parsing but chunk byteStart invalid!");
- 0 !== new DataView(t, i).getUint32(0, !r) && l.default.w(this.TAG, "PrevTagSize0 !== 0 !!!"), i += 4
- }
- for (; i < t.byteLength;) {
- this._dispatch = !0;
- var s = new DataView(t, i);
- if (i + 11 + 4 > t.byteLength) break;
- var a = s.getUint8(0),
- o = 16777215 & s.getUint32(0, !r);
- if (i + 11 + o + 4 > t.byteLength) break;
- if (8 === a || 9 === a || 18 === a) {
- var u = s.getUint8(4),
- d = s.getUint8(5),
- h = s.getUint8(6),
- f = s.getUint8(7),
- c = h | d << 8 | u << 16 | f << 24;
- 0 !== (16777215 & s.getUint32(7, !r)) && l.default.w(this.TAG, "Meet tag which has StreamID != 0!");
- var _ = i + 11;
- switch (a) {
- case 8:
- this._parseAudioData(t, _, o, c);
- break;
- case 9:
- this._parseVideoData(t, _, o, c, n + i);
- break;
- case 18:
- this._parseScriptData(t, _, o)
- }
- var m = s.getUint32(11 + o, !r);
- m !== 11 + o && l.default.w(this.TAG, "Invalid PrevTagSize " + m), i += 11 + o + 4
- } else l.default.w(this.TAG, "Unsupported tag type " + a + ", skipped"), i += 11 + o + 4
- }
- return this._isInitialMetadataDispatched() && this._dispatch && (this._audioTrack.length || this._videoTrack.length) && this._onDataAvailable(this._audioTrack, this._videoTrack), i
- }
- }, {
- key: "_parseScriptData",
- value: function(e, t, n) {
- var i = h.default.parseScriptData(e, t, n);
- if (i.hasOwnProperty("onMetaData")) {
- if (null == i.onMetaData || "object" !== a(i.onMetaData)) return void l.default.w(this.TAG, "Invalid onMetaData structure!");
- this._metadata && l.default.w(this.TAG, "Found another onMetaData tag!"), this._metadata = i;
- var r = this._metadata.onMetaData;
- if ("boolean" == typeof r.hasAudio && !1 === this._hasAudioFlagOverrided && (this._hasAudio = r.hasAudio, this._mediaInfo.hasAudio = this._hasAudio), "boolean" == typeof r.hasVideo && !1 === this._hasVideoFlagOverrided && (this._hasVideo = r.hasVideo, this._mediaInfo.hasVideo = this._hasVideo), "number" == typeof r.audiodatarate && (this._mediaInfo.audioDataRate = r.audiodatarate), "number" == typeof r.videodatarate && (this._mediaInfo.videoDataRate = r.videodatarate), "number" == typeof r.width && (this._mediaInfo.width = r.width), "number" == typeof r.height && (this._mediaInfo.height = r.height), "number" == typeof r.duration) {
- if (!this._durationOverrided) {
- var s = Math.floor(r.duration * this._timescale);
- this._duration = s, this._mediaInfo.duration = s
- }
- } else this._mediaInfo.duration = 0;
- if ("number" == typeof r.framerate) {
- var o = Math.floor(1e3 * r.framerate);
- if (o > 0) {
- var u = o / 1e3;
- this._referenceFrameRate.fixed = !0, this._referenceFrameRate.fps = u, this._referenceFrameRate.fps_num = o, this._referenceFrameRate.fps_den = 1e3, this._mediaInfo.fps = u
- }
- }
- if ("object" === a(r.keyframes)) {
- this._mediaInfo.hasKeyframesIndex = !0;
- var d = r.keyframes;
- this._mediaInfo.keyframesIndex = this._parseKeyframesIndex(d), r.keyframes = null
- } else this._mediaInfo.hasKeyframesIndex = !1;
- this._dispatch = !1, this._mediaInfo.metadata = r, l.default.v(this.TAG, "Parsed onMetaData"), this._mediaInfo.isComplete() && this._onMediaInfo(this._mediaInfo)
- }
- }
- }, {
- key: "_parseKeyframesIndex",
- value: function(e) {
- for (var t = [], n = [], i = 1; i < e.times.length; i++) {
- var r = this._timestampBase + Math.floor(1e3 * e.times[i]);
- t.push(r), n.push(e.filepositions[i])
- }
- return {
- times: t,
- filepositions: n
- }
- }
- }, {
- key: "_parseAudioData",
- value: function(e, t, n, i) {
- if (n <= 1) return void l.default.w(this.TAG, "Flv: Invalid audio packet, missing SoundData payload!");
- if (!0 !== this._hasAudioFlagOverrided || !1 !== this._hasAudio) {
- var r = (this._littleEndian, new DataView(e, t, n)),
- s = r.getUint8(0),
- a = s >>> 4;
- if (2 !== a && 10 !== a) return void this._onError(m.default.CODEC_UNSUPPORTED, "Flv: Unsupported audio codec idx: " + a);
- var o = 0,
- u = (12 & s) >>> 2;
- if (!(u >= 0 && u <= 4)) return void this._onError(m.default.FORMAT_ERROR, "Flv: Invalid audio sample rate idx: " + u);
- o = this._flvSoundRateTable[u];
- var d = 1 & s,
- h = this._audioMetadata,
- f = this._audioTrack;
- if (h || (!1 === this._hasAudio && !1 === this._hasAudioFlagOverrided && (this._hasAudio = !0, this._mediaInfo.hasAudio = !0), h = this._audioMetadata = {}, h.type = "audio", h.id = f.id, h.timescale = this._timescale, h.duration = this._duration, h.audioSampleRate = o, h.channelCount = 0 === d ? 1 : 2), 10 === a) {
- var c = this._parseAACAudioData(e, t + 1, n - 1);
- if (void 0 == c) return;
- if (0 === c.packetType) {
- h.config && l.default.w(this.TAG, "Found another AudioSpecificConfig!");
- var _ = c.data;
- h.audioSampleRate = _.samplingRate, h.channelCount = _.channelCount, h.codec = _.codec, h.originalCodec = _.originalCodec, h.config = _.config, h.refSampleDuration = 1024 / h.audioSampleRate * h.timescale, l.default.v(this.TAG, "Parsed AudioSpecificConfig"), this._isInitialMetadataDispatched() ? this._dispatch && (this._audioTrack.length || this._videoTrack.length) && this._onDataAvailable(this._audioTrack, this._videoTrack) : this._audioInitialMetadataDispatched = !0, this._dispatch = !1, this._onTrackMetadata("audio", h);
- var p = this._mediaInfo;
- p.audioCodec = h.originalCodec, p.audioSampleRate = h.audioSampleRate, p.audioChannelCount = h.channelCount, p.hasVideo ? null != p.videoCodec && (p.mimeType = 'video/x-flv; codecs="' + p.videoCodec + "," + p.audioCodec + '"') : p.mimeType = 'video/x-flv; codecs="' + p.audioCodec + '"', p.isComplete() && this._onMediaInfo(p)
- } else if (1 === c.packetType) {
- var v = this._timestampBase + i,
- g = {
- unit: c.data,
- length: c.data.byteLength,
- dts: v,
- pts: v
- };
- f.samples.push(g), f.length += c.data.length
- } else l.default.e(this.TAG, "Flv: Unsupported AAC data type " + c.packetType)
- } else if (2 === a) {
- if (!h.codec) {
- var y = this._parseMP3AudioData(e, t + 1, n - 1, !0);
- if (void 0 == y) return;
- h.audioSampleRate = y.samplingRate, h.channelCount = y.channelCount, h.codec = y.codec, h.originalCodec = y.originalCodec, h.refSampleDuration = 1152 / h.audioSampleRate * h.timescale, l.default.v(this.TAG, "Parsed MPEG Audio Frame Header"), this._audioInitialMetadataDispatched = !0, this._onTrackMetadata("audio", h);
- var E = this._mediaInfo;
- E.audioCodec = h.codec, E.audioSampleRate = h.audioSampleRate, E.audioChannelCount = h.channelCount, E.audioDataRate = y.bitRate, E.hasVideo ? null != E.videoCodec && (E.mimeType = 'video/x-flv; codecs="' + E.videoCodec + "," + E.audioCodec + '"') : E.mimeType = 'video/x-flv; codecs="' + E.audioCodec + '"', E.isComplete() && this._onMediaInfo(E)
- }
- var b = this._parseMP3AudioData(e, t + 1, n - 1, !1);
- if (void 0 == b) return;
- var S = this._timestampBase + i,
- k = {
- unit: b,
- length: b.byteLength,
- dts: S,
- pts: S
- };
- f.samples.push(k), f.length += b.length
- }
- }
- }
- }, {
- key: "_parseAACAudioData",
- value: function(e, t, n) {
- if (n <= 1) return void l.default.w(this.TAG, "Flv: Invalid AAC packet, missing AACPacketType or/and Data!");
- var i = {},
- r = new Uint8Array(e, t, n);
- return i.packetType = r[0], 0 === r[0] ? i.data = this._parseAACAudioSpecificConfig(e, t + 1, n - 1) : i.data = r.subarray(1), i
- }
- }, {
- key: "_parseAACAudioSpecificConfig",
- value: function(e, t, n) {
- var i = new Uint8Array(e, t, n),
- r = null,
- s = 0,
- a = 0,
- o = 0,
- u = null;
- if (s = a = i[0] >>> 3, (o = (7 & i[0]) << 1 | i[1] >>> 7) < 0 || o >= this._mpegSamplingRates.length) return void this._onError(m.default.FORMAT_ERROR, "Flv: AAC invalid sampling frequency index!");
- var l = this._mpegSamplingRates[o],
- d = (120 & i[1]) >>> 3;
- if (d < 0 || d >= 8) return void this._onError(m.default.FORMAT_ERROR, "Flv: AAC invalid channel configuration");
- 5 === s && (u = (7 & i[1]) << 1 | i[2] >>> 7, i[2]);
- var h = self.navigator.userAgent.toLowerCase();
- return -1 !== h.indexOf("firefox") ? o >= 6 ? (s = 5, r = new Array(4), u = o - 3) : (s = 2, r = new Array(2), u = o) : -1 !== h.indexOf("android") ? (s = 2, r = new Array(2), u = o) : (s = 5, u = o, r = new Array(4), o >= 6 ? u = o - 3 : 1 === d && (s = 2, r = new Array(2), u = o)), r[0] = s << 3, r[0] |= (15 & o) >>> 1, r[1] = (15 & o) << 7, r[1] |= (15 & d) << 3, 5 === s && (r[1] |= (15 & u) >>> 1, r[2] = (1 & u) << 7, r[2] |= 8, r[3] = 0), {
- config: r,
- samplingRate: l,
- channelCount: d,
- codec: "mp4a.40." + s,
- originalCodec: "mp4a.40." + a
- }
- }
- }, {
- key: "_parseMP3AudioData",
- value: function(e, t, n, i) {
- if (n < 4) return void l.default.w(this.TAG, "Flv: Invalid MP3 packet, header missing!");
- var r = (this._littleEndian, new Uint8Array(e, t, n)),
- s = null;
- if (i) {
- if (255 !== r[0]) return;
- var a = r[1] >>> 3 & 3,
- o = (6 & r[1]) >> 1,
- u = (240 & r[2]) >>> 4,
- d = (12 & r[2]) >>> 2,
- h = r[3] >>> 6 & 3,
- f = 3 !== h ? 2 : 1,
- c = 0,
- _ = 0;
- switch (a) {
- case 0:
- c = this._mpegAudioV25SampleRateTable[d];
- break;
- case 2:
- c = this._mpegAudioV20SampleRateTable[d];
- break;
- case 3:
- c = this._mpegAudioV10SampleRateTable[d]
- }
- switch (o) {
- case 1:
- 34, u < this._mpegAudioL3BitRateTable.length && (_ = this._mpegAudioL3BitRateTable[u]);
- break;
- case 2:
- 33, u < this._mpegAudioL2BitRateTable.length && (_ = this._mpegAudioL2BitRateTable[u]);
- break;
- case 3:
- 32, u < this._mpegAudioL1BitRateTable.length && (_ = this._mpegAudioL1BitRateTable[u])
- }
- s = {
- bitRate: _,
- samplingRate: c,
- channelCount: f,
- codec: "mp3",
- originalCodec: "mp3"
- }
- } else s = r;
- return s
- }
- }, {
- key: "_parseVideoData",
- value: function(e, t, n, i, r) {
- if (n <= 1) return void l.default.w(this.TAG, "Flv: Invalid video packet, missing VideoData payload!");
- if (!0 !== this._hasVideoFlagOverrided || !1 !== this._hasVideo) {
- var s = new Uint8Array(e, t, n)[0],
- a = (240 & s) >>> 4,
- o = 15 & s;
- if (7 !== o) return void this._onError(m.default.CODEC_UNSUPPORTED, "Flv: Unsupported codec in video frame: " + o);
- this._parseAVCVideoPacket(e, t + 1, n - 1, i, r, a)
- }
- }
- }, {
- key: "_parseAVCVideoPacket",
- value: function(e, t, n, i, r, s) {
- if (n < 4) return void l.default.w(this.TAG, "Flv: Invalid AVC packet, missing AVCPacketType or/and CompositionTime");
- var a = this._littleEndian,
- o = new DataView(e, t, n),
- u = o.getUint8(0),
- d = 16777215 & o.getUint32(0, !a),
- h = d << 8 >> 8;
- if (0 === u) this._parseAVCDecoderConfigurationRecord(e, t + 4, n - 4);
- else if (1 === u) this._parseAVCVideoData(e, t + 4, n - 4, i, r, s, h);
- else if (2 !== u) return void this._onError(m.default.FORMAT_ERROR, "Flv: Invalid video packet type " + u)
- }
- }, {
- key: "_parseAVCDecoderConfigurationRecord",
- value: function(e, t, n) {
- if (n < 7) return void l.default.w(this.TAG, "Flv: Invalid AVCDecoderConfigurationRecord, lack of data!");
- var i = this._videoMetadata,
- r = this._videoTrack,
- s = this._littleEndian,
- a = new DataView(e, t, n);
- i ? void 0 !== i.avcc && l.default.w(this.TAG, "Found another AVCDecoderConfigurationRecord!") : (!1 === this._hasVideo && !1 === this._hasVideoFlagOverrided && (this._hasVideo = !0, this._mediaInfo.hasVideo = !0), i = this._videoMetadata = {}, i.type = "video", i.id = r.id, i.timescale = this._timescale, i.duration = this._duration);
- var o = a.getUint8(0),
- u = a.getUint8(1);
- a.getUint8(2), a.getUint8(3);
- if (1 !== o || 0 === u) return void this._onError(m.default.FORMAT_ERROR, "Flv: Invalid AVCDecoderConfigurationRecord");
- if (this._naluLengthSize = 1 + (3 & a.getUint8(4)), 3 !== this._naluLengthSize && 4 !== this._naluLengthSize) return void this._onError(m.default.FORMAT_ERROR, "Flv: Strange NaluLengthSizeMinusOne: " + (this._naluLengthSize - 1));
- var d = 31 & a.getUint8(5);
- if (0 === d) return void this._onError(m.default.FORMAT_ERROR, "Flv: Invalid AVCDecoderConfigurationRecord: No SPS");
- d > 1 && l.default.w(this.TAG, "Flv: Strange AVCDecoderConfigurationRecord: SPS Count = " + d);
- for (var h = 6, f = 0; f < d; f++) {
- var _ = a.getUint16(h, !s);
- if (h += 2, 0 !== _) {
- var p = new Uint8Array(e, t + h, _);
- h += _;
- var v = c.default.parseSPS(p);
- if (0 === f) {
- i.codecWidth = v.codec_size.width, i.codecHeight = v.codec_size.height, i.presentWidth = v.present_size.width, i.presentHeight = v.present_size.height, i.profile = v.profile_string, i.level = v.level_string, i.bitDepth = v.bit_depth, i.chromaFormat = v.chroma_format, i.sarRatio = v.sar_ratio, i.frameRate = v.frame_rate, !1 !== v.frame_rate.fixed && 0 !== v.frame_rate.fps_num && 0 !== v.frame_rate.fps_den || (i.frameRate = this._referenceFrameRate);
- var g = i.frameRate.fps_den,
- y = i.frameRate.fps_num;
- i.refSampleDuration = i.timescale * (g / y);
- for (var E = p.subarray(1, 4), b = "avc1.", S = 0; S < 3; S++) {
- var k = E[S].toString(16);
- k.length < 2 && (k = "0" + k), b += k
- }
- i.codec = b;
- var L = this._mediaInfo;
- L.width = i.codecWidth, L.height = i.codecHeight, L.fps = i.frameRate.fps, L.profile = i.profile, L.level = i.level, L.refFrames = v.ref_frames, L.chromaFormat = v.chroma_format_string, L.sarNum = i.sarRatio.width, L.sarDen = i.sarRatio.height, L.videoCodec = b, L.hasAudio ? null != L.audioCodec && (L.mimeType = 'video/x-flv; codecs="' + L.videoCodec + "," + L.audioCodec + '"') : L.mimeType = 'video/x-flv; codecs="' + L.videoCodec + '"', L.isComplete() && this._onMediaInfo(L)
- }
- }
- }
- var w = a.getUint8(h);
- if (0 === w) return void this._onError(m.default.FORMAT_ERROR, "Flv: Invalid AVCDecoderConfigurationRecord: No PPS");
- w > 1 && l.default.w(this.TAG, "Flv: Strange AVCDecoderConfigurationRecord: PPS Count = " + w), h++;
- for (var R = 0; R < w; R++) {
- var A = a.getUint16(h, !s);
- h += 2, 0 !== A && (h += A)
- }
- i.avcc = new Uint8Array(n), i.avcc.set(new Uint8Array(e, t, n), 0), l.default.v(this.TAG, "Parsed AVCDecoderConfigurationRecord"), this._isInitialMetadataDispatched() ? this._dispatch && (this._audioTrack.length || this._videoTrack.length) && this._onDataAvailable(this._audioTrack, this._videoTrack) : this._videoInitialMetadataDispatched = !0, this._dispatch = !1, this._onTrackMetadata("video", i)
- }
- }, {
- key: "_parseAVCVideoData",
- value: function(e, t, n, i, r, s, a) {
- for (var o = this._littleEndian, u = new DataView(e, t, n), d = [], h = 0, f = 0, c = this._naluLengthSize, _ = this._timestampBase + i, m = 1 === s; f < n;) {
- if (f + 4 >= n) {
- l.default.w(this.TAG, "Malformed Nalu near timestamp " + _ + ", offset = " + f + ", dataSize = " + n);
- break
- }
- var p = u.getUint32(f, !o);
- if (3 === c && (p >>>= 8), p > n - c) return void l.default.w(this.TAG, "Malformed Nalus near timestamp " + _ + ", NaluSize > DataSize!");
- var v = 31 & u.getUint8(f + c);
- 5 === v && (m = !0);
- var g = new Uint8Array(e, t + f, c + p),
- y = {
- type: v,
- data: g
- };
- d.push(y), h += g.byteLength, f += c + p
- }
- if (d.length) {
- var E = this._videoTrack,
- b = {
- units: d,
- length: h,
- isKeyframe: m,
- dts: _,
- cts: a,
- pts: _ + a
- };
- m && (b.fileposition = r), E.samples.push(b), E.length += h
- }
- }
- }, {
- key: "onTrackMetadata",
- get: function() {
- return this._onTrackMetadata
- },
- set: function(e) {
- this._onTrackMetadata = e
- }
- }, {
- key: "onMediaInfo",
- get: function() {
- return this._onMediaInfo
- },
- set: function(e) {
- this._onMediaInfo = e
- }
- }, {
- key: "onError",
- get: function() {
- return this._onError
- },
- set: function(e) {
- this._onError = e
- }
- }, {
- key: "onDataAvailable",
- get: function() {
- return this._onDataAvailable
- },
- set: function(e) {
- this._onDataAvailable = e
- }
- }, {
- key: "timestampBase",
- get: function() {
- return this._timestampBase
- },
- set: function(e) {
- this._timestampBase = e
- }
- }, {
- key: "overridedDuration",
- get: function() {
- return this._duration
- },
- set: function(e) {
- this._durationOverrided = !0, this._duration = e, this._mediaInfo.duration = e
- }
- }, {
- key: "overridedHasAudio",
- set: function(e) {
- this._hasAudioFlagOverrided = !0, this._hasAudio = e, this._mediaInfo.hasAudio = e
- }
- }, {
- key: "overridedHasVideo",
- set: function(e) {
- this._hasVideoFlagOverrided = !0, this._hasVideo = e, this._mediaInfo.hasVideo = e
- }
- }], [{
- key: "probe",
- value: function(e) {
- var t = new Uint8Array(e),
- n = {
- match: !1
- };
- if (70 !== t[0] || 76 !== t[1] || 86 !== t[2] || 1 !== t[3]) return n;
- var i = (4 & t[4]) >>> 2 != 0,
- r = 0 != (1 & t[4]),
- a = s(t, 5);
- return a < 9 ? n : {
- match: !0,
- consumed: a,
- dataOffset: a,
- hasAudioTrack: i,
- hasVideoTrack: r
- }
- }
- }]), e
- }();
- n.default = y
- }, {
- "../core/media-info.js": 7,
- "../utils/exception.js": 40,
- "../utils/logger.js": 41,
- "./amf-parser.js": 15,
- "./demux-errors.js": 16,
- "./sps-parser.js": 19
- }],
- 19: [function(e, t, n) {
- "use strict";
-
- function i(e, t) {
- if (!(e instanceof t)) throw new TypeError("Cannot call a class as a function")
- }
- Object.defineProperty(n, "__esModule", {
- value: !0
- });
- var r = function() {
- function e(e, t) {
- for (var n = 0; n < t.length; n++) {
- var i = t[n];
- i.enumerable = i.enumerable || !1, i.configurable = !0, "value" in i && (i.writable = !0), Object.defineProperty(e, i.key, i)
- }
- }
- return function(t, n, i) {
- return n && e(t.prototype, n), i && e(t, i), t
- }
- }(),
- s = e("./exp-golomb.js"),
- a = function(e) {
- return e && e.__esModule ? e : {
- default: e
- }
- }(s),
- o = function() {
- function e() {
- i(this, e)
- }
- return r(e, null, [{
- key: "_ebsp2rbsp",
- value: function(e) {
- for (var t = e, n = t.byteLength, i = new Uint8Array(n), r = 0, s = 0; s < n; s++) s >= 2 && 3 === t[s] && 0 === t[s - 1] && 0 === t[s - 2] || (i[r] = t[s], r++);
- return new Uint8Array(i.buffer, 0, r)
- }
- }, {
- key: "parseSPS",
- value: function(t) {
- var n = e._ebsp2rbsp(t),
- i = new a.default(n);
- i.readByte();
- var r = i.readByte();
- i.readByte();
- var s = i.readByte();
- i.readUEG();
- var o = e.getProfileString(r),
- u = e.getLevelString(s),
- l = 1,
- d = 420,
- h = [0, 420, 422, 444],
- f = 8;
- if ((100 === r || 110 === r || 122 === r || 244 === r || 44 === r || 83 === r || 86 === r || 118 === r || 128 === r || 138 === r || 144 === r) && (l = i.readUEG(), 3 === l && i.readBits(1), l <= 3 && (d = h[l]), f = i.readUEG() + 8, i.readUEG(), i.readBits(1), i.readBool()))
- for (var c = 3 !== l ? 8 : 12, _ = 0; _ < c; _++) i.readBool() && (_ < 6 ? e._skipScalingList(i, 16) : e._skipScalingList(i, 64));
- i.readUEG();
- var m = i.readUEG();
- if (0 === m) i.readUEG();
- else if (1 === m) {
- i.readBits(1), i.readSEG(), i.readSEG();
- for (var p = i.readUEG(), v = 0; v < p; v++) i.readSEG()
- }
- var g = i.readUEG();
- i.readBits(1);
- var y = i.readUEG(),
- E = i.readUEG(),
- b = i.readBits(1);
- 0 === b && i.readBits(1), i.readBits(1);
- var S = 0,
- k = 0,
- L = 0,
- w = 0;
- i.readBool() && (S = i.readUEG(), k = i.readUEG(), L = i.readUEG(), w = i.readUEG());
- var R = 1,
- A = 1,
- O = 0,
- T = !0,
- C = 0,
- I = 0;
- if (i.readBool()) {
- if (i.readBool()) {
- var x = i.readByte(),
- M = [1, 12, 10, 16, 40, 24, 20, 32, 80, 18, 15, 64, 160, 4, 3, 2],
- D = [1, 11, 11, 11, 33, 11, 11, 11, 33, 11, 11, 33, 99, 3, 2, 1];
- x > 0 && x < 16 ? (R = M[x - 1], A = D[x - 1]) : 255 === x && (R = i.readByte() << 8 | i.readByte(), A = i.readByte() << 8 | i.readByte())
- }
- if (i.readBool() && i.readBool(), i.readBool() && (i.readBits(4), i.readBool() && i.readBits(24)), i.readBool() && (i.readUEG(), i.readUEG()), i.readBool()) {
- var B = i.readBits(32),
- j = i.readBits(32);
- T = i.readBool(), C = j, I = 2 * B, O = C / I
- }
- }
- var P = 1;
- 1 === R && 1 === A || (P = R / A);
- var U = 0,
- N = 0;
- if (0 === l) U = 1, N = 2 - b;
- else {
- var F = 3 === l ? 1 : 2,
- G = 1 === l ? 2 : 1;
- U = F, N = G * (2 - b)
- }
- var V = 16 * (y + 1),
- z = 16 * (E + 1) * (2 - b);
- V -= (S + k) * U, z -= (L + w) * N;
- var H = Math.ceil(V * P);
- return i.destroy(), i = null, {
- profile_string: o,
- level_string: u,
- bit_depth: f,
- ref_frames: g,
- chroma_format: d,
- chroma_format_string: e.getChromaFormatString(d),
- frame_rate: {
- fixed: T,
- fps: O,
- fps_den: I,
- fps_num: C
- },
- sar_ratio: {
- width: R,
- height: A
- },
- codec_size: {
- width: V,
- height: z
- },
- present_size: {
- width: H,
- height: z
- }
- }
- }
- }, {
- key: "_skipScalingList",
- value: function(e, t) {
- for (var n = 8, i = 8, r = 0, s = 0; s < t; s++) 0 !== i && (r = e.readSEG(), i = (n + r + 256) % 256), n = 0 === i ? n : i
- }
- }, {
- key: "getProfileString",
- value: function(e) {
- switch (e) {
- case 66:
- return "Baseline";
- case 77:
- return "Main";
- case 88:
- return "Extended";
- case 100:
- return "High";
- case 110:
- return "High10";
- case 122:
- return "High422";
- case 244:
- return "High444";
- default:
- return "Unknown"
- }
- }
- }, {
- key: "getLevelString",
- value: function(e) {
- return (e / 10).toFixed(1)
- }
- }, {
- key: "getChromaFormatString",
- value: function(e) {
- switch (e) {
- case 420:
- return "4:2:0";
- case 422:
- return "4:2:2";
- case 444:
- return "4:4:4";
- default:
- return "Unknown"
- }
- }
- }]), e
- }();
- n.default = o
- }, {
- "./exp-golomb.js": 17
- }],
- 20: [function(e, t, n) {
- "use strict";
-
- function i(e) {
- return e && e.__esModule ? e : {
- default: e
- }
- }
-
- function r(e, t) {
- var n = e;
- if (null == n || "object" !== (void 0 === n ? "undefined" : o(n))) throw new b.InvalidArgumentException("MediaDataSource must be an javascript object!");
- if (!n.hasOwnProperty("type")) throw new b.InvalidArgumentException("MediaDataSource must has type field to indicate video file type!");
- switch (n.type) {
- case "flv":
- return new c.default(n, t);
- default:
- return new m.default(n, t)
- }
- }
-
- function s() {
- return h.default.supportMSEH264Playback()
- }
-
- function a() {
- return h.default.getFeatureList()
- }
- Object.defineProperty(n, "__esModule", {
- value: !0
- });
- var o = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(e) {
- return typeof e
- } : function(e) {
- return e && "function" == typeof Symbol && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : typeof e
- },
- u = e("./utils/polyfill.js"),
- l = i(u),
- d = e("./core/features.js"),
- h = i(d),
- f = e("./player/flv-player.js"),
- c = i(f),
- _ = e("./player/native-player.js"),
- m = i(_),
- p = e("./player/player-events.js"),
- v = i(p),
- g = e("./player/player-errors.js"),
- y = e("./utils/logging-control.js"),
- E = i(y),
- b = e("./utils/exception.js");
- l.default.install();
- var S = {};
- S.createPlayer = r, S.isSupported = s, S.getFeatureList = a, S.Events = v.default, S.ErrorTypes = g.ErrorTypes, S.ErrorDetails = g.ErrorDetails, S.FlvPlayer = c.default, S.NativePlayer = m.default, S.LoggingControl = E.default, Object.defineProperty(S, "version", {
- enumerable: !0,
- get: function() {
- return "1.4.2"
- }
- }), n.default = S
- }, {
- "./core/features.js": 6,
- "./player/flv-player.js": 32,
- "./player/native-player.js": 33,
- "./player/player-errors.js": 34,
- "./player/player-events.js": 35,
- "./utils/exception.js": 40,
- "./utils/logging-control.js": 42,
- "./utils/polyfill.js": 43
- }],
- 21: [function(e, t, n) {
- "use strict";
- t.exports = e("./flv.js").default
- }, {
- "./flv.js": 20
- }],
- 22: [function(e, t, n) {
- "use strict";
-
- function i(e) {
- return e && e.__esModule ? e : {
- default: e
- }
- }
-
- function r(e, t) {
- if (!(e instanceof t)) throw new TypeError("Cannot call a class as a function")
- }
-
- function s(e, t) {
- if (!e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
- return !t || "object" != typeof t && "function" != typeof t ? e : t
- }
-
- function a(e, t) {
- if ("function" != typeof t && null !== t) throw new TypeError("Super expression must either be null or a function, not " + typeof t);
- e.prototype = Object.create(t && t.prototype, {
- constructor: {
- value: e,
- enumerable: !1,
- writable: !0,
- configurable: !0
- }
- }), t && (Object.setPrototypeOf ? Object.setPrototypeOf(e, t) : e.__proto__ = t)
- }
- Object.defineProperty(n, "__esModule", {
- value: !0
- });
- var o = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(e) {
- return typeof e
- } : function(e) {
- return e && "function" == typeof Symbol && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : typeof e
- },
- u = function e(t, n, i) {
- null === t && (t = Function.prototype);
- var r = Object.getOwnPropertyDescriptor(t, n);
- if (void 0 === r) {
- var s = Object.getPrototypeOf(t);
- return null === s ? void 0 : e(s, n, i)
- }
- if ("value" in r) return r.value;
- var a = r.get;
- if (void 0 !== a) return a.call(i)
- },
- l = function() {
- function e(e, t) {
- for (var n = 0; n < t.length; n++) {
- var i = t[n];
- i.enumerable = i.enumerable || !1, i.configurable = !0, "value" in i && (i.writable = !0), Object.defineProperty(e, i.key, i)
- }
- }
- return function(t, n, i) {
- return n && e(t.prototype, n), i && e(t, i), t
- }
- }(),
- d = e("../utils/logger.js"),
- h = (i(d), e("../utils/browser.js")),
- f = i(h),
- c = e("./loader.js"),
- _ = e("../utils/exception.js"),
- m = function(e) {
- function t(e, n) {
- r(this, t);
- var i = s(this, (t.__proto__ || Object.getPrototypeOf(t)).call(this, "fetch-stream-loader"));
- return i.TAG = "FetchStreamLoader", i._seekHandler = e, i._config = n, i._needStash = !0, i._requestAbort = !1, i._contentLength = null, i._receivedLength = 0, i
- }
- return a(t, e), l(t, null, [{
- key: "isSupported",
- value: function() {
- try {
- var e = f.default.msedge && f.default.version.minor >= 15048,
- t = !f.default.msedge || e;
- return self.fetch && self.ReadableStream && t
- } catch (e) {
- return !1
- }
- }
- }]), l(t, [{
- key: "destroy",
- value: function() {
- this.isWorking() && this.abort(), u(t.prototype.__proto__ || Object.getPrototypeOf(t.prototype), "destroy", this).call(this)
- }
- }, {
- key: "open",
- value: function(e, t) {
- var n = this;
- this._dataSource = e, this._range = t;
- var i = e.url;
- this._config.reuseRedirectedURL && void 0 != e.redirectedURL && (i = e.redirectedURL);
- var r = this._seekHandler.getConfig(i, t),
- s = new self.Headers;
- if ("object" === o(r.headers)) {
- var a = r.headers;
- for (var u in a) a.hasOwnProperty(u) && s.append(u, a[u])
- }
- var l = {
- method: "GET",
- headers: s,
- mode: "cors",
- cache: "default",
- referrerPolicy: "no-referrer-when-downgrade"
- };
- !1 === e.cors && (l.mode = "same-origin"), e.withCredentials && (l.credentials = "include"), e.referrerPolicy && (l.referrerPolicy = e.referrerPolicy), this._status = c.LoaderStatus.kConnecting, self.fetch(r.url, l).then(function(e) {
- if (n._requestAbort) return n._requestAbort = !1, void(n._status = c.LoaderStatus.kIdle);
- if (e.ok && e.status >= 200 && e.status <= 299) {
- if (e.url !== r.url && n._onURLRedirect) {
- var t = n._seekHandler.removeURLParameters(e.url);
- n._onURLRedirect(t)
- }
- var i = e.headers.get("Content-Length");
- return null != i && (n._contentLength = parseInt(i), 0 !== n._contentLength && n._onContentLengthKnown && n._onContentLengthKnown(n._contentLength)), n._pump.call(n, e.body.getReader())
- }
- if (n._status = c.LoaderStatus.kError, !n._onError) throw new _.RuntimeException("FetchStreamLoader: Http code invalid, " + e.status + " " + e.statusText);
- n._onError(c.LoaderErrors.HTTP_STATUS_CODE_INVALID, {
- code: e.status,
- msg: e.statusText
- })
- }).catch(function(e) {
- if (n._status = c.LoaderStatus.kError, !n._onError) throw e;
- n._onError(c.LoaderErrors.EXCEPTION, {
- code: -1,
- msg: e.message
- })
- })
- }
- }, {
- key: "abort",
- value: function() {
- this._requestAbort = !0
- }
- }, {
- key: "_pump",
- value: function(e) {
- var t = this;
- return e.read().then(function(n) {
- if (n.done)
- if (null !== t._contentLength && t._receivedLength < t._contentLength) {
- t._status = c.LoaderStatus.kError;
- var i = c.LoaderErrors.EARLY_EOF,
- r = {
- code: -1,
- msg: "Fetch stream meet Early-EOF"
- };
- if (!t._onError) throw new _.RuntimeException(r.msg);
- t._onError(i, r)
- } else t._status = c.LoaderStatus.kComplete, t._onComplete && t._onComplete(t._range.from, t._range.from + t._receivedLength - 1);
- else {
- if (!0 === t._requestAbort) return t._requestAbort = !1, t._status = c.LoaderStatus.kComplete, e.cancel();
- t._status = c.LoaderStatus.kBuffering;
- var s = n.value.buffer,
- a = t._range.from + t._receivedLength;
- t._receivedLength += s.byteLength, t._onDataArrival && t._onDataArrival(s, a, t._receivedLength), t._pump(e)
- }
- }).catch(function(e) {
- if (11 !== e.code || !f.default.msedge) {
- t._status = c.LoaderStatus.kError;
- var n = 0,
- i = null;
- if (19 !== e.code && "network error" !== e.message || !(null === t._contentLength || null !== t._contentLength && t._receivedLength < t._contentLength) ? (n = c.LoaderErrors.EXCEPTION, i = {
- code: e.code,
- msg: e.message
- }) : (n = c.LoaderErrors.EARLY_EOF, i = {
- code: e.code,
- msg: "Fetch stream meet Early-EOF"
- }), !t._onError) throw new _.RuntimeException(i.msg);
- t._onError(n, i)
- }
- })
- }
- }]), t
- }(c.BaseLoader);
- n.default = m
- }, {
- "../utils/browser.js": 39,
- "../utils/exception.js": 40,
- "../utils/logger.js": 41,
- "./loader.js": 24
- }],
- 23: [function(e, t, n) {
- "use strict";
-
- function i(e) {
- return e && e.__esModule ? e : {
- default: e
- }
- }
-
- function r(e, t) {
- if (!(e instanceof t)) throw new TypeError("Cannot call a class as a function")
- }
- Object.defineProperty(n, "__esModule", {
- value: !0
- });
- var s = function() {
- function e(e, t) {
- for (var n = 0; n < t.length; n++) {
- var i = t[n];
- i.enumerable = i.enumerable || !1, i.configurable = !0, "value" in i && (i.writable = !0), Object.defineProperty(e, i.key, i)
- }
- }
- return function(t, n, i) {
- return n && e(t.prototype, n), i && e(t, i), t
- }
- }(),
- a = e("../utils/logger.js"),
- o = i(a),
- u = e("./speed-sampler.js"),
- l = i(u),
- d = e("./loader.js"),
- h = e("./fetch-stream-loader.js"),
- f = i(h),
- c = e("./xhr-moz-chunked-loader.js"),
- _ = i(c),
- m = e("./xhr-msstream-loader.js"),
- p = (i(m), e("./xhr-range-loader.js")),
- v = i(p),
- g = e("./websocket-loader.js"),
- y = i(g),
- E = e("./range-seek-handler.js"),
- b = i(E),
- S = e("./param-seek-handler.js"),
- k = i(S),
- L = e("../utils/exception.js"),
- w = function() {
- function e(t, n, i) {
- r(this, e), this.TAG = "IOController", this._config = n, this._extraData = i, this._stashInitialSize = 393216, void 0 != n.stashInitialSize && n.stashInitialSize > 0 && (this._stashInitialSize = n.stashInitialSize), this._stashUsed = 0, this._stashSize = this._stashInitialSize, this._bufferSize = 3145728, this._stashBuffer = new ArrayBuffer(this._bufferSize), this._stashByteStart = 0, this._enableStash = !0, !1 === n.enableStashBuffer && (this._enableStash = !1), this._loader = null, this._loaderClass = null, this._seekHandler = null, this._dataSource = t, this._isWebSocketURL = /wss?:\/\/(.+?)/.test(t.url), this._refTotalLength = t.filesize ? t.filesize : null, this._totalLength = this._refTotalLength, this._fullRequestFlag = !1, this._currentRange = null, this._redirectedURL = null, this._speedNormalized = 0, this._speedSampler = new l.default, this._speedNormalizeList = [64, 128, 256, 384, 512, 768, 1024, 1536, 2048, 3072, 4096], this._isEarlyEofReconnecting = !1, this._paused = !1, this._resumeFrom = 0, this._onDataArrival = null, this._onSeeked = null, this._onError = null, this._onComplete = null, this._onRedirect = null, this._onRecoveredEarlyEof = null, this._selectSeekHandler(), this._selectLoader(), this._createLoader()
- }
- return s(e, [{
- key: "destroy",
- value: function() {
- this._loader.isWorking() && this._loader.abort(), this._loader.destroy(), this._loader = null, this._loaderClass = null, this._dataSource = null, this._stashBuffer = null, this._stashUsed = this._stashSize = this._bufferSize = this._stashByteStart = 0, this._currentRange = null, this._speedSampler = null, this._isEarlyEofReconnecting = !1, this._onDataArrival = null, this._onSeeked = null, this._onError = null, this._onComplete = null, this._onRedirect = null, this._onRecoveredEarlyEof = null, this._extraData = null
- }
- }, {
- key: "isWorking",
- value: function() {
- return this._loader && this._loader.isWorking() && !this._paused
- }
- }, {
- key: "isPaused",
- value: function() {
- return this._paused
- }
- }, {
- key: "_selectSeekHandler",
- value: function() {
- var e = this._config;
- if ("range" === e.seekType) this._seekHandler = new b.default(this._config.rangeLoadZeroStart);
- else if ("param" === e.seekType) {
- var t = e.seekParamStart || "bstart",
- n = e.seekParamEnd || "bend";
- this._seekHandler = new k.default(t, n)
- } else {
- if ("custom" !== e.seekType) throw new L.InvalidArgumentException("Invalid seekType in config: " + e.seekType);
- if ("function" != typeof e.customSeekHandler) throw new L.InvalidArgumentException("Custom seekType specified in config but invalid customSeekHandler!");
- this._seekHandler = new e.customSeekHandler
- }
- }
- }, {
- key: "_selectLoader",
- value: function() {
- if (this._isWebSocketURL) this._loaderClass = y.default;
- else if (f.default.isSupported()) this._loaderClass = f.default;
- else if (_.default.isSupported()) this._loaderClass = _.default;
- else {
- if (!v.default.isSupported()) throw new L.RuntimeException("Your browser doesn't support xhr with arraybuffer responseType!");
- this._loaderClass = v.default
- }
- }
- }, {
- key: "_createLoader",
- value: function() {
- this._loader = new this._loaderClass(this._seekHandler, this._config), !1 === this._loader.needStashBuffer && (this._enableStash = !1), this._loader.onContentLengthKnown = this._onContentLengthKnown.bind(this), this._loader.onURLRedirect = this._onURLRedirect.bind(this), this._loader.onDataArrival = this._onLoaderChunkArrival.bind(this), this._loader.onComplete = this._onLoaderComplete.bind(this), this._loader.onError = this._onLoaderError.bind(this)
- }
- }, {
- key: "open",
- value: function(e) {
- this._currentRange = {
- from: 0,
- to: -1
- }, e && (this._currentRange.from = e), this._speedSampler.reset(), e || (this._fullRequestFlag = !0), this._loader.open(this._dataSource, Object.assign({}, this._currentRange))
- }
- }, {
- key: "abort",
- value: function() {
- this._loader.abort(), this._paused && (this._paused = !1, this._resumeFrom = 0)
- }
- }, {
- key: "pause",
- value: function() {
- this.isWorking() && (this._loader.abort(), 0 !== this._stashUsed ? (this._resumeFrom = this._stashByteStart, this._currentRange.to = this._stashByteStart - 1) : this._resumeFrom = this._currentRange.to + 1, this._stashUsed = 0, this._stashByteStart = 0, this._paused = !0)
- }
- }, {
- key: "resume",
- value: function() {
- if (this._paused) {
- this._paused = !1;
- var e = this._resumeFrom;
- this._resumeFrom = 0, this._internalSeek(e, !0)
- }
- }
- }, {
- key: "seek",
- value: function(e) {
- this._paused = !1, this._stashUsed = 0, this._stashByteStart = 0, this._internalSeek(e, !0)
- }
- }, {
- key: "_internalSeek",
- value: function(e, t) {
- this._loader.isWorking() && this._loader.abort(), this._flushStashBuffer(t), this._loader.destroy(), this._loader = null;
- var n = {
- from: e,
- to: -1
- };
- this._currentRange = {
- from: n.from,
- to: -1
- }, this._speedSampler.reset(), this._stashSize = this._stashInitialSize, this._createLoader(), this._loader.open(this._dataSource, n), this._onSeeked && this._onSeeked()
- }
- }, {
- key: "updateUrl",
- value: function(e) {
- if (!e || "string" != typeof e || 0 === e.length) throw new L.InvalidArgumentException("Url must be a non-empty string!");
- this._dataSource.url = e
- }
- }, {
- key: "_expandBuffer",
- value: function(e) {
- for (var t = this._stashSize; t + 1048576 < e;) t *= 2;
- if ((t += 1048576) !== this._bufferSize) {
- var n = new ArrayBuffer(t);
- if (this._stashUsed > 0) {
- var i = new Uint8Array(this._stashBuffer, 0, this._stashUsed);
- new Uint8Array(n, 0, t).set(i, 0)
- }
- this._stashBuffer = n, this._bufferSize = t
- }
- }
- }, {
- key: "_normalizeSpeed",
- value: function(e) {
- var t = this._speedNormalizeList,
- n = t.length - 1,
- i = 0,
- r = 0,
- s = n;
- if (e < t[0]) return t[0];
- for (; r <= s;) {
- if ((i = r + Math.floor((s - r) / 2)) === n || e >= t[i] && e < t[i + 1]) return t[i];
- t[i] < e ? r = i + 1 : s = i - 1
- }
- }
- }, {
- key: "_adjustStashSize",
- value: function(e) {
- var t = 0;
- (t = this._config.isLive ? e : e < 512 ? e : e >= 512 && e <= 1024 ? Math.floor(1.5 * e) : 2 * e) > 8192 && (t = 8192);
- var n = 1024 * t + 1048576;
- this._bufferSize < n && this._expandBuffer(n), this._stashSize = 1024 * t
- }
- }, {
- key: "_dispatchChunks",
- value: function(e, t) {
- return this._currentRange.to = t + e.byteLength - 1, this._onDataArrival(e, t)
- }
- }, {
- key: "_onURLRedirect",
- value: function(e) {
- this._redirectedURL = e, this._onRedirect && this._onRedirect(e)
- }
- }, {
- key: "_onContentLengthKnown",
- value: function(e) {
- e && this._fullRequestFlag && (this._totalLength = e, this._fullRequestFlag = !1)
- }
- }, {
- key: "_onLoaderChunkArrival",
- value: function(e, t, n) {
- if (!this._onDataArrival) throw new L.IllegalStateException("IOController: No existing consumer (onDataArrival) callback!");
- if (!this._paused) {
- this._isEarlyEofReconnecting && (this._isEarlyEofReconnecting = !1, this._onRecoveredEarlyEof && this._onRecoveredEarlyEof()), this._speedSampler.addBytes(e.byteLength);
- var i = this._speedSampler.lastSecondKBps;
- if (0 !== i) {
- var r = this._normalizeSpeed(i);
- this._speedNormalized !== r && (this._speedNormalized = r, this._adjustStashSize(r))
- }
- if (this._enableStash)
- if (0 === this._stashUsed && 0 === this._stashByteStart && (this._stashByteStart = t), this._stashUsed + e.byteLength <= this._stashSize) {
- var s = new Uint8Array(this._stashBuffer, 0, this._stashSize);
- s.set(new Uint8Array(e), this._stashUsed), this._stashUsed += e.byteLength
- } else {
- var a = new Uint8Array(this._stashBuffer, 0, this._bufferSize);
- if (this._stashUsed > 0) {
- var o = this._stashBuffer.slice(0, this._stashUsed),
- u = this._dispatchChunks(o, this._stashByteStart);
- if (u < o.byteLength) {
- if (u > 0) {
- var l = new Uint8Array(o, u);
- a.set(l, 0), this._stashUsed = l.byteLength, this._stashByteStart += u
- }
- } else this._stashUsed = 0, this._stashByteStart += u;
- this._stashUsed + e.byteLength > this._bufferSize && (this._expandBuffer(this._stashUsed + e.byteLength), a = new Uint8Array(this._stashBuffer, 0, this._bufferSize)), a.set(new Uint8Array(e), this._stashUsed), this._stashUsed += e.byteLength
- } else {
- var d = this._dispatchChunks(e, t);
- if (d < e.byteLength) {
- var h = e.byteLength - d;
- h > this._bufferSize && (this._expandBuffer(h), a = new Uint8Array(this._stashBuffer, 0, this._bufferSize)), a.set(new Uint8Array(e, d), 0), this._stashUsed += h, this._stashByteStart = t + d
- }
- }
- }
- else if (0 === this._stashUsed) {
- var f = this._dispatchChunks(e, t);
- if (f < e.byteLength) {
- var c = e.byteLength - f;
- c > this._bufferSize && this._expandBuffer(c);
- var _ = new Uint8Array(this._stashBuffer, 0, this._bufferSize);
- _.set(new Uint8Array(e, f), 0), this._stashUsed += c, this._stashByteStart = t + f
- }
- } else {
- this._stashUsed + e.byteLength > this._bufferSize && this._expandBuffer(this._stashUsed + e.byteLength);
- var m = new Uint8Array(this._stashBuffer, 0, this._bufferSize);
- m.set(new Uint8Array(e), this._stashUsed), this._stashUsed += e.byteLength;
- var p = this._dispatchChunks(this._stashBuffer.slice(0, this._stashUsed), this._stashByteStart);
- if (p < this._stashUsed && p > 0) {
- var v = new Uint8Array(this._stashBuffer, p);
- m.set(v, 0)
- }
- this._stashUsed -= p, this._stashByteStart += p
- }
- }
- }
- }, {
- key: "_flushStashBuffer",
- value: function(e) {
- if (this._stashUsed > 0) {
- var t = this._stashBuffer.slice(0, this._stashUsed),
- n = this._dispatchChunks(t, this._stashByteStart),
- i = t.byteLength - n;
- if (n < t.byteLength) {
- if (!e) {
- if (n > 0) {
- var r = new Uint8Array(this._stashBuffer, 0, this._bufferSize),
- s = new Uint8Array(t, n);
- r.set(s, 0), this._stashUsed = s.byteLength, this._stashByteStart += n
- }
- return 0
- }
- o.default.w(this.TAG, i + " bytes unconsumed data remain when flush buffer, dropped")
- }
- return this._stashUsed = 0, this._stashByteStart = 0, i
- }
- return 0
- }
- }, {
- key: "_onLoaderComplete",
- value: function(e, t) {
- this._flushStashBuffer(!0), this._onComplete && this._onComplete(this._extraData)
- }
- }, {
- key: "_onLoaderError",
- value: function(e, t) {
- switch (o.default.e(this.TAG, "Loader error, code = " + t.code + ", msg = " + t.msg), this._flushStashBuffer(!1), this._isEarlyEofReconnecting && (this._isEarlyEofReconnecting = !1, e = d.LoaderErrors.UNRECOVERABLE_EARLY_EOF), e) {
- case d.LoaderErrors.EARLY_EOF:
- if (!this._config.isLive && this._totalLength) {
- var n = this._currentRange.to + 1;
- return void(n < this._totalLength && (o.default.w(this.TAG, "Connection lost, trying reconnect..."), this._isEarlyEofReconnecting = !0, this._internalSeek(n, !1)))
- }
- e = d.LoaderErrors.UNRECOVERABLE_EARLY_EOF;
- break;
- case d.LoaderErrors.UNRECOVERABLE_EARLY_EOF:
- case d.LoaderErrors.CONNECTING_TIMEOUT:
- case d.LoaderErrors.HTTP_STATUS_CODE_INVALID:
- case d.LoaderErrors.EXCEPTION:
- }
- if (!this._onError) throw new L.RuntimeException("IOException: " + t.msg);
- this._onError(e, t)
- }
- }, {
- key: "status",
- get: function() {
- return this._loader.status
- }
- }, {
- key: "extraData",
- get: function() {
- return this._extraData
- },
- set: function(e) {
- this._extraData = e
- }
- }, {
- key: "onDataArrival",
- get: function() {
- return this._onDataArrival
- },
- set: function(e) {
- this._onDataArrival = e
- }
- }, {
- key: "onSeeked",
- get: function() {
- return this._onSeeked
- },
- set: function(e) {
- this._onSeeked = e
- }
- }, {
- key: "onError",
- get: function() {
- return this._onError
- },
- set: function(e) {
- this._onError = e
- }
- }, {
- key: "onComplete",
- get: function() {
- return this._onComplete
- },
- set: function(e) {
- this._onComplete = e
- }
- }, {
- key: "onRedirect",
- get: function() {
- return this._onRedirect
- },
- set: function(e) {
- this._onRedirect = e
- }
- }, {
- key: "onRecoveredEarlyEof",
- get: function() {
- return this._onRecoveredEarlyEof
- },
- set: function(e) {
- this._onRecoveredEarlyEof = e
- }
- }, {
- key: "currentURL",
- get: function() {
- return this._dataSource.url
- }
- }, {
- key: "hasRedirect",
- get: function() {
- return null != this._redirectedURL || void 0 != this._dataSource.redirectedURL
- }
- }, {
- key: "currentRedirectedURL",
- get: function() {
- return this._redirectedURL || this._dataSource.redirectedURL
- }
- }, {
- key: "currentSpeed",
- get: function() {
- return this._loaderClass === v.default ? this._loader.currentSpeed : this._speedSampler.lastSecondKBps
- }
- }, {
- key: "loaderType",
- get: function() {
- return this._loader.type
- }
- }]), e
- }();
- n.default = w
- }, {
- "../utils/exception.js": 40,
- "../utils/logger.js": 41,
- "./fetch-stream-loader.js": 22,
- "./loader.js": 24,
- "./param-seek-handler.js": 25,
- "./range-seek-handler.js": 26,
- "./speed-sampler.js": 27,
- "./websocket-loader.js": 28,
- "./xhr-moz-chunked-loader.js": 29,
- "./xhr-msstream-loader.js": 30,
- "./xhr-range-loader.js": 31
- }],
- 24: [function(e, t, n) {
- "use strict";
-
- function i(e, t) {
- if (!(e instanceof t)) throw new TypeError("Cannot call a class as a function")
- }
- Object.defineProperty(n, "__esModule", {
- value: !0
- }), n.BaseLoader = n.LoaderErrors = n.LoaderStatus = void 0;
- var r = function() {
- function e(e, t) {
- for (var n = 0; n < t.length; n++) {
- var i = t[n];
- i.enumerable = i.enumerable || !1, i.configurable = !0, "value" in i && (i.writable = !0), Object.defineProperty(e, i.key, i)
- }
- }
- return function(t, n, i) {
- return n && e(t.prototype, n), i && e(t, i), t
- }
- }(),
- s = e("../utils/exception.js"),
- a = n.LoaderStatus = {
- kIdle: 0,
- kConnecting: 1,
- kBuffering: 2,
- kError: 3,
- kComplete: 4
- };
- n.LoaderErrors = {
- OK: "OK",
- EXCEPTION: "Exception",
- HTTP_STATUS_CODE_INVALID: "HttpStatusCodeInvalid",
- CONNECTING_TIMEOUT: "ConnectingTimeout",
- EARLY_EOF: "EarlyEof",
- UNRECOVERABLE_EARLY_EOF: "UnrecoverableEarlyEof"
- }, n.BaseLoader = function() {
- function e(t) {
- i(this, e), this._type = t || "undefined", this._status = a.kIdle, this._needStash = !1, this._onContentLengthKnown = null, this._onURLRedirect = null, this._onDataArrival = null, this._onError = null, this._onComplete = null
- }
- return r(e, [{
- key: "destroy",
- value: function() {
- this._status = a.kIdle, this._onContentLengthKnown = null, this._onURLRedirect = null, this._onDataArrival = null, this._onError = null, this._onComplete = null
- }
- }, {
- key: "isWorking",
- value: function() {
- return this._status === a.kConnecting || this._status === a.kBuffering
- }
- }, {
- key: "open",
- value: function(e, t) {
- throw new s.NotImplementedException("Unimplemented abstract function!")
- }
- }, {
- key: "abort",
- value: function() {
- throw new s.NotImplementedException("Unimplemented abstract function!")
- }
- }, {
- key: "type",
- get: function() {
- return this._type
- }
- }, {
- key: "status",
- get: function() {
- return this._status
- }
- }, {
- key: "needStashBuffer",
- get: function() {
- return this._needStash
- }
- }, {
- key: "onContentLengthKnown",
- get: function() {
- return this._onContentLengthKnown
- },
- set: function(e) {
- this._onContentLengthKnown = e
- }
- }, {
- key: "onURLRedirect",
- get: function() {
- return this._onURLRedirect
- },
- set: function(e) {
- this._onURLRedirect = e
- }
- }, {
- key: "onDataArrival",
- get: function() {
- return this._onDataArrival
- },
- set: function(e) {
- this._onDataArrival = e
- }
- }, {
- key: "onError",
- get: function() {
- return this._onError
- },
- set: function(e) {
- this._onError = e
- }
- }, {
- key: "onComplete",
- get: function() {
- return this._onComplete
- },
- set: function(e) {
- this._onComplete = e
- }
- }]), e
- }()
- }, {
- "../utils/exception.js": 40
- }],
- 25: [function(e, t, n) {
- "use strict";
-
- function i(e, t) {
- if (!(e instanceof t)) throw new TypeError("Cannot call a class as a function")
- }
- Object.defineProperty(n, "__esModule", {
- value: !0
- });
- var r = function() {
- function e(e, t) {
- for (var n = 0; n < t.length; n++) {
- var i = t[n];
- i.enumerable = i.enumerable || !1, i.configurable = !0, "value" in i && (i.writable = !0), Object.defineProperty(e, i.key, i)
- }
- }
- return function(t, n, i) {
- return n && e(t.prototype, n), i && e(t, i), t
- }
- }(),
- s = function() {
- function e(t, n) {
- i(this, e), this._startName = t, this._endName = n
- }
- return r(e, [{
- key: "getConfig",
- value: function(e, t) {
- var n = e;
- if (0 !== t.from || -1 !== t.to) {
- var i = !0; - 1 === n.indexOf("?") && (n += "?", i = !1), i && (n += "&"), n += this._startName + "=" + t.from.toString(), -1 !== t.to && (n += "&" + this._endName + "=" + t.to.toString())
- }
- return {
- url: n,
- headers: {}
- }
- }
- }, {
- key: "removeURLParameters",
- value: function(e) {
- var t = e.split("?")[0],
- n = void 0,
- i = e.indexOf("?"); - 1 !== i && (n = e.substring(i + 1));
- var r = "";
- if (void 0 != n && n.length > 0)
- for (var s = n.split("&"), a = 0; a < s.length; a++) {
- var o = s[a].split("="),
- u = a > 0;
- o[0] !== this._startName && o[0] !== this._endName && (u && (r += "&"), r += s[a])
- }
- return 0 === r.length ? t : t + "?" + r
- }
- }]), e
- }();
- n.default = s
- }, {}],
- 26: [function(e, t, n) {
- "use strict";
-
- function i(e, t) {
- if (!(e instanceof t)) throw new TypeError("Cannot call a class as a function")
- }
- Object.defineProperty(n, "__esModule", {
- value: !0
- });
- var r = function() {
- function e(e, t) {
- for (var n = 0; n < t.length; n++) {
- var i = t[n];
- i.enumerable = i.enumerable || !1, i.configurable = !0, "value" in i && (i.writable = !0), Object.defineProperty(e, i.key, i)
- }
- }
- return function(t, n, i) {
- return n && e(t.prototype, n), i && e(t, i), t
- }
- }(),
- s = function() {
- function e(t) {
- i(this, e), this._zeroStart = t || !1
- }
- return r(e, [{
- key: "getConfig",
- value: function(e, t) {
- var n = {};
- if (0 !== t.from || -1 !== t.to) {
- var i = void 0;
- i = -1 !== t.to ? "bytes=" + t.from.toString() + "-" + t.to.toString() : "bytes=" + t.from.toString() + "-", n.Range = i
- } else this._zeroStart && (n.Range = "bytes=0-");
- return {
- url: e,
- headers: n
- }
- }
- }, {
- key: "removeURLParameters",
- value: function(e) {
- return e
- }
- }]), e
- }();
- n.default = s
- }, {}],
- 27: [function(e, t, n) {
- "use strict";
-
- function i(e, t) {
- if (!(e instanceof t)) throw new TypeError("Cannot call a class as a function")
- }
- Object.defineProperty(n, "__esModule", {
- value: !0
- });
- var r = function() {
- function e(e, t) {
- for (var n = 0; n < t.length; n++) {
- var i = t[n];
- i.enumerable = i.enumerable || !1, i.configurable = !0, "value" in i && (i.writable = !0), Object.defineProperty(e, i.key, i)
- }
- }
- return function(t, n, i) {
- return n && e(t.prototype, n), i && e(t, i), t
- }
- }(),
- s = function() {
- function e() {
- i(this, e), this._firstCheckpoint = 0, this._lastCheckpoint = 0, this._intervalBytes = 0, this._totalBytes = 0, this._lastSecondBytes = 0, self.performance && self.performance.now ? this._now = self.performance.now.bind(self.performance) : this._now = Date.now
- }
- return r(e, [{
- key: "reset",
- value: function() {
- this._firstCheckpoint = this._lastCheckpoint = 0, this._totalBytes = this._intervalBytes = 0, this._lastSecondBytes = 0
- }
- }, {
- key: "addBytes",
- value: function(e) {
- 0 === this._firstCheckpoint ? (this._firstCheckpoint = this._now(), this._lastCheckpoint = this._firstCheckpoint, this._intervalBytes += e, this._totalBytes += e) : this._now() - this._lastCheckpoint < 1e3 ? (this._intervalBytes += e, this._totalBytes += e) : (this._lastSecondBytes = this._intervalBytes, this._intervalBytes = e, this._totalBytes += e, this._lastCheckpoint = this._now())
- }
- }, {
- key: "currentKBps",
- get: function() {
- this.addBytes(0);
- var e = (this._now() - this._lastCheckpoint) / 1e3;
- return 0 == e && (e = 1), this._intervalBytes / e / 1024
- }
- }, {
- key: "lastSecondKBps",
- get: function() {
- return this.addBytes(0), 0 !== this._lastSecondBytes ? this._lastSecondBytes / 1024 : this._now() - this._lastCheckpoint >= 500 ? this.currentKBps : 0
- }
- }, {
- key: "averageKBps",
- get: function() {
- var e = (this._now() - this._firstCheckpoint) / 1e3;
- return this._totalBytes / e / 1024
- }
- }]), e
- }();
- n.default = s
- }, {}],
- 28: [function(e, t, n) {
- "use strict";
-
- function i(e, t) {
- if (!(e instanceof t)) throw new TypeError("Cannot call a class as a function")
- }
-
- function r(e, t) {
- if (!e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
- return !t || "object" != typeof t && "function" != typeof t ? e : t
- }
-
- function s(e, t) {
- if ("function" != typeof t && null !== t) throw new TypeError("Super expression must either be null or a function, not " + typeof t);
- e.prototype = Object.create(t && t.prototype, {
- constructor: {
- value: e,
- enumerable: !1,
- writable: !0,
- configurable: !0
- }
- }), t && (Object.setPrototypeOf ? Object.setPrototypeOf(e, t) : e.__proto__ = t)
- }
- Object.defineProperty(n, "__esModule", {
- value: !0
- });
- var a = function e(t, n, i) {
- null === t && (t = Function.prototype);
- var r = Object.getOwnPropertyDescriptor(t, n);
- if (void 0 === r) {
- var s = Object.getPrototypeOf(t);
- return null === s ? void 0 : e(s, n, i)
- }
- if ("value" in r) return r.value;
- var a = r.get;
- if (void 0 !== a) return a.call(i)
- },
- o = function() {
- function e(e, t) {
- for (var n = 0; n < t.length; n++) {
- var i = t[n];
- i.enumerable = i.enumerable || !1, i.configurable = !0, "value" in i && (i.writable = !0), Object.defineProperty(e, i.key, i)
- }
- }
- return function(t, n, i) {
- return n && e(t.prototype, n), i && e(t, i), t
- }
- }(),
- u = e("../utils/logger.js"),
- l = (function(e) {
- e && e.__esModule
- }(u), e("./loader.js")),
- d = e("../utils/exception.js"),
- h = function(e) {
- function t() {
- i(this, t);
- var e = r(this, (t.__proto__ || Object.getPrototypeOf(t)).call(this, "websocket-loader"));
- return e.TAG = "WebSocketLoader", e._needStash = !0, e._ws = null, e._requestAbort = !1, e._receivedLength = 0, e
- }
- return s(t, e), o(t, null, [{
- key: "isSupported",
- value: function() {
- try {
- return void 0 !== self.WebSocket
- } catch (e) {
- return !1
- }
- }
- }]), o(t, [{
- key: "destroy",
- value: function() {
- this._ws && this.abort(), a(t.prototype.__proto__ || Object.getPrototypeOf(t.prototype), "destroy", this).call(this)
- }
- }, {
- key: "open",
- value: function(e) {
- try {
- var t = this._ws = new self.WebSocket(e.url);
- t.binaryType = "arraybuffer", t.onopen = this._onWebSocketOpen.bind(this), t.onclose = this._onWebSocketClose.bind(this), t.onmessage = this._onWebSocketMessage.bind(this), t.onerror = this._onWebSocketError.bind(this), this._status = l.LoaderStatus.kConnecting
- } catch (e) {
- this._status = l.LoaderStatus.kError;
- var n = {
- code: e.code,
- msg: e.message
- };
- if (!this._onError) throw new d.RuntimeException(n.msg);
- this._onError(l.LoaderErrors.EXCEPTION, n)
- }
- }
- }, {
- key: "abort",
- value: function() {
- var e = this._ws;
- !e || 0 !== e.readyState && 1 !== e.readyState || (this._requestAbort = !0, e.close()), this._ws = null, this._status = l.LoaderStatus.kComplete
- }
- }, {
- key: "_onWebSocketOpen",
- value: function(e) {
- this._status = l.LoaderStatus.kBuffering
- }
- }, {
- key: "_onWebSocketClose",
- value: function(e) {
- if (!0 === this._requestAbort) return void(this._requestAbort = !1);
- this._status = l.LoaderStatus.kComplete, this._onComplete && this._onComplete(0, this._receivedLength - 1)
- }
- }, {
- key: "_onWebSocketMessage",
- value: function(e) {
- var t = this;
- if (e.data instanceof ArrayBuffer) this._dispatchArrayBuffer(e.data);
- else if (e.data instanceof Blob) {
- var n = new FileReader;
- n.onload = function() {
- t._dispatchArrayBuffer(n.result)
- }, n.readAsArrayBuffer(e.data)
- } else {
- this._status = l.LoaderStatus.kError;
- var i = {
- code: -1,
- msg: "Unsupported WebSocket message type: " + e.data.constructor.name
- };
- if (!this._onError) throw new d.RuntimeException(i.msg);
- this._onError(l.LoaderErrors.EXCEPTION, i)
- }
- }
- }, {
- key: "_dispatchArrayBuffer",
- value: function(e) {
- var t = e,
- n = this._receivedLength;
- this._receivedLength += t.byteLength, this._onDataArrival && this._onDataArrival(t, n, this._receivedLength)
- }
- }, {
- key: "_onWebSocketError",
- value: function(e) {
- this._status = l.LoaderStatus.kError;
- var t = {
- code: e.code,
- msg: e.message
- };
- if (!this._onError) throw new d.RuntimeException(t.msg);
- this._onError(l.LoaderErrors.EXCEPTION, t)
- }
- }]), t
- }(l.BaseLoader);
- n.default = h
- }, {
- "../utils/exception.js": 40,
- "../utils/logger.js": 41,
- "./loader.js": 24
- }],
- 29: [function(e, t, n) {
- "use strict";
-
- function i(e, t) {
- if (!(e instanceof t)) throw new TypeError("Cannot call a class as a function")
- }
-
- function r(e, t) {
- if (!e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
- return !t || "object" != typeof t && "function" != typeof t ? e : t
- }
-
- function s(e, t) {
- if ("function" != typeof t && null !== t) throw new TypeError("Super expression must either be null or a function, not " + typeof t);
- e.prototype = Object.create(t && t.prototype, {
- constructor: {
- value: e,
- enumerable: !1,
- writable: !0,
- configurable: !0
- }
- }), t && (Object.setPrototypeOf ? Object.setPrototypeOf(e, t) : e.__proto__ = t)
- }
- Object.defineProperty(n, "__esModule", {
- value: !0
- });
- var a = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(e) {
- return typeof e
- } : function(e) {
- return e && "function" == typeof Symbol && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : typeof e
- },
- o = function e(t, n, i) {
- null === t && (t = Function.prototype);
- var r = Object.getOwnPropertyDescriptor(t, n);
- if (void 0 === r) {
- var s = Object.getPrototypeOf(t);
- return null === s ? void 0 : e(s, n, i)
- }
- if ("value" in r) return r.value;
- var a = r.get;
- if (void 0 !== a) return a.call(i)
- },
- u = function() {
- function e(e, t) {
- for (var n = 0; n < t.length; n++) {
- var i = t[n];
- i.enumerable = i.enumerable || !1, i.configurable = !0, "value" in i && (i.writable = !0), Object.defineProperty(e, i.key, i)
- }
- }
- return function(t, n, i) {
- return n && e(t.prototype, n), i && e(t, i), t
- }
- }(),
- l = e("../utils/logger.js"),
- d = function(e) {
- return e && e.__esModule ? e : {
- default: e
- }
- }(l),
- h = e("./loader.js"),
- f = e("../utils/exception.js"),
- c = function(e) {
- function t(e, n) {
- i(this, t);
- var s = r(this, (t.__proto__ || Object.getPrototypeOf(t)).call(this, "xhr-moz-chunked-loader"));
- return s.TAG = "MozChunkedLoader", s._seekHandler = e, s._config = n, s._needStash = !0, s._xhr = null, s._requestAbort = !1, s._contentLength = null, s._receivedLength = 0, s
- }
- return s(t, e), u(t, null, [{
- key: "isSupported",
- value: function() {
- try {
- var e = new XMLHttpRequest;
- return e.open("GET", "https://example.com", !0), e.responseType = "moz-chunked-arraybuffer", "moz-chunked-arraybuffer" === e.responseType
- } catch (e) {
- return d.default.w("MozChunkedLoader", e.message), !1
- }
- }
- }]), u(t, [{
- key: "destroy",
- value: function() {
- this.isWorking() && this.abort(), this._xhr && (this._xhr.onreadystatechange = null, this._xhr.onprogress = null, this._xhr.onloadend = null, this._xhr.onerror = null, this._xhr = null), o(t.prototype.__proto__ || Object.getPrototypeOf(t.prototype), "destroy", this).call(this)
- }
- }, {
- key: "open",
- value: function(e, t) {
- this._dataSource = e, this._range = t;
- var n = e.url;
- this._config.reuseRedirectedURL && void 0 != e.redirectedURL && (n = e.redirectedURL);
- var i = this._seekHandler.getConfig(n, t);
- this._requestURL = i.url;
- var r = this._xhr = new XMLHttpRequest;
- if (r.open("GET", i.url, !0), r.responseType = "moz-chunked-arraybuffer", r.onreadystatechange = this._onReadyStateChange.bind(this), r.onprogress = this._onProgress.bind(this), r.onloadend = this._onLoadEnd.bind(this), r.onerror = this._onXhrError.bind(this), e.withCredentials && (r.withCredentials = !0), "object" === a(i.headers)) {
- var s = i.headers;
- for (var o in s) s.hasOwnProperty(o) && r.setRequestHeader(o, s[o])
- }
- this._status = h.LoaderStatus.kConnecting, r.send()
- }
- }, {
- key: "abort",
- value: function() {
- this._requestAbort = !0, this._xhr && this._xhr.abort(), this._status = h.LoaderStatus.kComplete
- }
- }, {
- key: "_onReadyStateChange",
- value: function(e) {
- var t = e.target;
- if (2 === t.readyState) {
- if (void 0 != t.responseURL && t.responseURL !== this._requestURL && this._onURLRedirect) {
- var n = this._seekHandler.removeURLParameters(t.responseURL);
- this._onURLRedirect(n)
- }
- if (0 !== t.status && (t.status < 200 || t.status > 299)) {
- if (this._status = h.LoaderStatus.kError, !this._onError) throw new f.RuntimeException("MozChunkedLoader: Http code invalid, " + t.status + " " + t.statusText);
- this._onError(h.LoaderErrors.HTTP_STATUS_CODE_INVALID, {
- code: t.status,
- msg: t.statusText
- })
- } else this._status = h.LoaderStatus.kBuffering
- }
- }
- }, {
- key: "_onProgress",
- value: function(e) {
- if (this._status !== h.LoaderStatus.kError) {
- null === this._contentLength && null !== e.total && 0 !== e.total && (this._contentLength = e.total, this._onContentLengthKnown && this._onContentLengthKnown(this._contentLength));
- var t = e.target.response,
- n = this._range.from + this._receivedLength;
- this._receivedLength += t.byteLength, this._onDataArrival && this._onDataArrival(t, n, this._receivedLength)
- }
- }
- }, {
- key: "_onLoadEnd",
- value: function(e) {
- if (!0 === this._requestAbort) return void(this._requestAbort = !1);
- this._status !== h.LoaderStatus.kError && (this._status = h.LoaderStatus.kComplete, this._onComplete && this._onComplete(this._range.from, this._range.from + this._receivedLength - 1))
- }
- }, {
- key: "_onXhrError",
- value: function(e) {
- this._status = h.LoaderStatus.kError;
- var t = 0,
- n = null;
- if (this._contentLength && e.loaded < this._contentLength ? (t = h.LoaderErrors.EARLY_EOF, n = {
- code: -1,
- msg: "Moz-Chunked stream meet Early-Eof"
- }) : (t = h.LoaderErrors.EXCEPTION, n = {
- code: -1,
- msg: e.constructor.name + " " + e.type
- }), !this._onError) throw new f.RuntimeException(n.msg);
- this._onError(t, n)
- }
- }]), t
- }(h.BaseLoader);
- n.default = c
- }, {
- "../utils/exception.js": 40,
- "../utils/logger.js": 41,
- "./loader.js": 24
- }],
- 30: [function(e, t, n) {
- "use strict";
-
- function i(e, t) {
- if (!(e instanceof t)) throw new TypeError("Cannot call a class as a function")
- }
-
- function r(e, t) {
- if (!e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
- return !t || "object" != typeof t && "function" != typeof t ? e : t
- }
-
- function s(e, t) {
- if ("function" != typeof t && null !== t) throw new TypeError("Super expression must either be null or a function, not " + typeof t);
- e.prototype = Object.create(t && t.prototype, {
- constructor: {
- value: e,
- enumerable: !1,
- writable: !0,
- configurable: !0
- }
- }), t && (Object.setPrototypeOf ? Object.setPrototypeOf(e, t) : e.__proto__ = t)
- }
- Object.defineProperty(n, "__esModule", {
- value: !0
- });
- var a = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(e) {
- return typeof e
- } : function(e) {
- return e && "function" == typeof Symbol && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : typeof e
- },
- o = function e(t, n, i) {
- null === t && (t = Function.prototype);
- var r = Object.getOwnPropertyDescriptor(t, n);
- if (void 0 === r) {
- var s = Object.getPrototypeOf(t);
- return null === s ? void 0 : e(s, n, i)
- }
- if ("value" in r) return r.value;
- var a = r.get;
- if (void 0 !== a) return a.call(i)
- },
- u = function() {
- function e(e, t) {
- for (var n = 0; n < t.length; n++) {
- var i = t[n];
- i.enumerable = i.enumerable || !1, i.configurable = !0, "value" in i && (i.writable = !0), Object.defineProperty(e, i.key, i)
- }
- }
- return function(t, n, i) {
- return n && e(t.prototype, n), i && e(t, i), t
- }
- }(),
- l = e("../utils/logger.js"),
- d = function(e) {
- return e && e.__esModule ? e : {
- default: e
- }
- }(l),
- h = e("./loader.js"),
- f = e("../utils/exception.js"),
- c = function(e) {
- function t(e, n) {
- i(this, t);
- var s = r(this, (t.__proto__ || Object.getPrototypeOf(t)).call(this, "xhr-msstream-loader"));
- return s.TAG = "MSStreamLoader", s._seekHandler = e, s._config = n, s._needStash = !0, s._xhr = null, s._reader = null, s._totalRange = null, s._currentRange = null, s._currentRequestURL = null, s._currentRedirectedURL = null, s._contentLength = null, s._receivedLength = 0, s._bufferLimit = 16777216, s._lastTimeBufferSize = 0, s._isReconnecting = !1, s
- }
- return s(t, e), u(t, null, [{
- key: "isSupported",
- value: function() {
- try {
- if (void 0 === self.MSStream || void 0 === self.MSStreamReader) return !1;
- var e = new XMLHttpRequest;
- return e.open("GET", "https://example.com", !0), e.responseType = "ms-stream", "ms-stream" === e.responseType
- } catch (e) {
- return d.default.w("MSStreamLoader", e.message), !1
- }
- }
- }]), u(t, [{
- key: "destroy",
- value: function() {
- this.isWorking() && this.abort(), this._reader && (this._reader.onprogress = null, this._reader.onload = null, this._reader.onerror = null, this._reader = null), this._xhr && (this._xhr.onreadystatechange = null, this._xhr = null), o(t.prototype.__proto__ || Object.getPrototypeOf(t.prototype), "destroy", this).call(this)
- }
- }, {
- key: "open",
- value: function(e, t) {
- this._internalOpen(e, t, !1)
- }
- }, {
- key: "_internalOpen",
- value: function(e, t, n) {
- this._dataSource = e, n ? this._currentRange = t : this._totalRange = t;
- var i = e.url;
- this._config.reuseRedirectedURL && (void 0 != this._currentRedirectedURL ? i = this._currentRedirectedURL : void 0 != e.redirectedURL && (i = e.redirectedURL));
- var r = this._seekHandler.getConfig(i, t);
- this._currentRequestURL = r.url;
- var s = this._reader = new self.MSStreamReader;
- s.onprogress = this._msrOnProgress.bind(this), s.onload = this._msrOnLoad.bind(this), s.onerror = this._msrOnError.bind(this);
- var o = this._xhr = new XMLHttpRequest;
- if (o.open("GET", r.url, !0), o.responseType = "ms-stream", o.onreadystatechange = this._xhrOnReadyStateChange.bind(this), o.onerror = this._xhrOnError.bind(this), e.withCredentials && (o.withCredentials = !0), "object" === a(r.headers)) {
- var u = r.headers;
- for (var l in u) u.hasOwnProperty(l) && o.setRequestHeader(l, u[l])
- }
- this._isReconnecting ? this._isReconnecting = !1 : this._status = h.LoaderStatus.kConnecting, o.send()
- }
- }, {
- key: "abort",
- value: function() {
- this._internalAbort(), this._status = h.LoaderStatus.kComplete
- }
- }, {
- key: "_internalAbort",
- value: function() {
- this._reader && (1 === this._reader.readyState && this._reader.abort(), this._reader.onprogress = null, this._reader.onload = null, this._reader.onerror = null, this._reader = null), this._xhr && (this._xhr.abort(), this._xhr.onreadystatechange = null, this._xhr = null)
- }
- }, {
- key: "_xhrOnReadyStateChange",
- value: function(e) {
- var t = e.target;
- if (2 === t.readyState)
- if (t.status >= 200 && t.status <= 299) {
- if (this._status = h.LoaderStatus.kBuffering, void 0 != t.responseURL) {
- var n = this._seekHandler.removeURLParameters(t.responseURL);
- t.responseURL !== this._currentRequestURL && n !== this._currentRedirectedURL && (this._currentRedirectedURL = n, this._onURLRedirect && this._onURLRedirect(n))
- }
- var i = t.getResponseHeader("Content-Length");
- if (null != i && null == this._contentLength) {
- var r = parseInt(i);
- r > 0 && (this._contentLength = r, this._onContentLengthKnown && this._onContentLengthKnown(this._contentLength))
- }
- } else {
- if (this._status = h.LoaderStatus.kError, !this._onError) throw new f.RuntimeException("MSStreamLoader: Http code invalid, " + t.status + " " + t.statusText);
- this._onError(h.LoaderErrors.HTTP_STATUS_CODE_INVALID, {
- code: t.status,
- msg: t.statusText
- })
- }
- else if (3 === t.readyState && t.status >= 200 && t.status <= 299) {
- this._status = h.LoaderStatus.kBuffering;
- var s = t.response;
- this._reader.readAsArrayBuffer(s)
- }
- }
- }, {
- key: "_xhrOnError",
- value: function(e) {
- this._status = h.LoaderStatus.kError;
- var t = h.LoaderErrors.EXCEPTION,
- n = {
- code: -1,
- msg: e.constructor.name + " " + e.type
- };
- if (!this._onError) throw new f.RuntimeException(n.msg);
- this._onError(t, n)
- }
- }, {
- key: "_msrOnProgress",
- value: function(e) {
- var t = e.target,
- n = t.result;
- if (null == n) return void this._doReconnectIfNeeded();
- var i = n.slice(this._lastTimeBufferSize);
- this._lastTimeBufferSize = n.byteLength;
- var r = this._totalRange.from + this._receivedLength;
- this._receivedLength += i.byteLength, this._onDataArrival && this._onDataArrival(i, r, this._receivedLength), n.byteLength >= this._bufferLimit && (d.default.v(this.TAG, "MSStream buffer exceeded max size near " + (r + i.byteLength) + ", reconnecting..."), this._doReconnectIfNeeded())
- }
- }, {
- key: "_doReconnectIfNeeded",
- value: function() {
- if (null == this._contentLength || this._receivedLength < this._contentLength) {
- this._isReconnecting = !0, this._lastTimeBufferSize = 0, this._internalAbort();
- var e = {
- from: this._totalRange.from + this._receivedLength,
- to: -1
- };
- this._internalOpen(this._dataSource, e, !0)
- }
- }
- }, {
- key: "_msrOnLoad",
- value: function(e) {
- this._status = h.LoaderStatus.kComplete, this._onComplete && this._onComplete(this._totalRange.from, this._totalRange.from + this._receivedLength - 1)
- }
- }, {
- key: "_msrOnError",
- value: function(e) {
- this._status = h.LoaderStatus.kError;
- var t = 0,
- n = null;
- if (this._contentLength && this._receivedLength < this._contentLength ? (t = h.LoaderErrors.EARLY_EOF, n = {
- code: -1,
- msg: "MSStream meet Early-Eof"
- }) : (t = h.LoaderErrors.EARLY_EOF, n = {
- code: -1,
- msg: e.constructor.name + " " + e.type
- }), !this._onError) throw new f.RuntimeException(n.msg);
- this._onError(t, n)
- }
- }]), t
- }(h.BaseLoader);
- n.default = c
- }, {
- "../utils/exception.js": 40,
- "../utils/logger.js": 41,
- "./loader.js": 24
- }],
- 31: [function(e, t, n) {
- "use strict";
-
- function i(e) {
- return e && e.__esModule ? e : {
- default: e
- }
- }
-
- function r(e, t) {
- if (!(e instanceof t)) throw new TypeError("Cannot call a class as a function")
- }
-
- function s(e, t) {
- if (!e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
- return !t || "object" != typeof t && "function" != typeof t ? e : t
- }
-
- function a(e, t) {
- if ("function" != typeof t && null !== t) throw new TypeError("Super expression must either be null or a function, not " + typeof t);
- e.prototype = Object.create(t && t.prototype, {
- constructor: {
- value: e,
- enumerable: !1,
- writable: !0,
- configurable: !0
- }
- }), t && (Object.setPrototypeOf ? Object.setPrototypeOf(e, t) : e.__proto__ = t)
- }
- Object.defineProperty(n, "__esModule", {
- value: !0
- });
- var o = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(e) {
- return typeof e
- } : function(e) {
- return e && "function" == typeof Symbol && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : typeof e
- },
- u = function e(t, n, i) {
- null === t && (t = Function.prototype);
- var r = Object.getOwnPropertyDescriptor(t, n);
- if (void 0 === r) {
- var s = Object.getPrototypeOf(t);
- return null === s ? void 0 : e(s, n, i)
- }
- if ("value" in r) return r.value;
- var a = r.get;
- if (void 0 !== a) return a.call(i)
- },
- l = function() {
- function e(e, t) {
- for (var n = 0; n < t.length; n++) {
- var i = t[n];
- i.enumerable = i.enumerable || !1, i.configurable = !0, "value" in i && (i.writable = !0), Object.defineProperty(e, i.key, i)
- }
- }
- return function(t, n, i) {
- return n && e(t.prototype, n), i && e(t, i), t
- }
- }(),
- d = e("../utils/logger.js"),
- h = i(d),
- f = e("./speed-sampler.js"),
- c = i(f),
- _ = e("./loader.js"),
- m = e("../utils/exception.js"),
- p = function(e) {
- function t(e, n) {
- r(this, t);
- var i = s(this, (t.__proto__ || Object.getPrototypeOf(t)).call(this, "xhr-range-loader"));
- return i.TAG = "RangeLoader", i._seekHandler = e, i._config = n, i._needStash = !1, i._chunkSizeKBList = [128, 256, 384, 512, 768, 1024, 1536, 2048, 3072, 4096, 5120, 6144, 7168, 8192], i._currentChunkSizeKB = 384, i._currentSpeedNormalized = 0, i._zeroSpeedChunkCount = 0, i._xhr = null, i._speedSampler = new c.default, i._requestAbort = !1, i._waitForTotalLength = !1, i._totalLengthReceived = !1, i._currentRequestURL = null, i._currentRedirectedURL = null, i._currentRequestRange = null, i._totalLength = null, i._contentLength = null, i._receivedLength = 0, i._lastTimeLoaded = 0, i
- }
- return a(t, e), l(t, null, [{
- key: "isSupported",
- value: function() {
- try {
- var e = new XMLHttpRequest;
- return e.open("GET", "https://example.com", !0), e.responseType = "arraybuffer", "arraybuffer" === e.responseType
- } catch (e) {
- return h.default.w("RangeLoader", e.message), !1
- }
- }
- }]), l(t, [{
- key: "destroy",
- value: function() {
- this.isWorking() && this.abort(), this._xhr && (this._xhr.onreadystatechange = null, this._xhr.onprogress = null, this._xhr.onload = null, this._xhr.onerror = null, this._xhr = null), u(t.prototype.__proto__ || Object.getPrototypeOf(t.prototype), "destroy", this).call(this)
- }
- }, {
- key: "open",
- value: function(e, t) {
- this._dataSource = e, this._range = t, this._status = _.LoaderStatus.kConnecting;
- var n = !1;
- void 0 != this._dataSource.filesize && 0 !== this._dataSource.filesize && (n = !0, this._totalLength = this._dataSource.filesize), this._totalLengthReceived || n ? this._openSubRange() : (this._waitForTotalLength = !0, this._internalOpen(this._dataSource, {
- from: 0,
- to: -1
- }))
- }
- }, {
- key: "_openSubRange",
- value: function() {
- var e = 1024 * this._currentChunkSizeKB,
- t = this._range.from + this._receivedLength,
- n = t + e;
- null != this._contentLength && n - this._range.from >= this._contentLength && (n = this._range.from + this._contentLength - 1), this._currentRequestRange = {
- from: t,
- to: n
- }, this._internalOpen(this._dataSource, this._currentRequestRange)
- }
- }, {
- key: "_internalOpen",
- value: function(e, t) {
- this._lastTimeLoaded = 0;
- var n = e.url;
- this._config.reuseRedirectedURL && (void 0 != this._currentRedirectedURL ? n = this._currentRedirectedURL : void 0 != e.redirectedURL && (n = e.redirectedURL));
- var i = this._seekHandler.getConfig(n, t);
- this._currentRequestURL = i.url;
- var r = this._xhr = new XMLHttpRequest;
- if (r.open("GET", i.url, !0), r.responseType = "arraybuffer", r.onreadystatechange = this._onReadyStateChange.bind(this), r.onprogress = this._onProgress.bind(this), r.onload = this._onLoad.bind(this), r.onerror = this._onXhrError.bind(this), e.withCredentials && (r.withCredentials = !0), "object" === o(i.headers)) {
- var s = i.headers;
- for (var a in s) s.hasOwnProperty(a) && r.setRequestHeader(a, s[a])
- }
- r.send()
- }
- }, {
- key: "abort",
- value: function() {
- this._requestAbort = !0, this._internalAbort(), this._status = _.LoaderStatus.kComplete
- }
- }, {
- key: "_internalAbort",
- value: function() {
- this._xhr && (this._xhr.onreadystatechange = null, this._xhr.onprogress = null, this._xhr.onload = null, this._xhr.onerror = null, this._xhr.abort(), this._xhr = null)
- }
- }, {
- key: "_onReadyStateChange",
- value: function(e) {
- var t = e.target;
- if (2 === t.readyState) {
- if (void 0 != t.responseURL) {
- var n = this._seekHandler.removeURLParameters(t.responseURL);
- t.responseURL !== this._currentRequestURL && n !== this._currentRedirectedURL && (this._currentRedirectedURL = n, this._onURLRedirect && this._onURLRedirect(n))
- }
- if (t.status >= 200 && t.status <= 299) {
- if (this._waitForTotalLength) return;
- this._status = _.LoaderStatus.kBuffering
- } else {
- if (this._status = _.LoaderStatus.kError, !this._onError) throw new m.RuntimeException("RangeLoader: Http code invalid, " + t.status + " " + t.statusText);
- this._onError(_.LoaderErrors.HTTP_STATUS_CODE_INVALID, {
- code: t.status,
- msg: t.statusText
- })
- }
- }
- }
- }, {
- key: "_onProgress",
- value: function(e) {
- if (this._status !== _.LoaderStatus.kError) {
- if (null === this._contentLength) {
- var t = !1;
- if (this._waitForTotalLength) {
- this._waitForTotalLength = !1, this._totalLengthReceived = !0, t = !0;
- var n = e.total;
- this._internalAbort(), null != n & 0 !== n && (this._totalLength = n)
- }
- if (-1 === this._range.to ? this._contentLength = this._totalLength - this._range.from : this._contentLength = this._range.to - this._range.from + 1, t) return void this._openSubRange();
- this._onContentLengthKnown && this._onContentLengthKnown(this._contentLength)
- }
- var i = e.loaded - this._lastTimeLoaded;
- this._lastTimeLoaded = e.loaded, this._speedSampler.addBytes(i)
- }
- }
- }, {
- key: "_normalizeSpeed",
- value: function(e) {
- var t = this._chunkSizeKBList,
- n = t.length - 1,
- i = 0,
- r = 0,
- s = n;
- if (e < t[0]) return t[0];
- for (; r <= s;) {
- if ((i = r + Math.floor((s - r) / 2)) === n || e >= t[i] && e < t[i + 1]) return t[i];
- t[i] < e ? r = i + 1 : s = i - 1
- }
- }
- }, {
- key: "_onLoad",
- value: function(e) {
- if (this._status !== _.LoaderStatus.kError) {
- if (this._waitForTotalLength) return void(this._waitForTotalLength = !1);
- this._lastTimeLoaded = 0;
- var t = this._speedSampler.lastSecondKBps;
- if (0 === t && ++this._zeroSpeedChunkCount >= 3 && (t = this._speedSampler.currentKBps), 0 !== t) {
- var n = this._normalizeSpeed(t);
- this._currentSpeedNormalized !== n && (this._currentSpeedNormalized = n, this._currentChunkSizeKB = n)
- }
- var i = e.target.response,
- r = this._range.from + this._receivedLength;
- this._receivedLength += i.byteLength;
- var s = !1;
- null != this._contentLength && this._receivedLength < this._contentLength ? this._openSubRange() : s = !0, this._onDataArrival && this._onDataArrival(i, r, this._receivedLength), s && (this._status = _.LoaderStatus.kComplete, this._onComplete && this._onComplete(this._range.from, this._range.from + this._receivedLength - 1))
- }
- }
- }, {
- key: "_onXhrError",
- value: function(e) {
- this._status = _.LoaderStatus.kError;
- var t = 0,
- n = null;
- if (this._contentLength && this._receivedLength > 0 && this._receivedLength < this._contentLength ? (t = _.LoaderErrors.EARLY_EOF, n = {
- code: -1,
- msg: "RangeLoader meet Early-Eof"
- }) : (t = _.LoaderErrors.EXCEPTION, n = {
- code: -1,
- msg: e.constructor.name + " " + e.type
- }), !this._onError) throw new m.RuntimeException(n.msg);
- this._onError(t, n)
- }
- }, {
- key: "currentSpeed",
- get: function() {
- return this._speedSampler.lastSecondKBps
- }
- }]), t
- }(_.BaseLoader);
- n.default = p
- }, {
- "../utils/exception.js": 40,
- "../utils/logger.js": 41,
- "./loader.js": 24,
- "./speed-sampler.js": 27
- }],
- 32: [function(e, t, n) {
- "use strict";
-
- function i(e) {
- return e && e.__esModule ? e : {
- default: e
- }
- }
-
- function r(e, t) {
- if (!(e instanceof t)) throw new TypeError("Cannot call a class as a function")
- }
- Object.defineProperty(n, "__esModule", {
- value: !0
- });
- var s = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(e) {
- return typeof e
- } : function(e) {
- return e && "function" == typeof Symbol && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : typeof e
- },
- a = function() {
- function e(e, t) {
- for (var n = 0; n < t.length; n++) {
- var i = t[n];
- i.enumerable = i.enumerable || !1, i.configurable = !0, "value" in i && (i.writable = !0), Object.defineProperty(e, i.key, i)
- }
- }
- return function(t, n, i) {
- return n && e(t.prototype, n), i && e(t, i), t
- }
- }(),
- o = e("events"),
- u = i(o),
- l = e("../utils/logger.js"),
- d = i(l),
- h = e("../utils/browser.js"),
- f = i(h),
- c = e("./player-events.js"),
- _ = i(c),
- m = e("../core/transmuxer.js"),
- p = i(m),
- v = e("../core/transmuxing-events.js"),
- g = i(v),
- y = e("../core/mse-controller.js"),
- E = i(y),
- b = e("../core/mse-events.js"),
- S = i(b),
- k = e("./player-errors.js"),
- L = e("../config.js"),
- w = e("../utils/exception.js"),
- R = function() {
- function e(t, n) {
- if (r(this, e), this.TAG = "FlvPlayer", this._type = "FlvPlayer", this._emitter = new u.default, this._config = (0, L.createDefaultConfig)(), "object" === (void 0 === n ? "undefined" : s(n)) && Object.assign(this._config, n), "flv" !== t.type.toLowerCase()) throw new w.InvalidArgumentException("FlvPlayer requires an flv MediaDataSource input!");
- !0 === t.isLive && (this._config.isLive = !0), this.e = {
- onvLoadedMetadata: this._onvLoadedMetadata.bind(this),
- onvSeeking: this._onvSeeking.bind(this),
- onvCanPlay: this._onvCanPlay.bind(this),
- onvStalled: this._onvStalled.bind(this),
- onvProgress: this._onvProgress.bind(this)
- }, self.performance && self.performance.now ? this._now = self.performance.now.bind(self.performance) : this._now = Date.now, this._pendingSeekTime = null, this._requestSetTime = !1, this._seekpointRecord = null, this._progressChecker = null, this._mediaDataSource = t, this._mediaElement = null, this._msectl = null, this._transmuxer = null, this._mseSourceOpened = !1, this._hasPendingLoad = !1, this._receivedCanPlay = !1, this._mediaInfo = null, this._statisticsInfo = null;
- var i = f.default.chrome && (f.default.version.major < 50 || 50 === f.default.version.major && f.default.version.build < 2661);
- this._alwaysSeekKeyframe = !!(i || f.default.msedge || f.default.msie), this._alwaysSeekKeyframe && (this._config.accurateSeek = !1)
- }
- return a(e, [{
- key: "destroy",
- value: function() {
- null != this._progressChecker && (window.clearInterval(this._progressChecker), this._progressChecker = null), this._transmuxer && this.unload(), this._mediaElement && this.detachMediaElement(), this.e = null, this._mediaDataSource = null, this._emitter.removeAllListeners(), this._emitter = null
- }
- }, {
- key: "on",
- value: function(e, t) {
- var n = this;
- e === _.default.MEDIA_INFO ? null != this._mediaInfo && Promise.resolve().then(function() {
- n._emitter.emit(_.default.MEDIA_INFO, n.mediaInfo)
- }) : e === _.default.STATISTICS_INFO && null != this._statisticsInfo && Promise.resolve().then(function() {
- n._emitter.emit(_.default.STATISTICS_INFO, n.statisticsInfo)
- }), this._emitter.addListener(e, t)
- }
- }, {
- key: "off",
- value: function(e, t) {
- this._emitter.removeListener(e, t)
- }
- }, {
- key: "attachMediaElement",
- value: function(e) {
- var t = this;
- if (this._mediaElement = e, e.addEventListener("loadedmetadata", this.e.onvLoadedMetadata), e.addEventListener("seeking", this.e.onvSeeking), e.addEventListener("canplay", this.e.onvCanPlay), e.addEventListener("stalled", this.e.onvStalled), e.addEventListener("progress", this.e.onvProgress), this._msectl = new E.default(this._config), this._msectl.on(S.default.UPDATE_END, this._onmseUpdateEnd.bind(this)), this._msectl.on(S.default.BUFFER_FULL, this._onmseBufferFull.bind(this)), this._msectl.on(S.default.SOURCE_OPEN, function() {
- t._mseSourceOpened = !0, t._hasPendingLoad && (t._hasPendingLoad = !1, t.load())
- }), this._msectl.on(S.default.ERROR, function(e) {
- t._emitter.emit(_.default.ERROR, k.ErrorTypes.MEDIA_ERROR, k.ErrorDetails.MEDIA_MSE_ERROR, e)
- }), this._msectl.attachMediaElement(e), null != this._pendingSeekTime) try {
- e.currentTime = this._pendingSeekTime, this._pendingSeekTime = null
- } catch (e) {}
- }
- }, {
- key: "detachMediaElement",
- value: function() {
- this._mediaElement && (this._msectl.detachMediaElement(), this._mediaElement.removeEventListener("loadedmetadata", this.e.onvLoadedMetadata), this._mediaElement.removeEventListener("seeking", this.e.onvSeeking), this._mediaElement.removeEventListener("canplay", this.e.onvCanPlay), this._mediaElement.removeEventListener("stalled", this.e.onvStalled), this._mediaElement.removeEventListener("progress", this.e.onvProgress), this._mediaElement = null), this._msectl && (this._msectl.destroy(), this._msectl = null)
- }
- }, {
- key: "load",
- value: function() {
- var e = this;
- if (!this._mediaElement) throw new w.IllegalStateException("HTMLMediaElement must be attached before load()!");
- if (this._transmuxer) throw new w.IllegalStateException("FlvPlayer.load() has been called, please call unload() first!");
- if (!this._hasPendingLoad) {
- if (this._config.deferLoadAfterSourceOpen && !1 === this._mseSourceOpened) return void(this._hasPendingLoad = !0);
- this._mediaElement.readyState > 0 && (this._requestSetTime = !0, this._mediaElement.currentTime = 0), this._transmuxer = new p.default(this._mediaDataSource, this._config), this._transmuxer.on(g.default.INIT_SEGMENT, function(t, n) {
- e._msectl.appendInitSegment(n)
- }), this._transmuxer.on(g.default.MEDIA_SEGMENT, function(t, n) {
- if (e._msectl.appendMediaSegment(n), e._config.lazyLoad && !e._config.isLive) {
- var i = e._mediaElement.currentTime;
- n.info.endDts >= 1e3 * (i + e._config.lazyLoadMaxDuration) && null == e._progressChecker && (d.default.v(e.TAG, "Maximum buffering duration exceeded, suspend transmuxing task"), e._suspendTransmuxer())
- }
- }), this._transmuxer.on(g.default.LOADING_COMPLETE, function() {
- e._msectl.endOfStream(), e._emitter.emit(_.default.LOADING_COMPLETE)
- }),
- this._transmuxer.on(g.default.RECOVERED_EARLY_EOF, function() {
- e._emitter.emit(_.default.RECOVERED_EARLY_EOF)
- }), this._transmuxer.on(g.default.IO_ERROR, function(t, n) {
- e._emitter.emit(_.default.ERROR, k.ErrorTypes.NETWORK_ERROR, t, n)
- }), this._transmuxer.on(g.default.DEMUX_ERROR, function(t, n) {
- e._emitter.emit(_.default.ERROR, k.ErrorTypes.MEDIA_ERROR, t, {
- code: -1,
- msg: n
- })
- }), this._transmuxer.on(g.default.MEDIA_INFO, function(t) {
- e._mediaInfo = t, e._emitter.emit(_.default.MEDIA_INFO, Object.assign({}, t))
- }), this._transmuxer.on(g.default.STATISTICS_INFO, function(t) {
- e._statisticsInfo = e._fillStatisticsInfo(t), e._emitter.emit(_.default.STATISTICS_INFO, Object.assign({}, e._statisticsInfo))
- }), this._transmuxer.on(g.default.RECOMMEND_SEEKPOINT, function(t) {
- e._mediaElement && !e._config.accurateSeek && (e._requestSetTime = !0, e._mediaElement.currentTime = t / 1e3)
- }), this._transmuxer.open()
- }
- }
- }, {
- key: "unload",
- value: function() {
- this._mediaElement && this._mediaElement.pause(), this._msectl && this._msectl.seek(0), this._transmuxer && (this._transmuxer.close(), this._transmuxer.destroy(), this._transmuxer = null)
- }
- }, {
- key: "play",
- value: function() {
- return this._mediaElement.play()
- }
- }, {
- key: "pause",
- value: function() {
- this._mediaElement.pause()
- }
- }, {
- key: "_fillStatisticsInfo",
- value: function(e) {
- if (e.playerType = this._type, !(this._mediaElement instanceof HTMLVideoElement)) return e;
- var t = !0,
- n = 0,
- i = 0;
- if (this._mediaElement.getVideoPlaybackQuality) {
- var r = this._mediaElement.getVideoPlaybackQuality();
- n = r.totalVideoFrames, i = r.droppedVideoFrames
- } else void 0 != this._mediaElement.webkitDecodedFrameCount ? (n = this._mediaElement.webkitDecodedFrameCount, i = this._mediaElement.webkitDroppedFrameCount) : t = !1;
- return t && (e.decodedFrames = n, e.droppedFrames = i), e
- }
- }, {
- key: "_onmseUpdateEnd",
- value: function() {
- if (this._config.lazyLoad && !this._config.isLive) {
- for (var e = this._mediaElement.buffered, t = this._mediaElement.currentTime, n = 0, i = 0; i < e.length; i++) {
- var r = e.start(i),
- s = e.end(i);
- if (r <= t && t < s) {
- r,
- n = s;
- break
- }
- }
- n >= t + this._config.lazyLoadMaxDuration && null == this._progressChecker && (d.default.v(this.TAG, "Maximum buffering duration exceeded, suspend transmuxing task"), this._suspendTransmuxer())
- }
- }
- }, {
- key: "_onmseBufferFull",
- value: function() {
- d.default.v(this.TAG, "MSE SourceBuffer is full, suspend transmuxing task"), null == this._progressChecker && this._suspendTransmuxer()
- }
- }, {
- key: "_suspendTransmuxer",
- value: function() {
- this._transmuxer && (this._transmuxer.pause(), null == this._progressChecker && (this._progressChecker = window.setInterval(this._checkProgressAndResume.bind(this), 1e3)))
- }
- }, {
- key: "_checkProgressAndResume",
- value: function() {
- for (var e = this._mediaElement.currentTime, t = this._mediaElement.buffered, n = !1, i = 0; i < t.length; i++) {
- var r = t.start(i),
- s = t.end(i);
- if (e >= r && e < s) {
- e >= s - this._config.lazyLoadRecoverDuration && (n = !0);
- break
- }
- }
- n && (window.clearInterval(this._progressChecker), this._progressChecker = null, n && (d.default.v(this.TAG, "Continue loading from paused position"), this._transmuxer.resume()))
- }
- }, {
- key: "_isTimepointBuffered",
- value: function(e) {
- for (var t = this._mediaElement.buffered, n = 0; n < t.length; n++) {
- var i = t.start(n),
- r = t.end(n);
- if (e >= i && e < r) return !0
- }
- return !1
- }
- }, {
- key: "_internalSeek",
- value: function(e) {
- var t = this._isTimepointBuffered(e),
- n = !1,
- i = 0;
- if (e < 1 && this._mediaElement.buffered.length > 0) {
- var r = this._mediaElement.buffered.start(0);
- (r < 1 && e < r || f.default.safari) && (n = !0, i = f.default.safari ? .1 : r)
- }
- if (n) this._requestSetTime = !0, this._mediaElement.currentTime = i;
- else if (t) {
- if (this._alwaysSeekKeyframe) {
- var s = this._msectl.getNearestKeyframe(Math.floor(1e3 * e));
- this._requestSetTime = !0, this._mediaElement.currentTime = null != s ? s.dts / 1e3 : e
- } else this._requestSetTime = !0, this._mediaElement.currentTime = e;
- null != this._progressChecker && this._checkProgressAndResume()
- } else null != this._progressChecker && (window.clearInterval(this._progressChecker), this._progressChecker = null), this._msectl.seek(e), this._transmuxer.seek(Math.floor(1e3 * e)), this._config.accurateSeek && (this._requestSetTime = !0, this._mediaElement.currentTime = e)
- }
- }, {
- key: "_checkAndApplyUnbufferedSeekpoint",
- value: function() {
- if (this._seekpointRecord)
- if (this._seekpointRecord.recordTime <= this._now() - 100) {
- var e = this._mediaElement.currentTime;
- this._seekpointRecord = null, this._isTimepointBuffered(e) || (null != this._progressChecker && (window.clearTimeout(this._progressChecker), this._progressChecker = null), this._msectl.seek(e), this._transmuxer.seek(Math.floor(1e3 * e)), this._config.accurateSeek && (this._requestSetTime = !0, this._mediaElement.currentTime = e))
- } else window.setTimeout(this._checkAndApplyUnbufferedSeekpoint.bind(this), 50)
- }
- }, {
- key: "_checkAndResumeStuckPlayback",
- value: function(e) {
- var t = this._mediaElement;
- if (e || !this._receivedCanPlay || t.readyState < 2) {
- var n = t.buffered;
- n.length > 0 && t.currentTime < n.start(0) && (d.default.w(this.TAG, "Playback seems stuck at " + t.currentTime + ", seek to " + n.start(0)), this._requestSetTime = !0, this._mediaElement.currentTime = n.start(0), this._mediaElement.removeEventListener("progress", this.e.onvProgress))
- } else this._mediaElement.removeEventListener("progress", this.e.onvProgress)
- }
- }, {
- key: "_onvLoadedMetadata",
- value: function(e) {
- null != this._pendingSeekTime && (this._mediaElement.currentTime = this._pendingSeekTime, this._pendingSeekTime = null)
- }
- }, {
- key: "_onvSeeking",
- value: function(e) {
- var t = this._mediaElement.currentTime,
- n = this._mediaElement.buffered;
- if (this._requestSetTime) return void(this._requestSetTime = !1);
- if (t < 1 && n.length > 0) {
- var i = n.start(0);
- if (i < 1 && t < i || f.default.safari) return this._requestSetTime = !0, void(this._mediaElement.currentTime = f.default.safari ? .1 : i)
- }
- if (this._isTimepointBuffered(t)) {
- if (this._alwaysSeekKeyframe) {
- var r = this._msectl.getNearestKeyframe(Math.floor(1e3 * t));
- null != r && (this._requestSetTime = !0, this._mediaElement.currentTime = r.dts / 1e3)
- }
- return void(null != this._progressChecker && this._checkProgressAndResume())
- }
- this._seekpointRecord = {
- seekPoint: t,
- recordTime: this._now()
- }, window.setTimeout(this._checkAndApplyUnbufferedSeekpoint.bind(this), 50)
- }
- }, {
- key: "_onvCanPlay",
- value: function(e) {
- this._receivedCanPlay = !0, this._mediaElement.removeEventListener("canplay", this.e.onvCanPlay)
- }
- }, {
- key: "_onvStalled",
- value: function(e) {
- this._checkAndResumeStuckPlayback(!0)
- }
- }, {
- key: "_onvProgress",
- value: function(e) {
- this._checkAndResumeStuckPlayback()
- }
- }, {
- key: "type",
- get: function() {
- return this._type
- }
- }, {
- key: "buffered",
- get: function() {
- return this._mediaElement.buffered
- }
- }, {
- key: "duration",
- get: function() {
- return this._mediaElement.duration
- }
- }, {
- key: "volume",
- get: function() {
- return this._mediaElement.volume
- },
- set: function(e) {
- this._mediaElement.volume = e
- }
- }, {
- key: "muted",
- get: function() {
- return this._mediaElement.muted
- },
- set: function(e) {
- this._mediaElement.muted = e
- }
- }, {
- key: "currentTime",
- get: function() {
- return this._mediaElement ? this._mediaElement.currentTime : 0
- },
- set: function(e) {
- this._mediaElement ? this._internalSeek(e) : this._pendingSeekTime = e
- }
- }, {
- key: "mediaInfo",
- get: function() {
- return Object.assign({}, this._mediaInfo)
- }
- }, {
- key: "statisticsInfo",
- get: function() {
- return null == this._statisticsInfo && (this._statisticsInfo = {}), this._statisticsInfo = this._fillStatisticsInfo(this._statisticsInfo), Object.assign({}, this._statisticsInfo)
- }
- }]), e
- }();
- n.default = R
- }, {
- "../config.js": 5,
- "../core/mse-controller.js": 9,
- "../core/mse-events.js": 10,
- "../core/transmuxer.js": 11,
- "../core/transmuxing-events.js": 13,
- "../utils/browser.js": 39,
- "../utils/exception.js": 40,
- "../utils/logger.js": 41,
- "./player-errors.js": 34,
- "./player-events.js": 35,
- events: 2
- }],
- 33: [function(e, t, n) {
- "use strict";
-
- function i(e) {
- return e && e.__esModule ? e : {
- default: e
- }
- }
-
- function r(e, t) {
- if (!(e instanceof t)) throw new TypeError("Cannot call a class as a function")
- }
- Object.defineProperty(n, "__esModule", {
- value: !0
- });
- var s = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(e) {
- return typeof e
- } : function(e) {
- return e && "function" == typeof Symbol && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : typeof e
- },
- a = function() {
- function e(e, t) {
- for (var n = 0; n < t.length; n++) {
- var i = t[n];
- i.enumerable = i.enumerable || !1, i.configurable = !0, "value" in i && (i.writable = !0), Object.defineProperty(e, i.key, i)
- }
- }
- return function(t, n, i) {
- return n && e(t.prototype, n), i && e(t, i), t
- }
- }(),
- o = e("events"),
- u = i(o),
- l = e("./player-events.js"),
- d = i(l),
- h = e("../config.js"),
- f = e("../utils/exception.js"),
- c = function() {
- function e(t, n) {
- if (r(this, e), this.TAG = "NativePlayer", this._type = "NativePlayer", this._emitter = new u.default, this._config = (0, h.createDefaultConfig)(), "object" === (void 0 === n ? "undefined" : s(n)) && Object.assign(this._config, n), "flv" === t.type.toLowerCase()) throw new f.InvalidArgumentException("NativePlayer does't support flv MediaDataSource input!");
- if (t.hasOwnProperty("segments")) throw new f.InvalidArgumentException("NativePlayer(" + t.type + ") doesn't support multipart playback!");
- this.e = {
- onvLoadedMetadata: this._onvLoadedMetadata.bind(this)
- }, this._pendingSeekTime = null, this._statisticsReporter = null, this._mediaDataSource = t, this._mediaElement = null
- }
- return a(e, [{
- key: "destroy",
- value: function() {
- this._mediaElement && (this.unload(), this.detachMediaElement()), this.e = null, this._mediaDataSource = null, this._emitter.removeAllListeners(), this._emitter = null
- }
- }, {
- key: "on",
- value: function(e, t) {
- var n = this;
- e === d.default.MEDIA_INFO ? null != this._mediaElement && 0 !== this._mediaElement.readyState && Promise.resolve().then(function() {
- n._emitter.emit(d.default.MEDIA_INFO, n.mediaInfo)
- }) : e === d.default.STATISTICS_INFO && null != this._mediaElement && 0 !== this._mediaElement.readyState && Promise.resolve().then(function() {
- n._emitter.emit(d.default.STATISTICS_INFO, n.statisticsInfo)
- }), this._emitter.addListener(e, t)
- }
- }, {
- key: "off",
- value: function(e, t) {
- this._emitter.removeListener(e, t)
- }
- }, {
- key: "attachMediaElement",
- value: function(e) {
- if (this._mediaElement = e, e.addEventListener("loadedmetadata", this.e.onvLoadedMetadata), null != this._pendingSeekTime) try {
- e.currentTime = this._pendingSeekTime, this._pendingSeekTime = null
- } catch (e) {}
- }
- }, {
- key: "detachMediaElement",
- value: function() {
- this._mediaElement && (this._mediaElement.src = "", this._mediaElement.removeAttribute("src"), this._mediaElement.removeEventListener("loadedmetadata", this.e.onvLoadedMetadata), this._mediaElement = null), null != this._statisticsReporter && (window.clearInterval(this._statisticsReporter), this._statisticsReporter = null)
- }
- }, {
- key: "load",
- value: function() {
- if (!this._mediaElement) throw new f.IllegalStateException("HTMLMediaElement must be attached before load()!");
- this._mediaElement.src = this._mediaDataSource.url, this._mediaElement.readyState > 0 && (this._mediaElement.currentTime = 0), this._mediaElement.preload = "auto", this._mediaElement.load(), this._statisticsReporter = window.setInterval(this._reportStatisticsInfo.bind(this), this._config.statisticsInfoReportInterval)
- }
- }, {
- key: "unload",
- value: function() {
- this._mediaElement && (this._mediaElement.src = "", this._mediaElement.removeAttribute("src")), null != this._statisticsReporter && (window.clearInterval(this._statisticsReporter), this._statisticsReporter = null)
- }
- }, {
- key: "play",
- value: function() {
- return this._mediaElement.play()
- }
- }, {
- key: "pause",
- value: function() {
- this._mediaElement.pause()
- }
- }, {
- key: "_onvLoadedMetadata",
- value: function(e) {
- null != this._pendingSeekTime && (this._mediaElement.currentTime = this._pendingSeekTime, this._pendingSeekTime = null), this._emitter.emit(d.default.MEDIA_INFO, this.mediaInfo)
- }
- }, {
- key: "_reportStatisticsInfo",
- value: function() {
- this._emitter.emit(d.default.STATISTICS_INFO, this.statisticsInfo)
- }
- }, {
- key: "type",
- get: function() {
- return this._type
- }
- }, {
- key: "buffered",
- get: function() {
- return this._mediaElement.buffered
- }
- }, {
- key: "duration",
- get: function() {
- return this._mediaElement.duration
- }
- }, {
- key: "volume",
- get: function() {
- return this._mediaElement.volume
- },
- set: function(e) {
- this._mediaElement.volume = e
- }
- }, {
- key: "muted",
- get: function() {
- return this._mediaElement.muted
- },
- set: function(e) {
- this._mediaElement.muted = e
- }
- }, {
- key: "currentTime",
- get: function() {
- return this._mediaElement ? this._mediaElement.currentTime : 0
- },
- set: function(e) {
- this._mediaElement ? this._mediaElement.currentTime = e : this._pendingSeekTime = e
- }
- }, {
- key: "mediaInfo",
- get: function() {
- var e = this._mediaElement instanceof HTMLAudioElement ? "audio/" : "video/",
- t = {
- mimeType: e + this._mediaDataSource.type
- };
- return this._mediaElement && (t.duration = Math.floor(1e3 * this._mediaElement.duration), this._mediaElement instanceof HTMLVideoElement && (t.width = this._mediaElement.videoWidth, t.height = this._mediaElement.videoHeight)), t
- }
- }, {
- key: "statisticsInfo",
- get: function() {
- var e = {
- playerType: this._type,
- url: this._mediaDataSource.url
- };
- if (!(this._mediaElement instanceof HTMLVideoElement)) return e;
- var t = !0,
- n = 0,
- i = 0;
- if (this._mediaElement.getVideoPlaybackQuality) {
- var r = this._mediaElement.getVideoPlaybackQuality();
- n = r.totalVideoFrames, i = r.droppedVideoFrames
- } else void 0 != this._mediaElement.webkitDecodedFrameCount ? (n = this._mediaElement.webkitDecodedFrameCount, i = this._mediaElement.webkitDroppedFrameCount) : t = !1;
- return t && (e.decodedFrames = n, e.droppedFrames = i), e
- }
- }]), e
- }();
- n.default = c
- }, {
- "../config.js": 5,
- "../utils/exception.js": 40,
- "./player-events.js": 35,
- events: 2
- }],
- 34: [function(e, t, n) {
- "use strict";
- Object.defineProperty(n, "__esModule", {
- value: !0
- }), n.ErrorDetails = n.ErrorTypes = void 0;
- var i = e("../io/loader.js"),
- r = e("../demux/demux-errors.js"),
- s = function(e) {
- return e && e.__esModule ? e : {
- default: e
- }
- }(r);
- n.ErrorTypes = {
- NETWORK_ERROR: "NetworkError",
- MEDIA_ERROR: "MediaError",
- OTHER_ERROR: "OtherError"
- }, n.ErrorDetails = {
- NETWORK_EXCEPTION: i.LoaderErrors.EXCEPTION,
- NETWORK_STATUS_CODE_INVALID: i.LoaderErrors.HTTP_STATUS_CODE_INVALID,
- NETWORK_TIMEOUT: i.LoaderErrors.CONNECTING_TIMEOUT,
- NETWORK_UNRECOVERABLE_EARLY_EOF: i.LoaderErrors.UNRECOVERABLE_EARLY_EOF,
- MEDIA_MSE_ERROR: "MediaMSEError",
- MEDIA_FORMAT_ERROR: s.default.FORMAT_ERROR,
- MEDIA_FORMAT_UNSUPPORTED: s.default.FORMAT_UNSUPPORTED,
- MEDIA_CODEC_UNSUPPORTED: s.default.CODEC_UNSUPPORTED
- }
- }, {
- "../demux/demux-errors.js": 16,
- "../io/loader.js": 24
- }],
- 35: [function(e, t, n) {
- "use strict";
- Object.defineProperty(n, "__esModule", {
- value: !0
- });
- var i = {
- ERROR: "error",
- LOADING_COMPLETE: "loading_complete",
- RECOVERED_EARLY_EOF: "recovered_early_eof",
- MEDIA_INFO: "media_info",
- STATISTICS_INFO: "statistics_info"
- };
- n.default = i
- }, {}],
- 36: [function(e, t, n) {
- "use strict";
-
- function i(e, t) {
- if (!(e instanceof t)) throw new TypeError("Cannot call a class as a function")
- }
- Object.defineProperty(n, "__esModule", {
- value: !0
- });
- var r = function() {
- function e(e, t) {
- for (var n = 0; n < t.length; n++) {
- var i = t[n];
- i.enumerable = i.enumerable || !1, i.configurable = !0, "value" in i && (i.writable = !0), Object.defineProperty(e, i.key, i)
- }
- }
- return function(t, n, i) {
- return n && e(t.prototype, n), i && e(t, i), t
- }
- }(),
- s = function() {
- function e() {
- i(this, e)
- }
- return r(e, null, [{
- key: "getSilentFrame",
- value: function(e, t) {
- if ("mp4a.40.2" === e) {
- if (1 === t) return new Uint8Array([0, 200, 0, 128, 35, 128]);
- if (2 === t) return new Uint8Array([33, 0, 73, 144, 2, 25, 0, 35, 128]);
- if (3 === t) return new Uint8Array([0, 200, 0, 128, 32, 132, 1, 38, 64, 8, 100, 0, 142]);
- if (4 === t) return new Uint8Array([0, 200, 0, 128, 32, 132, 1, 38, 64, 8, 100, 0, 128, 44, 128, 8, 2, 56]);
- if (5 === t) return new Uint8Array([0, 200, 0, 128, 32, 132, 1, 38, 64, 8, 100, 0, 130, 48, 4, 153, 0, 33, 144, 2, 56]);
- if (6 === t) return new Uint8Array([0, 200, 0, 128, 32, 132, 1, 38, 64, 8, 100, 0, 130, 48, 4, 153, 0, 33, 144, 2, 0, 178, 0, 32, 8, 224])
- } else {
- if (1 === t) return new Uint8Array([1, 64, 34, 128, 163, 78, 230, 128, 186, 8, 0, 0, 0, 28, 6, 241, 193, 10, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 94]);
- if (2 === t) return new Uint8Array([1, 64, 34, 128, 163, 94, 230, 128, 186, 8, 0, 0, 0, 0, 149, 0, 6, 241, 161, 10, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 94]);
- if (3 === t) return new Uint8Array([1, 64, 34, 128, 163, 94, 230, 128, 186, 8, 0, 0, 0, 0, 149, 0, 6, 241, 161, 10, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 94])
- }
- return null
- }
- }]), e
- }();
- n.default = s
- }, {}],
- 37: [function(e, t, n) {
- "use strict";
-
- function i(e, t) {
- if (!(e instanceof t)) throw new TypeError("Cannot call a class as a function")
- }
- Object.defineProperty(n, "__esModule", {
- value: !0
- });
- var r = function() {
- function e(e, t) {
- for (var n = 0; n < t.length; n++) {
- var i = t[n];
- i.enumerable = i.enumerable || !1, i.configurable = !0, "value" in i && (i.writable = !0), Object.defineProperty(e, i.key, i)
- }
- }
- return function(t, n, i) {
- return n && e(t.prototype, n), i && e(t, i), t
- }
- }(),
- s = function() {
- function e() {
- i(this, e)
- }
- return r(e, null, [{
- key: "init",
- value: function() {
- e.types = {
- avc1: [],
- avcC: [],
- btrt: [],
- dinf: [],
- dref: [],
- esds: [],
- ftyp: [],
- hdlr: [],
- mdat: [],
- mdhd: [],
- mdia: [],
- mfhd: [],
- minf: [],
- moof: [],
- moov: [],
- mp4a: [],
- mvex: [],
- mvhd: [],
- sdtp: [],
- stbl: [],
- stco: [],
- stsc: [],
- stsd: [],
- stsz: [],
- stts: [],
- tfdt: [],
- tfhd: [],
- traf: [],
- trak: [],
- trun: [],
- trex: [],
- tkhd: [],
- vmhd: [],
- smhd: [],
- ".mp3": []
- };
- for (var t in e.types) e.types.hasOwnProperty(t) && (e.types[t] = [t.charCodeAt(0), t.charCodeAt(1), t.charCodeAt(2), t.charCodeAt(3)]);
- var n = e.constants = {};
- n.FTYP = new Uint8Array([105, 115, 111, 109, 0, 0, 0, 1, 105, 115, 111, 109, 97, 118, 99, 49]), n.STSD_PREFIX = new Uint8Array([0, 0, 0, 0, 0, 0, 0, 1]), n.STTS = new Uint8Array([0, 0, 0, 0, 0, 0, 0, 0]), n.STSC = n.STCO = n.STTS, n.STSZ = new Uint8Array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), n.HDLR_VIDEO = new Uint8Array([0, 0, 0, 0, 0, 0, 0, 0, 118, 105, 100, 101, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 86, 105, 100, 101, 111, 72, 97, 110, 100, 108, 101, 114, 0]), n.HDLR_AUDIO = new Uint8Array([0, 0, 0, 0, 0, 0, 0, 0, 115, 111, 117, 110, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 83, 111, 117, 110, 100, 72, 97, 110, 100, 108, 101, 114, 0]), n.DREF = new Uint8Array([0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 12, 117, 114, 108, 32, 0, 0, 0, 1]), n.SMHD = new Uint8Array([0, 0, 0, 0, 0, 0, 0, 0]), n.VMHD = new Uint8Array([0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0])
- }
- }, {
- key: "box",
- value: function(e) {
- for (var t = 8, n = null, i = Array.prototype.slice.call(arguments, 1), r = i.length, s = 0; s < r; s++) t += i[s].byteLength;
- n = new Uint8Array(t), n[0] = t >>> 24 & 255, n[1] = t >>> 16 & 255, n[2] = t >>> 8 & 255, n[3] = 255 & t, n.set(e, 4);
- for (var a = 8, o = 0; o < r; o++) n.set(i[o], a), a += i[o].byteLength;
- return n
- }
- }, {
- key: "generateInitSegment",
- value: function(t) {
- var n = e.box(e.types.ftyp, e.constants.FTYP),
- i = e.moov(t),
- r = new Uint8Array(n.byteLength + i.byteLength);
- return r.set(n, 0), r.set(i, n.byteLength), r
- }
- }, {
- key: "moov",
- value: function(t) {
- var n = e.mvhd(t.timescale, t.duration),
- i = e.trak(t),
- r = e.mvex(t);
- return e.box(e.types.moov, n, i, r)
- }
- }, {
- key: "mvhd",
- value: function(t, n) {
- return e.box(e.types.mvhd, new Uint8Array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, t >>> 24 & 255, t >>> 16 & 255, t >>> 8 & 255, 255 & t, n >>> 24 & 255, n >>> 16 & 255, n >>> 8 & 255, 255 & n, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255]))
- }
- }, {
- key: "trak",
- value: function(t) {
- return e.box(e.types.trak, e.tkhd(t), e.mdia(t))
- }
- }, {
- key: "tkhd",
- value: function(t) {
- var n = t.id,
- i = t.duration,
- r = t.presentWidth,
- s = t.presentHeight;
- return e.box(e.types.tkhd, new Uint8Array([0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0, n >>> 24 & 255, n >>> 16 & 255, n >>> 8 & 255, 255 & n, 0, 0, 0, 0, i >>> 24 & 255, i >>> 16 & 255, i >>> 8 & 255, 255 & i, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 64, 0, 0, 0, r >>> 8 & 255, 255 & r, 0, 0, s >>> 8 & 255, 255 & s, 0, 0]))
- }
- }, {
- key: "mdia",
- value: function(t) {
- return e.box(e.types.mdia, e.mdhd(t), e.hdlr(t), e.minf(t))
- }
- }, {
- key: "mdhd",
- value: function(t) {
- var n = t.timescale,
- i = t.duration;
- return e.box(e.types.mdhd, new Uint8Array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, n >>> 24 & 255, n >>> 16 & 255, n >>> 8 & 255, 255 & n, i >>> 24 & 255, i >>> 16 & 255, i >>> 8 & 255, 255 & i, 85, 196, 0, 0]))
- }
- }, {
- key: "hdlr",
- value: function(t) {
- var n = null;
- return n = "audio" === t.type ? e.constants.HDLR_AUDIO : e.constants.HDLR_VIDEO, e.box(e.types.hdlr, n)
- }
- }, {
- key: "minf",
- value: function(t) {
- var n = null;
- return n = "audio" === t.type ? e.box(e.types.smhd, e.constants.SMHD) : e.box(e.types.vmhd, e.constants.VMHD), e.box(e.types.minf, n, e.dinf(), e.stbl(t))
- }
- }, {
- key: "dinf",
- value: function() {
- return e.box(e.types.dinf, e.box(e.types.dref, e.constants.DREF))
- }
- }, {
- key: "stbl",
- value: function(t) {
- return e.box(e.types.stbl, e.stsd(t), e.box(e.types.stts, e.constants.STTS), e.box(e.types.stsc, e.constants.STSC), e.box(e.types.stsz, e.constants.STSZ), e.box(e.types.stco, e.constants.STCO))
- }
- }, {
- key: "stsd",
- value: function(t) {
- return "audio" === t.type ? "mp3" === t.codec ? e.box(e.types.stsd, e.constants.STSD_PREFIX, e.mp3(t)) : e.box(e.types.stsd, e.constants.STSD_PREFIX, e.mp4a(t)) : e.box(e.types.stsd, e.constants.STSD_PREFIX, e.avc1(t))
- }
- }, {
- key: "mp3",
- value: function(t) {
- var n = t.channelCount,
- i = t.audioSampleRate,
- r = new Uint8Array([0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, n, 0, 16, 0, 0, 0, 0, i >>> 8 & 255, 255 & i, 0, 0]);
- return e.box(e.types[".mp3"], r)
- }
- }, {
- key: "mp4a",
- value: function(t) {
- var n = t.channelCount,
- i = t.audioSampleRate,
- r = new Uint8Array([0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, n, 0, 16, 0, 0, 0, 0, i >>> 8 & 255, 255 & i, 0, 0]);
- return e.box(e.types.mp4a, r, e.esds(t))
- }
- }, {
- key: "esds",
- value: function(t) {
- var n = t.config || [],
- i = n.length,
- r = new Uint8Array([0, 0, 0, 0, 3, 23 + i, 0, 1, 0, 4, 15 + i, 64, 21, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5].concat([i]).concat(n).concat([6, 1, 2]));
- return e.box(e.types.esds, r)
- }
- }, {
- key: "avc1",
- value: function(t) {
- var n = t.avcc,
- i = t.codecWidth,
- r = t.codecHeight,
- s = new Uint8Array([0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, i >>> 8 & 255, 255 & i, r >>> 8 & 255, 255 & r, 0, 72, 0, 0, 0, 72, 0, 0, 0, 0, 0, 0, 0, 1, 10, 120, 113, 113, 47, 102, 108, 118, 46, 106, 115, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 24, 255, 255]);
- return e.box(e.types.avc1, s, e.box(e.types.avcC, n))
- }
- }, {
- key: "mvex",
- value: function(t) {
- return e.box(e.types.mvex, e.trex(t))
- }
- }, {
- key: "trex",
- value: function(t) {
- var n = t.id,
- i = new Uint8Array([0, 0, 0, 0, n >>> 24 & 255, n >>> 16 & 255, n >>> 8 & 255, 255 & n, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1]);
- return e.box(e.types.trex, i)
- }
- }, {
- key: "moof",
- value: function(t, n) {
- return e.box(e.types.moof, e.mfhd(t.sequenceNumber), e.traf(t, n))
- }
- }, {
- key: "mfhd",
- value: function(t) {
- var n = new Uint8Array([0, 0, 0, 0, t >>> 24 & 255, t >>> 16 & 255, t >>> 8 & 255, 255 & t]);
- return e.box(e.types.mfhd, n)
- }
- }, {
- key: "traf",
- value: function(t, n) {
- var i = t.id,
- r = e.box(e.types.tfhd, new Uint8Array([0, 0, 0, 0, i >>> 24 & 255, i >>> 16 & 255, i >>> 8 & 255, 255 & i])),
- s = e.box(e.types.tfdt, new Uint8Array([0, 0, 0, 0, n >>> 24 & 255, n >>> 16 & 255, n >>> 8 & 255, 255 & n])),
- a = e.sdtp(t),
- o = e.trun(t, a.byteLength + 16 + 16 + 8 + 16 + 8 + 8);
- return e.box(e.types.traf, r, s, o, a)
- }
- }, {
- key: "sdtp",
- value: function(t) {
- for (var n = t.samples || [], i = n.length, r = new Uint8Array(4 + i), s = 0; s < i; s++) {
- var a = n[s].flags;
- r[s + 4] = a.isLeading << 6 | a.dependsOn << 4 | a.isDependedOn << 2 | a.hasRedundancy
- }
- return e.box(e.types.sdtp, r)
- }
- }, {
- key: "trun",
- value: function(t, n) {
- var i = t.samples || [],
- r = i.length,
- s = 12 + 16 * r,
- a = new Uint8Array(s);
- n += 8 + s, a.set([0, 0, 15, 1, r >>> 24 & 255, r >>> 16 & 255, r >>> 8 & 255, 255 & r, n >>> 24 & 255, n >>> 16 & 255, n >>> 8 & 255, 255 & n], 0);
- for (var o = 0; o < r; o++) {
- var u = i[o].duration,
- l = i[o].size,
- d = i[o].flags,
- h = i[o].cts;
- a.set([u >>> 24 & 255, u >>> 16 & 255, u >>> 8 & 255, 255 & u, l >>> 24 & 255, l >>> 16 & 255, l >>> 8 & 255, 255 & l, d.isLeading << 2 | d.dependsOn, d.isDependedOn << 6 | d.hasRedundancy << 4 | d.isNonSync, 0, 0, h >>> 24 & 255, h >>> 16 & 255, h >>> 8 & 255, 255 & h], 12 + 16 * o)
- }
- return e.box(e.types.trun, a)
- }
- }, {
- key: "mdat",
- value: function(t) {
- return e.box(e.types.mdat, t)
- }
- }]), e
- }();
- s.init(), n.default = s
- }, {}],
- 38: [function(e, t, n) {
- "use strict";
-
- function i(e) {
- return e && e.__esModule ? e : {
- default: e
- }
- }
-
- function r(e, t) {
- if (!(e instanceof t)) throw new TypeError("Cannot call a class as a function")
- }
- Object.defineProperty(n, "__esModule", {
- value: !0
- });
- var s = function() {
- function e(e, t) {
- for (var n = 0; n < t.length; n++) {
- var i = t[n];
- i.enumerable = i.enumerable || !1, i.configurable = !0, "value" in i && (i.writable = !0), Object.defineProperty(e, i.key, i)
- }
- }
- return function(t, n, i) {
- return n && e(t.prototype, n), i && e(t, i), t
- }
- }(),
- a = e("../utils/logger.js"),
- o = i(a),
- u = e("./mp4-generator.js"),
- l = i(u),
- d = e("./aac-silent.js"),
- h = i(d),
- f = e("../utils/browser.js"),
- c = i(f),
- _ = e("../core/media-segment-info.js"),
- m = e("../utils/exception.js"),
- p = function() {
- function e(t) {
- r(this, e), this.TAG = "MP4Remuxer", this._config = t, this._isLive = !0 === t.isLive, this._dtsBase = -1, this._dtsBaseInited = !1, this._audioDtsBase = 1 / 0, this._videoDtsBase = 1 / 0, this._audioNextDts = void 0, this._videoNextDts = void 0, this._audioStashedLastSample = null, this._videoStashedLastSample = null, this._audioMeta = null, this._videoMeta = null, this._audioSegmentInfoList = new _.MediaSegmentInfoList("audio"), this._videoSegmentInfoList = new _.MediaSegmentInfoList("video"), this._onInitSegment = null, this._onMediaSegment = null, this._forceFirstIDR = !(!c.default.chrome || !(c.default.version.major < 50 || 50 === c.default.version.major && c.default.version.build < 2661)), this._fillSilentAfterSeek = c.default.msedge || c.default.msie, this._mp3UseMpegAudio = !c.default.firefox, this._fillAudioTimestampGap = this._config.fixAudioTimestampGap
- }
- return s(e, [{
- key: "destroy",
- value: function() {
- this._dtsBase = -1, this._dtsBaseInited = !1, this._audioMeta = null, this._videoMeta = null, this._audioSegmentInfoList.clear(), this._audioSegmentInfoList = null, this._videoSegmentInfoList.clear(), this._videoSegmentInfoList = null, this._onInitSegment = null, this._onMediaSegment = null
- }
- }, {
- key: "bindDataSource",
- value: function(e) {
- return e.onDataAvailable = this.remux.bind(this), e.onTrackMetadata = this._onTrackMetadataReceived.bind(this), this
- }
- }, {
- key: "insertDiscontinuity",
- value: function() {
- this._audioNextDts = this._videoNextDts = void 0
- }
- }, {
- key: "seek",
- value: function(e) {
- this._audioStashedLastSample = null, this._videoStashedLastSample = null, this._videoSegmentInfoList.clear(), this._audioSegmentInfoList.clear()
- }
- }, {
- key: "remux",
- value: function(e, t) {
- if (!this._onMediaSegment) throw new m.IllegalStateException("MP4Remuxer: onMediaSegment callback must be specificed!");
- this._dtsBaseInited || this._calculateDtsBase(e, t), this._remuxVideo(t), this._remuxAudio(e)
- }
- }, {
- key: "_onTrackMetadataReceived",
- value: function(e, t) {
- var n = null,
- i = "mp4",
- r = t.codec;
- if ("audio" === e) this._audioMeta = t, "mp3" === t.codec && this._mp3UseMpegAudio ? (i = "mpeg", r = "", n = new Uint8Array) : n = l.default.generateInitSegment(t);
- else {
- if ("video" !== e) return;
- this._videoMeta = t, n = l.default.generateInitSegment(t)
- }
- if (!this._onInitSegment) throw new m.IllegalStateException("MP4Remuxer: onInitSegment callback must be specified!");
- this._onInitSegment(e, {
- type: e,
- data: n.buffer,
- codec: r,
- container: e + "/" + i,
- mediaDuration: t.duration
- })
- }
- }, {
- key: "_calculateDtsBase",
- value: function(e, t) {
- this._dtsBaseInited || (e.samples && e.samples.length && (this._audioDtsBase = e.samples[0].dts), t.samples && t.samples.length && (this._videoDtsBase = t.samples[0].dts), this._dtsBase = Math.min(this._audioDtsBase, this._videoDtsBase), this._dtsBaseInited = !0)
- }
- }, {
- key: "flushStashedSamples",
- value: function() {
- var e = this._videoStashedLastSample,
- t = this._audioStashedLastSample,
- n = {
- type: "video",
- id: 1,
- sequenceNumber: 0,
- samples: [],
- length: 0
- };
- null != e && (n.samples.push(e), n.length = e.length);
- var i = {
- type: "audio",
- id: 2,
- sequenceNumber: 0,
- samples: [],
- length: 0
- };
- null != t && (i.samples.push(t), i.length = t.length), this._videoStashedLastSample = null, this._audioStashedLastSample = null, this._remuxVideo(n, !0), this._remuxAudio(i, !0)
- }
- }, {
- key: "_remuxAudio",
- value: function(e, t) {
- if (null != this._audioMeta) {
- var n = e,
- i = n.samples,
- r = void 0,
- s = -1,
- a = -1,
- u = this._audioMeta.refSampleDuration,
- d = "mp3" === this._audioMeta.codec && this._mp3UseMpegAudio,
- f = this._dtsBaseInited && void 0 === this._audioNextDts,
- m = !1;
- if (i && 0 !== i.length && (1 !== i.length || t)) {
- var p = 0,
- v = null,
- g = 0;
- d ? (p = 0, g = n.length) : (p = 8, g = 8 + n.length);
- var y = null;
- if (i.length > 1 && (y = i.pop(), g -= y.length), null != this._audioStashedLastSample) {
- var E = this._audioStashedLastSample;
- this._audioStashedLastSample = null, i.unshift(E), g += E.length
- }
- null != y && (this._audioStashedLastSample = y);
- var b = i[0].dts - this._dtsBase;
- if (this._audioNextDts) r = b - this._audioNextDts;
- else if (this._audioSegmentInfoList.isEmpty()) r = 0, this._fillSilentAfterSeek && !this._videoSegmentInfoList.isEmpty() && "mp3" !== this._audioMeta.originalCodec && (m = !0);
- else {
- var S = this._audioSegmentInfoList.getLastSampleBefore(b);
- if (null != S) {
- var k = b - (S.originalDts + S.duration);
- k <= 3 && (k = 0);
- var L = S.dts + S.duration + k;
- r = b - L
- } else r = 0
- }
- if (m) {
- var w = b - r,
- R = this._videoSegmentInfoList.getLastSegmentBefore(b);
- if (null != R && R.beginDts < w) {
- var A = h.default.getSilentFrame(this._audioMeta.originalCodec, this._audioMeta.channelCount);
- if (A) {
- var O = R.beginDts,
- T = w - R.beginDts;
- o.default.v(this.TAG, "InsertPrefixSilentAudio: dts: " + O + ", duration: " + T), i.unshift({
- unit: A,
- dts: O,
- pts: O
- }), g += A.byteLength
- }
- } else m = !1
- }
- for (var C = [], I = 0; I < i.length; I++) {
- var x = i[I],
- M = x.unit,
- D = x.dts - this._dtsBase,
- B = D - r; - 1 === s && (s = B);
- var j = 0;
- if (I !== i.length - 1) {
- j = i[I + 1].dts - this._dtsBase - r - B
- } else if (null != y) {
- var P = y.dts - this._dtsBase - r;
- j = P - B
- } else j = C.length >= 1 ? C[C.length - 1].duration : Math.floor(u);
- var U = !1,
- N = null;
- if (j > 1.5 * u && "mp3" !== this._audioMeta.codec && this._fillAudioTimestampGap && !c.default.safari) {
- U = !0;
- var F = Math.abs(j - u),
- G = Math.ceil(F / u),
- V = B + u;
- o.default.w(this.TAG, "Large audio timestamp gap detected, may cause AV sync to drift. Silent frames will be generated to avoid unsync.\ndts: " + (B + j) + " ms, expected: " + (B + Math.round(u)) + " ms, delta: " + Math.round(F) + " ms, generate: " + G + " frames");
- var z = h.default.getSilentFrame(this._audioMeta.originalCodec, this._audioMeta.channelCount);
- null == z && (o.default.w(this.TAG, "Unable to generate silent frame for " + this._audioMeta.originalCodec + " with " + this._audioMeta.channelCount + " channels, repeat last frame"), z = M), N = [];
- for (var H = 0; H < G; H++) {
- var K = Math.round(V);
- if (N.length > 0) {
- var q = N[N.length - 1];
- q.duration = K - q.dts
- }
- var W = {
- dts: K,
- pts: K,
- cts: 0,
- unit: z,
- size: z.byteLength,
- duration: 0,
- originalDts: D,
- flags: {
- isLeading: 0,
- dependsOn: 1,
- isDependedOn: 0,
- hasRedundancy: 0
- }
- };
- N.push(W), g += M.byteLength, V += u
- }
- var X = N[N.length - 1];
- X.duration = B + j - X.dts, j = Math.round(u)
- }
- C.push({
- dts: B,
- pts: B,
- cts: 0,
- unit: x.unit,
- size: x.unit.byteLength,
- duration: j,
- originalDts: D,
- flags: {
- isLeading: 0,
- dependsOn: 1,
- isDependedOn: 0,
- hasRedundancy: 0
- }
- }), U && C.push.apply(C, N)
- }
- d ? v = new Uint8Array(g) : (v = new Uint8Array(g), v[0] = g >>> 24 & 255, v[1] = g >>> 16 & 255, v[2] = g >>> 8 & 255, v[3] = 255 & g, v.set(l.default.types.mdat, 4));
- for (var Y = 0; Y < C.length; Y++) {
- var Z = C[Y].unit;
- v.set(Z, p), p += Z.byteLength
- }
- var Q = C[C.length - 1];
- a = Q.dts + Q.duration, this._audioNextDts = a;
- var J = new _.MediaSegmentInfo;
- J.beginDts = s, J.endDts = a, J.beginPts = s, J.endPts = a, J.originalBeginDts = C[0].originalDts, J.originalEndDts = Q.originalDts + Q.duration, J.firstSample = new _.SampleInfo(C[0].dts, C[0].pts, C[0].duration, C[0].originalDts, !1), J.lastSample = new _.SampleInfo(Q.dts, Q.pts, Q.duration, Q.originalDts, !1), this._isLive || this._audioSegmentInfoList.append(J), n.samples = C, n.sequenceNumber++;
- var $ = null;
- $ = d ? new Uint8Array : l.default.moof(n, s), n.samples = [], n.length = 0;
- var ee = {
- type: "audio",
- data: this._mergeBoxes($, v).buffer,
- sampleCount: C.length,
- info: J
- };
- d && f && (ee.timestampOffset = s), this._onMediaSegment("audio", ee)
- }
- }
- }
- }, {
- key: "_remuxVideo",
- value: function(e, t) {
- if (null != this._videoMeta) {
- var n = e,
- i = n.samples,
- r = void 0,
- s = -1,
- a = -1,
- o = -1,
- u = -1;
- if (i && 0 !== i.length && (1 !== i.length || t)) {
- var d = 8,
- h = null,
- f = 8 + e.length,
- c = null;
- if (i.length > 1 && (c = i.pop(), f -= c.length), null != this._videoStashedLastSample) {
- var m = this._videoStashedLastSample;
- this._videoStashedLastSample = null, i.unshift(m), f += m.length
- }
- null != c && (this._videoStashedLastSample = c);
- var p = i[0].dts - this._dtsBase;
- if (this._videoNextDts) r = p - this._videoNextDts;
- else if (this._videoSegmentInfoList.isEmpty()) r = 0;
- else {
- var v = this._videoSegmentInfoList.getLastSampleBefore(p);
- if (null != v) {
- var g = p - (v.originalDts + v.duration);
- g <= 3 && (g = 0);
- var y = v.dts + v.duration + g;
- r = p - y
- } else r = 0
- }
- for (var E = new _.MediaSegmentInfo, b = [], S = 0; S < i.length; S++) {
- var k = i[S],
- L = k.dts - this._dtsBase,
- w = k.isKeyframe,
- R = L - r,
- A = k.cts,
- O = R + A; - 1 === s && (s = R, o = O);
- var T = 0;
- if (S !== i.length - 1) {
- T = i[S + 1].dts - this._dtsBase - r - R
- } else if (null != c) {
- var C = c.dts - this._dtsBase - r;
- T = C - R
- } else T = b.length >= 1 ? b[b.length - 1].duration : Math.floor(this._videoMeta.refSampleDuration);
- if (w) {
- var I = new _.SampleInfo(R, O, T, k.dts, !0);
- I.fileposition = k.fileposition, E.appendSyncPoint(I)
- }
- b.push({
- dts: R,
- pts: O,
- cts: A,
- units: k.units,
- size: k.length,
- isKeyframe: w,
- duration: T,
- originalDts: L,
- flags: {
- isLeading: 0,
- dependsOn: w ? 2 : 1,
- isDependedOn: w ? 1 : 0,
- hasRedundancy: 0,
- isNonSync: w ? 0 : 1
- }
- })
- }
- h = new Uint8Array(f), h[0] = f >>> 24 & 255, h[1] = f >>> 16 & 255, h[2] = f >>> 8 & 255, h[3] = 255 & f, h.set(l.default.types.mdat, 4);
- for (var x = 0; x < b.length; x++)
- for (var M = b[x].units; M.length;) {
- var D = M.shift(),
- B = D.data;
- h.set(B, d), d += B.byteLength
- }
- var j = b[b.length - 1];
- if (a = j.dts + j.duration, u = j.pts + j.duration, this._videoNextDts = a, E.beginDts = s, E.endDts = a, E.beginPts = o, E.endPts = u, E.originalBeginDts = b[0].originalDts, E.originalEndDts = j.originalDts + j.duration, E.firstSample = new _.SampleInfo(b[0].dts, b[0].pts, b[0].duration, b[0].originalDts, b[0].isKeyframe), E.lastSample = new _.SampleInfo(j.dts, j.pts, j.duration, j.originalDts, j.isKeyframe), this._isLive || this._videoSegmentInfoList.append(E), n.samples = b, n.sequenceNumber++, this._forceFirstIDR) {
- var P = b[0].flags;
- P.dependsOn = 2, P.isNonSync = 0
- }
- var U = l.default.moof(n, s);
- n.samples = [], n.length = 0, this._onMediaSegment("video", {
- type: "video",
- data: this._mergeBoxes(U, h).buffer,
- sampleCount: b.length,
- info: E
- })
- }
- }
- }
- }, {
- key: "_mergeBoxes",
- value: function(e, t) {
- var n = new Uint8Array(e.byteLength + t.byteLength);
- return n.set(e, 0), n.set(t, e.byteLength), n
- }
- }, {
- key: "onInitSegment",
- get: function() {
- return this._onInitSegment
- },
- set: function(e) {
- this._onInitSegment = e
- }
- }, {
- key: "onMediaSegment",
- get: function() {
- return this._onMediaSegment
- },
- set: function(e) {
- this._onMediaSegment = e
- }
- }]), e
- }();
- n.default = p
- }, {
- "../core/media-segment-info.js": 8,
- "../utils/browser.js": 39,
- "../utils/exception.js": 40,
- "../utils/logger.js": 41,
- "./aac-silent.js": 36,
- "./mp4-generator.js": 37
- }],
- 39: [function(e, t, n) {
- "use strict";
- Object.defineProperty(n, "__esModule", {
- value: !0
- });
- var i = {};
- ! function() {
- var e = self.navigator.userAgent.toLowerCase(),
- t = /(edge)\/([\w.]+)/.exec(e) || /(opr)[\/]([\w.]+)/.exec(e) || /(chrome)[ \/]([\w.]+)/.exec(e) || /(iemobile)[\/]([\w.]+)/.exec(e) || /(version)(applewebkit)[ \/]([\w.]+).*(safari)[ \/]([\w.]+)/.exec(e) || /(webkit)[ \/]([\w.]+).*(version)[ \/]([\w.]+).*(safari)[ \/]([\w.]+)/.exec(e) || /(webkit)[ \/]([\w.]+)/.exec(e) || /(opera)(?:.*version|)[ \/]([\w.]+)/.exec(e) || /(msie) ([\w.]+)/.exec(e) || e.indexOf("trident") >= 0 && /(rv)(?::| )([\w.]+)/.exec(e) || e.indexOf("compatible") < 0 && /(firefox)[ \/]([\w.]+)/.exec(e) || [],
- n = /(ipad)/.exec(e) || /(ipod)/.exec(e) || /(windows phone)/.exec(e) || /(iphone)/.exec(e) || /(kindle)/.exec(e) || /(android)/.exec(e) || /(windows)/.exec(e) || /(mac)/.exec(e) || /(linux)/.exec(e) || /(cros)/.exec(e) || [],
- r = {
- browser: t[5] || t[3] || t[1] || "",
- version: t[2] || t[4] || "0",
- majorVersion: t[4] || t[2] || "0",
- platform: n[0] || ""
- },
- s = {};
- if (r.browser) {
- s[r.browser] = !0;
- var a = r.majorVersion.split(".");
- s.version = {
- major: parseInt(r.majorVersion, 10),
- string: r.version
- }, a.length > 1 && (s.version.minor = parseInt(a[1], 10)), a.length > 2 && (s.version.build = parseInt(a[2], 10))
- }
- r.platform && (s[r.platform] = !0), (s.chrome || s.opr || s.safari) && (s.webkit = !0), (s.rv || s.iemobile) && (s.rv && delete s.rv, r.browser = "msie", s.msie = !0), s.edge && (delete s.edge, r.browser = "msedge", s.msedge = !0), s.opr && (r.browser = "opera", s.opera = !0), s.safari && s.android && (r.browser = "android", s.android = !0), s.name = r.browser, s.platform = r.platform;
- for (var o in i) i.hasOwnProperty(o) && delete i[o];
- Object.assign(i, s)
- }(), n.default = i
- }, {}],
- 40: [function(e, t, n) {
- "use strict";
-
- function i(e, t) {
- if (!e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
- return !t || "object" != typeof t && "function" != typeof t ? e : t
- }
-
- function r(e, t) {
- if ("function" != typeof t && null !== t) throw new TypeError("Super expression must either be null or a function, not " + typeof t);
- e.prototype = Object.create(t && t.prototype, {
- constructor: {
- value: e,
- enumerable: !1,
- writable: !0,
- configurable: !0
- }
- }), t && (Object.setPrototypeOf ? Object.setPrototypeOf(e, t) : e.__proto__ = t)
- }
-
- function s(e, t) {
- if (!(e instanceof t)) throw new TypeError("Cannot call a class as a function")
- }
- Object.defineProperty(n, "__esModule", {
- value: !0
- });
- var a = function() {
- function e(e, t) {
- for (var n = 0; n < t.length; n++) {
- var i = t[n];
- i.enumerable = i.enumerable || !1, i.configurable = !0, "value" in i && (i.writable = !0), Object.defineProperty(e, i.key, i)
- }
- }
- return function(t, n, i) {
- return n && e(t.prototype, n), i && e(t, i), t
- }
- }(),
- o = n.RuntimeException = function() {
- function e(t) {
- s(this, e), this._message = t
- }
- return a(e, [{
- key: "toString",
- value: function() {
- return this.name + ": " + this.message
- }
- }, {
- key: "name",
- get: function() {
- return "RuntimeException"
- }
- }, {
- key: "message",
- get: function() {
- return this._message
- }
- }]), e
- }();
- n.IllegalStateException = function(e) {
- function t(e) {
- return s(this, t), i(this, (t.__proto__ || Object.getPrototypeOf(t)).call(this, e))
- }
- return r(t, e), a(t, [{
- key: "name",
- get: function() {
- return "IllegalStateException"
- }
- }]), t
- }(o), n.InvalidArgumentException = function(e) {
- function t(e) {
- return s(this, t), i(this, (t.__proto__ || Object.getPrototypeOf(t)).call(this, e))
- }
- return r(t, e), a(t, [{
- key: "name",
- get: function() {
- return "InvalidArgumentException"
- }
- }]), t
- }(o), n.NotImplementedException = function(e) {
- function t(e) {
- return s(this, t), i(this, (t.__proto__ || Object.getPrototypeOf(t)).call(this, e))
- }
- return r(t, e), a(t, [{
- key: "name",
- get: function() {
- return "NotImplementedException"
- }
- }]), t
- }(o)
- }, {}],
- 41: [function(e, t, n) {
- "use strict";
-
- function i(e, t) {
- if (!(e instanceof t)) throw new TypeError("Cannot call a class as a function")
- }
- Object.defineProperty(n, "__esModule", {
- value: !0
- });
- var r = function() {
- function e(e, t) {
- for (var n = 0; n < t.length; n++) {
- var i = t[n];
- i.enumerable = i.enumerable || !1, i.configurable = !0, "value" in i && (i.writable = !0), Object.defineProperty(e, i.key, i)
- }
- }
- return function(t, n, i) {
- return n && e(t.prototype, n), i && e(t, i), t
- }
- }(),
- s = e("events"),
- a = function(e) {
- return e && e.__esModule ? e : {
- default: e
- }
- }(s),
- o = function() {
- function e() {
- i(this, e)
- }
- return r(e, null, [{
- key: "e",
- value: function(t, n) {
- t && !e.FORCE_GLOBAL_TAG || (t = e.GLOBAL_TAG);
- var i = "[" + t + "] > " + n;
- e.ENABLE_CALLBACK && e.emitter.emit("log", "error", i), e.ENABLE_ERROR && (console.error ? console.error(i) : console.warn ? console.warn(i) : console.log(i))
- }
- }, {
- key: "i",
- value: function(t, n) {
- t && !e.FORCE_GLOBAL_TAG || (t = e.GLOBAL_TAG);
- var i = "[" + t + "] > " + n;
- e.ENABLE_CALLBACK && e.emitter.emit("log", "info", i), e.ENABLE_INFO && (console.info ? console.info(i) : console.log(i))
- }
- }, {
- key: "w",
- value: function(t, n) {
- t && !e.FORCE_GLOBAL_TAG || (t = e.GLOBAL_TAG);
- var i = "[" + t + "] > " + n;
- e.ENABLE_CALLBACK && e.emitter.emit("log", "warn", i), e.ENABLE_WARN && (console.warn ? console.warn(i) : console.log(i))
- }
- }, {
- key: "d",
- value: function(t, n) {
- t && !e.FORCE_GLOBAL_TAG || (t = e.GLOBAL_TAG);
- var i = "[" + t + "] > " + n;
- e.ENABLE_CALLBACK && e.emitter.emit("log", "debug", i), e.ENABLE_DEBUG && (console.debug ? console.debug(i) : console.log(i))
- }
- }, {
- key: "v",
- value: function(t, n) {
- t && !e.FORCE_GLOBAL_TAG || (t = e.GLOBAL_TAG);
- var i = "[" + t + "] > " + n;
- e.ENABLE_CALLBACK && e.emitter.emit("log", "verbose", i), e.ENABLE_VERBOSE && console.log(i)
- }
- }]), e
- }();
- o.GLOBAL_TAG = "flv.js", o.FORCE_GLOBAL_TAG = !1, o.ENABLE_ERROR = !0, o.ENABLE_INFO = !0, o.ENABLE_WARN = !0, o.ENABLE_DEBUG = !0, o.ENABLE_VERBOSE = !0, o.ENABLE_CALLBACK = !1, o.emitter = new a.default, n.default = o
- }, {
- events: 2
- }],
- 42: [function(e, t, n) {
- "use strict";
-
- function i(e) {
- return e && e.__esModule ? e : {
- default: e
- }
- }
-
- function r(e, t) {
- if (!(e instanceof t)) throw new TypeError("Cannot call a class as a function")
- }
- Object.defineProperty(n, "__esModule", {
- value: !0
- });
- var s = function() {
- function e(e, t) {
- for (var n = 0; n < t.length; n++) {
- var i = t[n];
- i.enumerable = i.enumerable || !1, i.configurable = !0, "value" in i && (i.writable = !0), Object.defineProperty(e, i.key, i)
- }
- }
- return function(t, n, i) {
- return n && e(t.prototype, n), i && e(t, i), t
- }
- }(),
- a = e("events"),
- o = i(a),
- u = e("./logger.js"),
- l = i(u),
- d = function() {
- function e() {
- r(this, e)
- }
- return s(e, null, [{
- key: "getConfig",
- value: function() {
- return {
- globalTag: l.default.GLOBAL_TAG,
- forceGlobalTag: l.default.FORCE_GLOBAL_TAG,
- enableVerbose: l.default.ENABLE_VERBOSE,
- enableDebug: l.default.ENABLE_DEBUG,
- enableInfo: l.default.ENABLE_INFO,
- enableWarn: l.default.ENABLE_WARN,
- enableError: l.default.ENABLE_ERROR,
- enableCallback: l.default.ENABLE_CALLBACK
- }
- }
- }, {
- key: "applyConfig",
- value: function(e) {
- l.default.GLOBAL_TAG = e.globalTag, l.default.FORCE_GLOBAL_TAG = e.forceGlobalTag, l.default.ENABLE_VERBOSE = e.enableVerbose, l.default.ENABLE_DEBUG = e.enableDebug, l.default.ENABLE_INFO = e.enableInfo, l.default.ENABLE_WARN = e.enableWarn, l.default.ENABLE_ERROR = e.enableError, l.default.ENABLE_CALLBACK = e.enableCallback
- }
- }, {
- key: "_notifyChange",
- value: function() {
- var t = e.emitter;
- if (t.listenerCount("change") > 0) {
- var n = e.getConfig();
- t.emit("change", n)
- }
- }
- }, {
- key: "registerListener",
- value: function(t) {
- e.emitter.addListener("change", t)
- }
- }, {
- key: "removeListener",
- value: function(t) {
- e.emitter.removeListener("change", t)
- }
- }, {
- key: "addLogListener",
- value: function(t) {
- l.default.emitter.addListener("log", t), l.default.emitter.listenerCount("log") > 0 && (l.default.ENABLE_CALLBACK = !0, e._notifyChange())
- }
- }, {
- key: "removeLogListener",
- value: function(t) {
- l.default.emitter.removeListener("log", t), 0 === l.default.emitter.listenerCount("log") && (l.default.ENABLE_CALLBACK = !1, e._notifyChange())
- }
- }, {
- key: "forceGlobalTag",
- get: function() {
- return l.default.FORCE_GLOBAL_TAG
- },
- set: function(t) {
- l.default.FORCE_GLOBAL_TAG = t, e._notifyChange()
- }
- }, {
- key: "globalTag",
- get: function() {
- return l.default.GLOBAL_TAG
- },
- set: function(t) {
- l.default.GLOBAL_TAG = t, e._notifyChange()
- }
- }, {
- key: "enableAll",
- get: function() {
- return l.default.ENABLE_VERBOSE && l.default.ENABLE_DEBUG && l.default.ENABLE_INFO && l.default.ENABLE_WARN && l.default.ENABLE_ERROR
- },
- set: function(t) {
- l.default.ENABLE_VERBOSE = t, l.default.ENABLE_DEBUG = t, l.default.ENABLE_INFO = t, l.default.ENABLE_WARN = t, l.default.ENABLE_ERROR = t, e._notifyChange()
- }
- }, {
- key: "enableDebug",
- get: function() {
- return l.default.ENABLE_DEBUG
- },
- set: function(t) {
- l.default.ENABLE_DEBUG = t, e._notifyChange()
- }
- }, {
- key: "enableVerbose",
- get: function() {
- return l.default.ENABLE_VERBOSE
- },
- set: function(t) {
- l.default.ENABLE_VERBOSE = t, e._notifyChange()
- }
- }, {
- key: "enableInfo",
- get: function() {
- return l.default.ENABLE_INFO
- },
- set: function(t) {
- l.default.ENABLE_INFO = t, e._notifyChange()
- }
- }, {
- key: "enableWarn",
- get: function() {
- return l.default.ENABLE_WARN
- },
- set: function(t) {
- l.default.ENABLE_WARN = t, e._notifyChange()
- }
- }, {
- key: "enableError",
- get: function() {
- return l.default.ENABLE_ERROR
- },
- set: function(t) {
- l.default.ENABLE_ERROR = t, e._notifyChange()
- }
- }]), e
- }();
- d.emitter = new o.default, n.default = d
- }, {
- "./logger.js": 41,
- events: 2
- }],
- 43: [function(e, t, n) {
- "use strict";
-
- function i(e, t) {
- if (!(e instanceof t)) throw new TypeError("Cannot call a class as a function")
- }
- Object.defineProperty(n, "__esModule", {
- value: !0
- });
- var r = function() {
- function e(e, t) {
- for (var n = 0; n < t.length; n++) {
- var i = t[n];
- i.enumerable = i.enumerable || !1, i.configurable = !0, "value" in i && (i.writable = !0), Object.defineProperty(e, i.key, i)
- }
- }
- return function(t, n, i) {
- return n && e(t.prototype, n), i && e(t, i), t
- }
- }(),
- s = function() {
- function t() {
- i(this, t)
- }
- return r(t, null, [{
- key: "install",
- value: function() {
- Object.setPrototypeOf = Object.setPrototypeOf || function(e, t) {
- return e.__proto__ = t, e
- }, Object.assign = Object.assign || function(e) {
- if (void 0 === e || null === e) throw new TypeError("Cannot convert undefined or null to object");
- for (var t = Object(e), n = 1; n < arguments.length; n++) {
- var i = arguments[n];
- if (void 0 !== i && null !== i)
- for (var r in i) i.hasOwnProperty(r) && (t[r] = i[r])
- }
- return t
- }, "function" != typeof self.Promise && e("es6-promise").polyfill()
- }
- }]), t
- }();
- s.install(), n.default = s
- }, {
- "es6-promise": 1
- }],
- 44: [function(e, t, n) {
- "use strict";
-
- function i(e, t, n) {
- var i = e;
- if (t + n < i.length) {
- for (; n--;)
- if (128 != (192 & i[++t])) return !1;
- return !0
- }
- return !1
- }
-
- function r(e) {
- for (var t = [], n = e, r = 0, s = e.length; r < s;)
- if (n[r] < 128) t.push(String.fromCharCode(n[r])), ++r;
- else {
- if (n[r] < 192);
- else if (n[r] < 224) {
- if (i(n, r, 1)) {
- var a = (31 & n[r]) << 6 | 63 & n[r + 1];
- if (a >= 128) {
- t.push(String.fromCharCode(65535 & a)), r += 2;
- continue
- }
- }
- } else if (n[r] < 240) {
- if (i(n, r, 2)) {
- var o = (15 & n[r]) << 12 | (63 & n[r + 1]) << 6 | 63 & n[r + 2];
- if (o >= 2048 && 55296 != (63488 & o)) {
- t.push(String.fromCharCode(65535 & o)), r += 3;
- continue
- }
- }
- } else if (n[r] < 248 && i(n, r, 3)) {
- var u = (7 & n[r]) << 18 | (63 & n[r + 1]) << 12 | (63 & n[r + 2]) << 6 | 63 & n[r + 3];
- if (u > 65536 && u < 1114112) {
- u -= 65536, t.push(String.fromCharCode(u >>> 10 | 55296)), t.push(String.fromCharCode(1023 & u | 56320)), r += 4;
- continue
- }
- }
- t.push(String.fromCharCode(65533)), ++r
- } return t.join("")
- }
- Object.defineProperty(n, "__esModule", {
- value: !0
- }), n.default = r
- }, {}]
- }, {}, [21])(21)
-});
-//# sourceMappingURL=flv.min.js.map
\ No newline at end of file
+!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,t.flvjs=e()}}(function(){var e;return function e(t,n,i){function r(a,o){if(!n[a]){if(!t[a]){var u="function"==typeof require&&require;if(!o&&u)return u(a,!0);if(s)return s(a,!0);var l=new Error("Cannot find module '"+a+"'");throw l.code="MODULE_NOT_FOUND",l}var d=n[a]={exports:{}};t[a][0].call(d.exports,function(e){var n=t[a][1][e];return r(n||e)},d,d.exports,e,t,n,i)}return n[a].exports}for(var s="function"==typeof require&&require,a=0;a
0&&this._events[e].length>n&&(this._events[e].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[e].length),"function"==typeof console.trace&&console.trace()),this},i.prototype.on=i.prototype.addListener,i.prototype.once=function(e,t){function n(){this.removeListener(e,n),i||(i=!0,t.apply(this,arguments))}if(!r(t))throw TypeError("listener must be a function");var i=!1;return n.listener=t,this.on(e,n),this},i.prototype.removeListener=function(e,t){var n,i,s,o;if(!r(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;if(n=this._events[e],s=n.length,i=-1,n===t||r(n.listener)&&n.listener===t)delete this._events[e],this._events.removeListener&&this.emit("removeListener",e,t);else if(a(n)){for(o=s;o-- >0;)if(n[o]===t||n[o].listener&&n[o].listener===t){i=o;break}if(i<0)return this;1===n.length?(n.length=0,delete this._events[e]):n.splice(i,1),this._events.removeListener&&this.emit("removeListener",e,t)}return this},i.prototype.removeAllListeners=function(e){var t,n;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[e]&&delete this._events[e],this;if(0===arguments.length){for(t in this._events)"removeListener"!==t&&this.removeAllListeners(t);return this.removeAllListeners("removeListener"),this._events={},this}if(n=this._events[e],r(n))this.removeListener(e,n);else if(n)for(;n.length;)this.removeListener(e,n[n.length-1]);return delete this._events[e],this},i.prototype.listeners=function(e){return this._events&&this._events[e]?r(this._events[e])?[this._events[e]]:this._events[e].slice():[]},i.prototype.listenerCount=function(e){if(this._events){var t=this._events[e];if(r(t))return 1;if(t)return t.length}return 0},i.listenerCount=function(e,t){return e.listenerCount(t)}},{}],3:[function(e,t,n){function i(){throw new Error("setTimeout has not been defined")}function r(){throw new Error("clearTimeout has not been defined")}function s(e){if(h===setTimeout)return setTimeout(e,0);if((h===i||!h)&&setTimeout)return h=setTimeout,setTimeout(e,0);try{return h(e,0)}catch(t){try{return h.call(null,e,0)}catch(t){return h.call(this,e,0)}}}function a(e){if(f===clearTimeout)return clearTimeout(e);if((f===r||!f)&&clearTimeout)return f=clearTimeout,clearTimeout(e);try{return f(e)}catch(t){try{return f.call(null,e)}catch(t){return f.call(this,e)}}}function o(){p&&_&&(p=!1,_.length?m=_.concat(m):v=-1,m.length&&u())}function u(){if(!p){var e=s(o);p=!0;for(var t=m.length;t;){for(_=m,m=[];++v1)for(var n=1;n=e[r]&&t0&&e[0].originalDts=t[r].dts&&et[i].lastSample.originalDts&&e=t[i].lastSample.originalDts&&(i===t.length-1||i0&&(r=this._searchNearestSegmentBefore(n.originalBeginDts)+1),this._lastAppendLocation=r,this._list.splice(r,0,n)}},{key:"getLastSegmentBefore",value:function(e){var t=this._searchNearestSegmentBefore(e);return t>=0?this._list[t]:null}},{key:"getLastSampleBefore",value:function(e){var t=this.getLastSegmentBefore(e);return null!=t?t.lastSample:null}},{key:"getLastSyncPointBefore",value:function(e){for(var t=this._searchNearestSegmentBefore(e),n=this._list[t].syncPoints;0===n.length&&t>0;)t--,n=this._list[t].syncPoints;return n.length>0?n[n.length-1]:null}},{key:"type",get:function(){return this._type}},{key:"length",get:function(){return this._list.length}}]),e}()},{}],9:[function(e,t,n){"use strict";function i(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(n,"__esModule",{value:!0});var s=function(){function e(e,t){for(var n=0;n0&&(i+=";codecs="+n.codec);var r=!1;if(l.default.v(this.TAG,"Received Initialization Segment, mimeType: "+i),this._lastInitSegments[n.type]=n,i!==this._mimeTypes[n.type]){if(this._mimeTypes[n.type])l.default.v(this.TAG,"Notice: "+n.type+" mimeType changed, origin: "+this._mimeTypes[n.type]+", target: "+i);else{r=!0;try{var s=this._sourceBuffers[n.type]=this._mediaSource.addSourceBuffer(i);s.addEventListener("error",this.e.onSourceBufferError),s.addEventListener("updateend",this.e.onSourceBufferUpdateEnd)}catch(e){return l.default.e(this.TAG,e.message),void this._emitter.emit(c.default.ERROR,{code:e.code,msg:e.message})}}this._mimeTypes[n.type]=i}t||this._pendingSegments[n.type].push(n),r||this._sourceBuffers[n.type]&&!this._sourceBuffers[n.type].updating&&this._doAppendSegments(),h.default.safari&&"audio/mpeg"===n.container&&n.mediaDuration>0&&(this._requireSetMediaDuration=!0,this._pendingMediaDuration=n.mediaDuration/1e3,this._updateMediaSourceDuration())}},{key:"appendMediaSegment",value:function(e){var t=e;this._pendingSegments[t.type].push(t),this._config.autoCleanupSourceBuffer&&this._needCleanupSourceBuffer()&&this._doCleanupSourceBuffer();var n=this._sourceBuffers[t.type];!n||n.updating||this._hasPendingRemoveRanges()||this._doAppendSegments()}},{key:"seek",value:function(e){for(var t in this._sourceBuffers)if(this._sourceBuffers[t]){var n=this._sourceBuffers[t];if("open"===this._mediaSource.readyState)try{n.abort()}catch(e){l.default.e(this.TAG,e.message)}this._idrList.clear();var i=this._pendingSegments[t];if(i.splice(0,i.length),"closed"!==this._mediaSource.readyState){for(var r=0;r=1&&e-i.start(0)>=this._config.autoCleanupMaxBackwardDuration)return!0}}return!1}},{key:"_doCleanupSourceBuffer",value:function(){var e=this._mediaElement.currentTime;for(var t in this._sourceBuffers){var n=this._sourceBuffers[t];if(n){for(var i=n.buffered,r=!1,s=0;s=this._config.autoCleanupMaxBackwardDuration){r=!0;var u=e-this._config.autoCleanupMinBackwardDuration;this._pendingRemoveRanges[t].push({start:a,end:u})}}else o0&&(isNaN(t)||n>t)&&(l.default.v(this.TAG,"Update MediaSource duration from "+t+" to "+n),this._mediaSource.duration=n),this._requireSetMediaDuration=!1,this._pendingMediaDuration=0}}},{key:"_doRemoveRanges",value:function(){for(var e in this._pendingRemoveRanges)if(this._sourceBuffers[e]&&!this._sourceBuffers[e].updating)for(var t=this._sourceBuffers[e],n=this._pendingRemoveRanges[e];n.length&&!t.updating;){var i=n.shift();t.remove(i.start,i.end)}}},{key:"_doAppendSegments",value:function(){var e=this._pendingSegments;for(var t in e)if(this._sourceBuffers[t]&&!this._sourceBuffers[t].updating&&e[t].length>0){var n=e[t].shift();if(n.timestampOffset){var i=this._sourceBuffers[t].timestampOffset,r=n.timestampOffset/1e3,s=Math.abs(i-r);s>.1&&(l.default.v(this.TAG,"Update MPEG audio timestampOffset from "+i+" to "+r),this._sourceBuffers[t].timestampOffset=r),delete n.timestampOffset}if(!n.data||0===n.data.byteLength)continue;try{this._sourceBuffers[t].appendBuffer(n.data),this._isBufferFull=!1,"video"===t&&n.hasOwnProperty("info")&&this._idrList.appendArray(n.info.syncPoints)}catch(e){this._pendingSegments[t].unshift(n),22===e.code?(this._isBufferFull||this._emitter.emit(c.default.BUFFER_FULL),this._isBufferFull=!0):(l.default.e(this.TAG,e.message),this._emitter.emit(c.default.ERROR,{code:e.code,msg:e.message}))}}}},{key:"_onSourceOpen",value:function(){if(l.default.v(this.TAG,"MediaSource onSourceOpen"),this._mediaSource.removeEventListener("sourceopen",this.e.onSourceOpen),this._pendingSourceBufferInit.length>0)for(var e=this._pendingSourceBufferInit;e.length;){var t=e.shift();this.appendInitSegment(t,!0)}this._hasPendingSegments()&&this._doAppendSegments(),this._emitter.emit(c.default.SOURCE_OPEN)}},{key:"_onSourceEnded",value:function(){l.default.v(this.TAG,"MediaSource onSourceEnded")}},{key:"_onSourceClose",value:function(){l.default.v(this.TAG,"MediaSource onSourceClose"),this._mediaSource&&null!=this.e&&(this._mediaSource.removeEventListener("sourceopen",this.e.onSourceOpen),this._mediaSource.removeEventListener("sourceended",this.e.onSourceEnded),this._mediaSource.removeEventListener("sourceclose",this.e.onSourceClose))}},{key:"_hasPendingSegments",value:function(){var e=this._pendingSegments;return e.video.length>0||e.audio.length>0}},{key:"_hasPendingRemoveRanges",value:function(){var e=this._pendingRemoveRanges;return e.video.length>0||e.audio.length>0}},{key:"_onSourceBufferUpdateEnd",value:function(){this._requireSetMediaDuration?this._updateMediaSourceDuration():this._hasPendingRemoveRanges()?this._doRemoveRanges():this._hasPendingSegments()?this._doAppendSegments():this._hasPendingEos&&this.endOfStream(),this._emitter.emit(c.default.UPDATE_END)}},{key:"_onSourceBufferError",value:function(e){l.default.e(this.TAG,"SourceBuffer Error: "+e)}}]),e}();n.default=p},{"../utils/browser.js":39,"../utils/exception.js":40,"../utils/logger.js":41,"./media-segment-info.js":8,"./mse-events.js":10,events:2}],10:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var i={ERROR:"error",SOURCE_OPEN:"source_open",UPDATE_END:"update_end",BUFFER_FULL:"buffer_full"};n.default=i},{}],11:[function(e,t,n){"use strict";function i(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(n,"__esModule",{value:!0});var s=function(){function e(e,t){for(var n=0;n0)this._demuxer.bindDataSource(this._ioctl),this._demuxer.timestampBase=this._mediaDataSource.segments[this._currentSegmentIndex].timestampBase,r=this._demuxer.parseChunks(e,t);else if((i=m.default.probe(e)).match){this._demuxer=new m.default(i,this._config),this._remuxer||(this._remuxer=new v.default(this._config));var s=this._mediaDataSource;void 0==s.duration||isNaN(s.duration)||(this._demuxer.overridedDuration=s.duration),"boolean"==typeof s.hasAudio&&(this._demuxer.overridedHasAudio=s.hasAudio),"boolean"==typeof s.hasVideo&&(this._demuxer.overridedHasVideo=s.hasVideo),this._demuxer.timestampBase=s.segments[this._currentSegmentIndex].timestampBase,this._demuxer.onError=this._onDemuxException.bind(this),this._demuxer.onMediaInfo=this._onMediaInfo.bind(this),this._remuxer.bindDataSource(this._demuxer.bindDataSource(this._ioctl)),this._remuxer.onInitSegment=this._onRemuxerInitSegmentArrival.bind(this),this._remuxer.onMediaSegment=this._onRemuxerMediaSegmentArrival.bind(this),r=this._demuxer.parseChunks(e,t)}else i=null,l.default.e(this.TAG,"Non-FLV, Unsupported media type!"),Promise.resolve().then(function(){n._internalAbort()}),this._emitter.emit(k.default.DEMUX_ERROR,y.default.FORMAT_UNSUPPORTED,"Non-FLV, Unsupported media type"),r=0;return r}},{key:"_onMediaInfo",value:function(e){var t=this;null==this._mediaInfo&&(this._mediaInfo=Object.assign({},e),this._mediaInfo.keyframesIndex=null,this._mediaInfo.segments=[],this._mediaInfo.segmentCount=this._mediaDataSource.segments.length,Object.setPrototypeOf(this._mediaInfo,c.default.prototype));var n=Object.assign({},e);Object.setPrototypeOf(n,c.default.prototype),this._mediaInfo.segments[this._currentSegmentIndex]=n,this._reportSegmentMediaInfo(this._currentSegmentIndex),null!=this._pendingSeekTime&&Promise.resolve().then(function(){var e=t._pendingSeekTime;t._pendingSeekTime=null,t.seek(e)})}},{key:"_onIOSeeked",value:function(){this._remuxer.insertDiscontinuity()}},{key:"_onIOComplete",value:function(e){var t=e,n=t+1;n0&&n[0].originalDts===i&&(i=n[0].pts),this._emitter.emit(k.default.RECOMMEND_SEEKPOINT,i)}}},{key:"_enableStatisticsReporter",value:function(){null==this._statisticsReporter&&(this._statisticsReporter=self.setInterval(this._reportStatisticsInfo.bind(this),this._config.statisticsInfoReportInterval))}},{key:"_disableStatisticsReporter",value:function(){this._statisticsReporter&&(self.clearInterval(this._statisticsReporter),this._statisticsReporter=null)}},{key:"_reportSegmentMediaInfo",value:function(e){var t=this._mediaInfo.segments[e],n=Object.assign({},t);n.duration=this._mediaInfo.duration,n.segmentCount=this._mediaInfo.segmentCount,delete n.segments,delete n.keyframesIndex,this._emitter.emit(k.default.MEDIA_INFO,n)}},{key:"_reportStatisticsInfo",value:function(){var e={};e.url=this._ioctl.currentURL,e.hasRedirect=this._ioctl.hasRedirect,e.hasRedirect&&(e.redirectedURL=this._ioctl.currentRedirectedURL),e.speed=this._ioctl.currentSpeed,e.loaderType=this._ioctl.loaderType,e.currentSegmentIndex=this._currentSegmentIndex,e.totalSegmentCount=this._mediaDataSource.segments.length,this._emitter.emit(k.default.STATISTICS_INFO,e)}}]),e}());n.default=L},{"../demux/demux-errors.js":16,"../demux/flv-demuxer.js":18,"../io/io-controller.js":23,"../io/loader.js":24,"../remux/mp4-remuxer.js":38,"../utils/browser.js":39,"../utils/logger.js":41,"./media-info.js":7,"./transmuxing-events.js":13,events:2}],13:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var i={IO_ERROR:"io_error",DEMUX_ERROR:"demux_error",INIT_SEGMENT:"init_segment",MEDIA_SEGMENT:"media_segment",LOADING_COMPLETE:"loading_complete",RECOVERED_EARLY_EOF:"recovered_early_eof",MEDIA_INFO:"media_info",STATISTICS_INFO:"statistics_info",RECOMMEND_SEEKPOINT:"recommend_seekpoint"};n.default=i},{}],14:[function(e,t,n){"use strict";function i(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(n,"__esModule",{value:!0});var r=e("../utils/logger.js"),s=(i(r),e("../utils/logging-control.js")),a=i(s),o=e("../utils/polyfill.js"),u=i(o),l=e("./transmuxing-controller.js"),d=i(l),h=e("./transmuxing-events.js"),f=i(h),c=function(e){function t(t,n){var i={msg:f.default.INIT_SEGMENT,data:{type:t,data:n}};e.postMessage(i,[n.data])}function n(t,n){var i={msg:f.default.MEDIA_SEGMENT,data:{type:t,data:n}};e.postMessage(i,[n.data])}function i(){var t={msg:f.default.LOADING_COMPLETE};e.postMessage(t)}function r(){var t={msg:f.default.RECOVERED_EARLY_EOF};e.postMessage(t)}function s(t){var n={msg:f.default.MEDIA_INFO,data:t};e.postMessage(n)}function o(t){var n={msg:f.default.STATISTICS_INFO,data:t};e.postMessage(n)}function l(t,n){e.postMessage({msg:f.default.IO_ERROR,data:{type:t,info:n}})}function h(t,n){e.postMessage({msg:f.default.DEMUX_ERROR,data:{type:t,info:n}})}function c(t){e.postMessage({msg:f.default.RECOMMEND_SEEKPOINT,data:t})}function _(t,n){e.postMessage({msg:"logcat_callback",data:{type:t,logcat:n}})}var m=null,p=_.bind(this);u.default.install(),e.addEventListener("message",function(u){switch(u.data.cmd){case"init":m=new d.default(u.data.param[0],u.data.param[1]),m.on(f.default.IO_ERROR,l.bind(this)),m.on(f.default.DEMUX_ERROR,h.bind(this)),m.on(f.default.INIT_SEGMENT,t.bind(this)),m.on(f.default.MEDIA_SEGMENT,n.bind(this)),m.on(f.default.LOADING_COMPLETE,i.bind(this)),m.on(f.default.RECOVERED_EARLY_EOF,r.bind(this)),m.on(f.default.MEDIA_INFO,s.bind(this)),m.on(f.default.STATISTICS_INFO,o.bind(this)),m.on(f.default.RECOMMEND_SEEKPOINT,c.bind(this));break;case"destroy":m&&(m.destroy(),m=null),e.postMessage({msg:"destroyed"});break;case"start":m.start();break;case"stop":m.stop();break;case"seek":m.seek(u.data.param);break;case"pause":m.pause();break;case"resume":m.resume();break;case"logging_config":var _=u.data.param;a.default.applyConfig(_),!0===_.enableCallback?a.default.addLogListener(p):a.default.removeLogListener(p)}})};n.default=c},{"../utils/logger.js":41,"../utils/logging-control.js":42,"../utils/polyfill.js":43,"./transmuxing-controller.js":12,"./transmuxing-events.js":13}],15:[function(e,t,n){"use strict";function i(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(n,"__esModule",{value:!0});var s=function(){function e(e,t){for(var n=0;n0?(0,l.default)(new Uint8Array(e,t+2,r)):"",{data:s,size:2+r}}},{key:"parseLongString",value:function(e,t,n){if(n<4)throw new d.IllegalStateException("Data not enough when parse LongString");var i=new DataView(e,t,n),r=i.getUint32(0,!h),s=void 0;return s=r>0?(0,l.default)(new Uint8Array(e,t+4,r)):"",{data:s,size:4+r}}},{key:"parseDate",value:function(e,t,n){if(n<10)throw new d.IllegalStateException("Data size invalid when parse Date");var i=new DataView(e,t,n),r=i.getFloat64(0,!h);return r+=60*i.getInt16(8,!h)*1e3,{data:new Date(r),size:10}}},{key:"parseValue",value:function(t,n,i){if(i<1)throw new d.IllegalStateException("Data not enough when parse Value");var r=new DataView(t,n,i),s=1,a=r.getUint8(0),u=void 0,l=!1;try{switch(a){case 0:u=r.getFloat64(1,!h),s+=8;break;case 1:u=!!r.getUint8(1),s+=1;break;case 2:var f=e.parseString(t,n+1,i-1);u=f.data,s+=f.size;break;case 3:u={};var c=0;for(9==(16777215&r.getUint32(i-4,!h))&&(c=3);s32)throw new s.InvalidArgumentException("ExpGolomb: readBits() bits exceeded max 32bits!");if(e<=this._current_word_bits_left){var t=this._current_word>>>32-e;return this._current_word<<=e,this._current_word_bits_left-=e,t}var n=this._current_word_bits_left?this._current_word:0;n>>>=32-this._current_word_bits_left;var i=e-this._current_word_bits_left;this._fillCurrentWord();var r=Math.min(i,this._current_word_bits_left),a=this._current_word>>>32-r;return this._current_word<<=r,this._current_word_bits_left-=r,n=n<>>e))return this._current_word<<=e,this._current_word_bits_left-=e,e;return this._fillCurrentWord(),e+this._skipLeadingZero()}},{key:"readUEG",value:function(){var e=this._skipLeadingZero();return this.readBits(e+1)-1}},{key:"readSEG",value:function(){var e=this.readUEG();return 1&e?e+1>>>1:-1*(e>>>1)}}]),e}();n.default=a},{"../utils/exception.js":40}],18:[function(e,t,n){"use strict";function i(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function s(e,t){return e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3]}Object.defineProperty(n,"__esModule",{value:!0});var a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},o=function(){function e(e,t){for(var n=0;n13))return 0;i=e.probe(t).dataOffset}if(this._firstParse){this._firstParse=!1,n+i!==this._dataOffset&&l.default.w(this.TAG,"First time parsing but chunk byteStart invalid!");0!==new DataView(t,i).getUint32(0,!r)&&l.default.w(this.TAG,"PrevTagSize0 !== 0 !!!"),i+=4}for(;it.byteLength)break;var a=s.getUint8(0),o=16777215&s.getUint32(0,!r);if(i+11+o+4>t.byteLength)break;if(8===a||9===a||18===a){var u=s.getUint8(4),d=s.getUint8(5),h=s.getUint8(6),f=s.getUint8(7),c=h|d<<8|u<<16|f<<24;0!==(16777215&s.getUint32(7,!r))&&l.default.w(this.TAG,"Meet tag which has StreamID != 0!");var _=i+11;switch(a){case 8:this._parseAudioData(t,_,o,c);break;case 9:this._parseVideoData(t,_,o,c,n+i);break;case 18:this._parseScriptData(t,_,o)}var m=s.getUint32(11+o,!r);m!==11+o&&l.default.w(this.TAG,"Invalid PrevTagSize "+m),i+=11+o+4}else l.default.w(this.TAG,"Unsupported tag type "+a+", skipped"),i+=11+o+4}return this._isInitialMetadataDispatched()&&this._dispatch&&(this._audioTrack.length||this._videoTrack.length)&&this._onDataAvailable(this._audioTrack,this._videoTrack),i}},{key:"_parseScriptData",value:function(e,t,n){var i=h.default.parseScriptData(e,t,n);if(i.hasOwnProperty("onMetaData")){if(null==i.onMetaData||"object"!==a(i.onMetaData))return void l.default.w(this.TAG,"Invalid onMetaData structure!");this._metadata&&l.default.w(this.TAG,"Found another onMetaData tag!"),this._metadata=i;var r=this._metadata.onMetaData;if("boolean"==typeof r.hasAudio&&!1===this._hasAudioFlagOverrided&&(this._hasAudio=r.hasAudio,this._mediaInfo.hasAudio=this._hasAudio),"boolean"==typeof r.hasVideo&&!1===this._hasVideoFlagOverrided&&(this._hasVideo=r.hasVideo,this._mediaInfo.hasVideo=this._hasVideo),"number"==typeof r.audiodatarate&&(this._mediaInfo.audioDataRate=r.audiodatarate),"number"==typeof r.videodatarate&&(this._mediaInfo.videoDataRate=r.videodatarate),"number"==typeof r.width&&(this._mediaInfo.width=r.width),"number"==typeof r.height&&(this._mediaInfo.height=r.height),"number"==typeof r.duration){if(!this._durationOverrided){var s=Math.floor(r.duration*this._timescale);this._duration=s,this._mediaInfo.duration=s}}else this._mediaInfo.duration=0;if("number"==typeof r.framerate){var o=Math.floor(1e3*r.framerate);if(o>0){var u=o/1e3;this._referenceFrameRate.fixed=!0,this._referenceFrameRate.fps=u,this._referenceFrameRate.fps_num=o,this._referenceFrameRate.fps_den=1e3,this._mediaInfo.fps=u}}if("object"===a(r.keyframes)){this._mediaInfo.hasKeyframesIndex=!0;var d=r.keyframes;this._mediaInfo.keyframesIndex=this._parseKeyframesIndex(d),r.keyframes=null}else this._mediaInfo.hasKeyframesIndex=!1;this._dispatch=!1,this._mediaInfo.metadata=r,l.default.v(this.TAG,"Parsed onMetaData"),this._mediaInfo.isComplete()&&this._onMediaInfo(this._mediaInfo)}}},{key:"_parseKeyframesIndex",value:function(e){for(var t=[],n=[],i=1;i>>4;if(2!==a&&10!==a)return void this._onError(m.default.CODEC_UNSUPPORTED,"Flv: Unsupported audio codec idx: "+a);var o=0,u=(12&s)>>>2;if(!(u>=0&&u<=4))return void this._onError(m.default.FORMAT_ERROR,"Flv: Invalid audio sample rate idx: "+u);o=this._flvSoundRateTable[u];var d=1&s,h=this._audioMetadata,f=this._audioTrack;if(h||(!1===this._hasAudio&&!1===this._hasAudioFlagOverrided&&(this._hasAudio=!0,this._mediaInfo.hasAudio=!0),h=this._audioMetadata={},h.type="audio",h.id=f.id,h.timescale=this._timescale,h.duration=this._duration,h.audioSampleRate=o,h.channelCount=0===d?1:2),10===a){var c=this._parseAACAudioData(e,t+1,n-1);if(void 0==c)return;if(0===c.packetType){h.config&&l.default.w(this.TAG,"Found another AudioSpecificConfig!");var _=c.data;h.audioSampleRate=_.samplingRate,h.channelCount=_.channelCount,h.codec=_.codec,h.originalCodec=_.originalCodec,h.config=_.config,h.refSampleDuration=1024/h.audioSampleRate*h.timescale,l.default.v(this.TAG,"Parsed AudioSpecificConfig"),this._isInitialMetadataDispatched()?this._dispatch&&(this._audioTrack.length||this._videoTrack.length)&&this._onDataAvailable(this._audioTrack,this._videoTrack):this._audioInitialMetadataDispatched=!0,this._dispatch=!1,this._onTrackMetadata("audio",h);var p=this._mediaInfo;p.audioCodec=h.originalCodec,p.audioSampleRate=h.audioSampleRate,p.audioChannelCount=h.channelCount,p.hasVideo?null!=p.videoCodec&&(p.mimeType='video/x-flv; codecs="'+p.videoCodec+","+p.audioCodec+'"'):p.mimeType='video/x-flv; codecs="'+p.audioCodec+'"',p.isComplete()&&this._onMediaInfo(p)}else if(1===c.packetType){var v=this._timestampBase+i,g={unit:c.data,length:c.data.byteLength,dts:v,pts:v};f.samples.push(g),f.length+=c.data.length}else l.default.e(this.TAG,"Flv: Unsupported AAC data type "+c.packetType)}else if(2===a){if(!h.codec){var y=this._parseMP3AudioData(e,t+1,n-1,!0);if(void 0==y)return;h.audioSampleRate=y.samplingRate,h.channelCount=y.channelCount,h.codec=y.codec,h.originalCodec=y.originalCodec,h.refSampleDuration=1152/h.audioSampleRate*h.timescale,l.default.v(this.TAG,"Parsed MPEG Audio Frame Header"),this._audioInitialMetadataDispatched=!0,this._onTrackMetadata("audio",h);var E=this._mediaInfo;E.audioCodec=h.codec,E.audioSampleRate=h.audioSampleRate,E.audioChannelCount=h.channelCount,E.audioDataRate=y.bitRate,E.hasVideo?null!=E.videoCodec&&(E.mimeType='video/x-flv; codecs="'+E.videoCodec+","+E.audioCodec+'"'):E.mimeType='video/x-flv; codecs="'+E.audioCodec+'"',E.isComplete()&&this._onMediaInfo(E)}var b=this._parseMP3AudioData(e,t+1,n-1,!1);if(void 0==b)return
+;var S=this._timestampBase+i,k={unit:b,length:b.byteLength,dts:S,pts:S};f.samples.push(k),f.length+=b.length}}}},{key:"_parseAACAudioData",value:function(e,t,n){if(n<=1)return void l.default.w(this.TAG,"Flv: Invalid AAC packet, missing AACPacketType or/and Data!");var i={},r=new Uint8Array(e,t,n);return i.packetType=r[0],0===r[0]?i.data=this._parseAACAudioSpecificConfig(e,t+1,n-1):i.data=r.subarray(1),i}},{key:"_parseAACAudioSpecificConfig",value:function(e,t,n){var i=new Uint8Array(e,t,n),r=null,s=0,a=0,o=0,u=null;if(s=a=i[0]>>>3,(o=(7&i[0])<<1|i[1]>>>7)<0||o>=this._mpegSamplingRates.length)return void this._onError(m.default.FORMAT_ERROR,"Flv: AAC invalid sampling frequency index!");var l=this._mpegSamplingRates[o],d=(120&i[1])>>>3;if(d<0||d>=8)return void this._onError(m.default.FORMAT_ERROR,"Flv: AAC invalid channel configuration");5===s&&(u=(7&i[1])<<1|i[2]>>>7,i[2]);var h=self.navigator.userAgent.toLowerCase();return-1!==h.indexOf("firefox")?o>=6?(s=5,r=new Array(4),u=o-3):(s=2,r=new Array(2),u=o):-1!==h.indexOf("android")?(s=2,r=new Array(2),u=o):(s=5,u=o,r=new Array(4),o>=6?u=o-3:1===d&&(s=2,r=new Array(2),u=o)),r[0]=s<<3,r[0]|=(15&o)>>>1,r[1]=(15&o)<<7,r[1]|=(15&d)<<3,5===s&&(r[1]|=(15&u)>>>1,r[2]=(1&u)<<7,r[2]|=8,r[3]=0),{config:r,samplingRate:l,channelCount:d,codec:"mp4a.40."+s,originalCodec:"mp4a.40."+a}}},{key:"_parseMP3AudioData",value:function(e,t,n,i){if(n<4)return void l.default.w(this.TAG,"Flv: Invalid MP3 packet, header missing!");var r=(this._littleEndian,new Uint8Array(e,t,n)),s=null;if(i){if(255!==r[0])return;var a=r[1]>>>3&3,o=(6&r[1])>>1,u=(240&r[2])>>>4,d=(12&r[2])>>>2,h=r[3]>>>6&3,f=3!==h?2:1,c=0,_=0;switch(a){case 0:c=this._mpegAudioV25SampleRateTable[d];break;case 2:c=this._mpegAudioV20SampleRateTable[d];break;case 3:c=this._mpegAudioV10SampleRateTable[d]}switch(o){case 1:34,u>>4,o=15&s;if(7!==o)return void this._onError(m.default.CODEC_UNSUPPORTED,"Flv: Unsupported codec in video frame: "+o);this._parseAVCVideoPacket(e,t+1,n-1,i,r,a)}}},{key:"_parseAVCVideoPacket",value:function(e,t,n,i,r,s){if(n<4)return void l.default.w(this.TAG,"Flv: Invalid AVC packet, missing AVCPacketType or/and CompositionTime");var a=this._littleEndian,o=new DataView(e,t,n),u=o.getUint8(0),d=16777215&o.getUint32(0,!a),h=d<<8>>8;if(0===u)this._parseAVCDecoderConfigurationRecord(e,t+4,n-4);else if(1===u)this._parseAVCVideoData(e,t+4,n-4,i,r,s,h);else if(2!==u)return void this._onError(m.default.FORMAT_ERROR,"Flv: Invalid video packet type "+u)}},{key:"_parseAVCDecoderConfigurationRecord",value:function(e,t,n){if(n<7)return void l.default.w(this.TAG,"Flv: Invalid AVCDecoderConfigurationRecord, lack of data!");var i=this._videoMetadata,r=this._videoTrack,s=this._littleEndian,a=new DataView(e,t,n);i?void 0!==i.avcc&&l.default.w(this.TAG,"Found another AVCDecoderConfigurationRecord!"):(!1===this._hasVideo&&!1===this._hasVideoFlagOverrided&&(this._hasVideo=!0,this._mediaInfo.hasVideo=!0),i=this._videoMetadata={},i.type="video",i.id=r.id,i.timescale=this._timescale,i.duration=this._duration);var o=a.getUint8(0),u=a.getUint8(1);a.getUint8(2),a.getUint8(3);if(1!==o||0===u)return void this._onError(m.default.FORMAT_ERROR,"Flv: Invalid AVCDecoderConfigurationRecord");if(this._naluLengthSize=1+(3&a.getUint8(4)),3!==this._naluLengthSize&&4!==this._naluLengthSize)return void this._onError(m.default.FORMAT_ERROR,"Flv: Strange NaluLengthSizeMinusOne: "+(this._naluLengthSize-1));var d=31&a.getUint8(5);if(0===d)return void this._onError(m.default.FORMAT_ERROR,"Flv: Invalid AVCDecoderConfigurationRecord: No SPS");d>1&&l.default.w(this.TAG,"Flv: Strange AVCDecoderConfigurationRecord: SPS Count = "+d);for(var h=6,f=0;f1&&l.default.w(this.TAG,"Flv: Strange AVCDecoderConfigurationRecord: PPS Count = "+w),h++;for(var R=0;R=n){l.default.w(this.TAG,"Malformed Nalu near timestamp "+_+", offset = "+f+", dataSize = "+n);break}var p=u.getUint32(f,!o);if(3===c&&(p>>>=8),p>n-c)return void l.default.w(this.TAG,"Malformed Nalus near timestamp "+_+", NaluSize > DataSize!");var v=31&u.getUint8(f+c);5===v&&(m=!0);var g=new Uint8Array(e,t+f,c+p),y={type:v,data:g};d.push(y),h+=g.byteLength,f+=c+p}if(d.length){var E=this._videoTrack,b={units:d,length:h,isKeyframe:m,dts:_,cts:a,pts:_+a};m&&(b.fileposition=r),E.samples.push(b),E.length+=h}}},{key:"onTrackMetadata",get:function(){return this._onTrackMetadata},set:function(e){this._onTrackMetadata=e}},{key:"onMediaInfo",get:function(){return this._onMediaInfo},set:function(e){this._onMediaInfo=e}},{key:"onError",get:function(){return this._onError},set:function(e){this._onError=e}},{key:"onDataAvailable",get:function(){return this._onDataAvailable},set:function(e){this._onDataAvailable=e}},{key:"timestampBase",get:function(){return this._timestampBase},set:function(e){this._timestampBase=e}},{key:"overridedDuration",get:function(){return this._duration},set:function(e){this._durationOverrided=!0,this._duration=e,this._mediaInfo.duration=e}},{key:"overridedHasAudio",set:function(e){this._hasAudioFlagOverrided=!0,this._hasAudio=e,this._mediaInfo.hasAudio=e}},{key:"overridedHasVideo",set:function(e){this._hasVideoFlagOverrided=!0,this._hasVideo=e,this._mediaInfo.hasVideo=e}}],[{key:"probe",value:function(e){var t=new Uint8Array(e),n={match:!1};if(70!==t[0]||76!==t[1]||86!==t[2]||1!==t[3])return n;var i=(4&t[4])>>>2!=0,r=0!=(1&t[4]),a=s(t,5);return a<9?n:{match:!0,consumed:a,dataOffset:a,hasAudioTrack:i,hasVideoTrack:r}}}]),e}();n.default=y},{"../core/media-info.js":7,"../utils/exception.js":40,"../utils/logger.js":41,"./amf-parser.js":15,"./demux-errors.js":16,"./sps-parser.js":19}],19:[function(e,t,n){"use strict";function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(n,"__esModule",{value:!0});var r=function(){function e(e,t){for(var n=0;n=2&&3===t[s]&&0===t[s-1]&&0===t[s-2]||(i[r]=t[s],r++);return new Uint8Array(i.buffer,0,r)}},{key:"parseSPS",value:function(t){var n=e._ebsp2rbsp(t),i=new a.default(n);i.readByte();var r=i.readByte();i.readByte();var s=i.readByte();i.readUEG();var o=e.getProfileString(r),u=e.getLevelString(s),l=1,d=420,h=[0,420,422,444],f=8;if((100===r||110===r||122===r||244===r||44===r||83===r||86===r||118===r||128===r||138===r||144===r)&&(l=i.readUEG(),3===l&&i.readBits(1),l<=3&&(d=h[l]),f=i.readUEG()+8,i.readUEG(),i.readBits(1),i.readBool()))for(var c=3!==l?8:12,_=0;_0&&x<16?(R=M[x-1],A=D[x-1]):255===x&&(R=i.readByte()<<8|i.readByte(),A=i.readByte()<<8|i.readByte())}if(i.readBool()&&i.readBool(),i.readBool()&&(i.readBits(4),i.readBool()&&i.readBits(24)),i.readBool()&&(i.readUEG(),i.readUEG()),i.readBool()){var B=i.readBits(32),j=i.readBits(32);T=i.readBool(),C=j,I=2*B,O=C/I}}var P=1;1===R&&1===A||(P=R/A);var U=0,N=0;if(0===l)U=1,N=2-b;else{var F=3===l?1:2,G=1===l?2:1;U=F,N=G*(2-b)}var V=16*(y+1),z=16*(E+1)*(2-b);V-=(S+k)*U,z-=(L+w)*N;var H=Math.ceil(V*P);return i.destroy(),i=null,{profile_string:o,level_string:u,bit_depth:f,ref_frames:g,chroma_format:d,chroma_format_string:e.getChromaFormatString(d),frame_rate:{fixed:T,fps:O,fps_den:I,fps_num:C},sar_ratio:{width:R,height:A},codec_size:{width:V,height:z},present_size:{width:H,height:z}}}},{key:"_skipScalingList",value:function(e,t){for(var n=8,i=8,r=0,s=0;s=15048,t=!f.default.msedge||e;return self.fetch&&self.ReadableStream&&t}catch(e){return!1}}}]),l(t,[{key:"destroy",value:function(){this.isWorking()&&this.abort(),u(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"destroy",this).call(this)}},{key:"open",value:function(e,t){var n=this;this._dataSource=e,this._range=t;var i=e.url;this._config.reuseRedirectedURL&&void 0!=e.redirectedURL&&(i=e.redirectedURL);var r=this._seekHandler.getConfig(i,t),s=new self.Headers;if("object"===o(r.headers)){var a=r.headers;for(var u in a)a.hasOwnProperty(u)&&s.append(u,a[u])}var l={method:"GET",headers:s,mode:"cors",cache:"default",referrerPolicy:"no-referrer-when-downgrade"};!1===e.cors&&(l.mode="same-origin"),e.withCredentials&&(l.credentials="include"),e.referrerPolicy&&(l.referrerPolicy=e.referrerPolicy),this._status=c.LoaderStatus.kConnecting,self.fetch(r.url,l).then(function(e){if(n._requestAbort)return n._requestAbort=!1,void(n._status=c.LoaderStatus.kIdle);if(e.ok&&e.status>=200&&e.status<=299){if(e.url!==r.url&&n._onURLRedirect){var t=n._seekHandler.removeURLParameters(e.url);n._onURLRedirect(t)}var i=e.headers.get("Content-Length");return null!=i&&(n._contentLength=parseInt(i),0!==n._contentLength&&n._onContentLengthKnown&&n._onContentLengthKnown(n._contentLength)),n._pump.call(n,e.body.getReader())}if(n._status=c.LoaderStatus.kError,!n._onError)throw new _.RuntimeException("FetchStreamLoader: Http code invalid, "+e.status+" "+e.statusText);n._onError(c.LoaderErrors.HTTP_STATUS_CODE_INVALID,{code:e.status,msg:e.statusText})}).catch(function(e){if(n._status=c.LoaderStatus.kError,!n._onError)throw e;n._onError(c.LoaderErrors.EXCEPTION,{code:-1,msg:e.message})})}},{key:"abort",value:function(){this._requestAbort=!0}},{key:"_pump",value:function(e){var t=this;return e.read().then(function(n){if(n.done)if(null!==t._contentLength&&t._receivedLength0&&(this._stashInitialSize=n.stashInitialSize),this._stashUsed=0,this._stashSize=this._stashInitialSize,this._bufferSize=3145728,this._stashBuffer=new ArrayBuffer(this._bufferSize),this._stashByteStart=0,this._enableStash=!0,!1===n.enableStashBuffer&&(this._enableStash=!1),this._loader=null,this._loaderClass=null,this._seekHandler=null,this._dataSource=t,this._isWebSocketURL=/wss?:\/\/(.+?)/.test(t.url),this._refTotalLength=t.filesize?t.filesize:null,this._totalLength=this._refTotalLength,this._fullRequestFlag=!1,this._currentRange=null,this._redirectedURL=null,this._speedNormalized=0,this._speedSampler=new l.default,this._speedNormalizeList=[64,128,256,384,512,768,1024,1536,2048,3072,4096],this._isEarlyEofReconnecting=!1,this._paused=!1,this._resumeFrom=0,this._onDataArrival=null,this._onSeeked=null,this._onError=null,this._onComplete=null,this._onRedirect=null,this._onRecoveredEarlyEof=null,this._selectSeekHandler(),this._selectLoader(),this._createLoader()}return s(e,[{key:"destroy",value:function(){this._loader.isWorking()&&this._loader.abort(),this._loader.destroy(),this._loader=null,this._loaderClass=null,this._dataSource=null,this._stashBuffer=null,this._stashUsed=this._stashSize=this._bufferSize=this._stashByteStart=0,this._currentRange=null,this._speedSampler=null,this._isEarlyEofReconnecting=!1,this._onDataArrival=null,this._onSeeked=null,this._onError=null,this._onComplete=null,this._onRedirect=null,this._onRecoveredEarlyEof=null,this._extraData=null}},{key:"isWorking",value:function(){return this._loader&&this._loader.isWorking()&&!this._paused}},{key:"isPaused",value:function(){return this._paused}},{key:"_selectSeekHandler",value:function(){var e=this._config;if("range"===e.seekType)this._seekHandler=new b.default(this._config.rangeLoadZeroStart);else if("param"===e.seekType){var t=e.seekParamStart||"bstart",n=e.seekParamEnd||"bend";this._seekHandler=new k.default(t,n)}else{if("custom"!==e.seekType)throw new L.InvalidArgumentException("Invalid seekType in config: "+e.seekType);if("function"!=typeof e.customSeekHandler)throw new L.InvalidArgumentException("Custom seekType specified in config but invalid customSeekHandler!");this._seekHandler=new e.customSeekHandler}}},{key:"_selectLoader",value:function(){if(this._isWebSocketURL)this._loaderClass=y.default;else if(f.default.isSupported())this._loaderClass=f.default;else if(_.default.isSupported())this._loaderClass=_.default;else{if(!v.default.isSupported())throw new L.RuntimeException("Your browser doesn't support xhr with arraybuffer responseType!");this._loaderClass=v.default}}},{key:"_createLoader",value:function(){this._loader=new this._loaderClass(this._seekHandler,this._config),!1===this._loader.needStashBuffer&&(this._enableStash=!1),this._loader.onContentLengthKnown=this._onContentLengthKnown.bind(this),this._loader.onURLRedirect=this._onURLRedirect.bind(this),this._loader.onDataArrival=this._onLoaderChunkArrival.bind(this),this._loader.onComplete=this._onLoaderComplete.bind(this),this._loader.onError=this._onLoaderError.bind(this)}},{key:"open",value:function(e){this._currentRange={from:0,to:-1},e&&(this._currentRange.from=e),this._speedSampler.reset(),e||(this._fullRequestFlag=!0),this._loader.open(this._dataSource,Object.assign({},this._currentRange))}},{key:"abort",value:function(){this._loader.abort(),this._paused&&(this._paused=!1,this._resumeFrom=0)}},{key:"pause",value:function(){this.isWorking()&&(this._loader.abort(),0!==this._stashUsed?(this._resumeFrom=this._stashByteStart,this._currentRange.to=this._stashByteStart-1):this._resumeFrom=this._currentRange.to+1,this._stashUsed=0,this._stashByteStart=0,this._paused=!0)}},{key:"resume",value:function(){if(this._paused){this._paused=!1;var e=this._resumeFrom;this._resumeFrom=0,this._internalSeek(e,!0)}}},{key:"seek",value:function(e){this._paused=!1,this._stashUsed=0,this._stashByteStart=0,this._internalSeek(e,!0)}},{key:"_internalSeek",value:function(e,t){this._loader.isWorking()&&this._loader.abort(),this._flushStashBuffer(t),this._loader.destroy(),this._loader=null;var n={from:e,to:-1};this._currentRange={from:n.from,to:-1},this._speedSampler.reset(),this._stashSize=this._stashInitialSize,this._createLoader(),this._loader.open(this._dataSource,n),this._onSeeked&&this._onSeeked()}},{key:"updateUrl",value:function(e){if(!e||"string"!=typeof e||0===e.length)throw new L.InvalidArgumentException("Url must be a non-empty string!");this._dataSource.url=e}},{key:"_expandBuffer",value:function(e){for(var t=this._stashSize;t+10485760){var i=new Uint8Array(this._stashBuffer,0,this._stashUsed);new Uint8Array(n,0,t).set(i,0)}this._stashBuffer=n,this._bufferSize=t}}},{key:"_normalizeSpeed",value:function(e){var t=this._speedNormalizeList,n=t.length-1,i=0,r=0,s=n;if(e=t[i]&&e=512&&e<=1024?Math.floor(1.5*e):2*e)>8192&&(t=8192);var n=1024*t+1048576;this._bufferSize0){var o=this._stashBuffer.slice(0,this._stashUsed),u=this._dispatchChunks(o,this._stashByteStart);if(u0){var l=new Uint8Array(o,u);a.set(l,0),this._stashUsed=l.byteLength,this._stashByteStart+=u}}else this._stashUsed=0,this._stashByteStart+=u;this._stashUsed+e.byteLength>this._bufferSize&&(this._expandBuffer(this._stashUsed+e.byteLength),a=new Uint8Array(this._stashBuffer,0,this._bufferSize)),a.set(new Uint8Array(e),this._stashUsed),this._stashUsed+=e.byteLength}else{var d=this._dispatchChunks(e,t);if(dthis._bufferSize&&(this._expandBuffer(h),a=new Uint8Array(this._stashBuffer,0,this._bufferSize)),a.set(new Uint8Array(e,d),0),this._stashUsed+=h,this._stashByteStart=t+d}}}else if(0===this._stashUsed){var f=this._dispatchChunks(e,t);if(fthis._bufferSize&&this._expandBuffer(c);var _=new Uint8Array(this._stashBuffer,0,this._bufferSize);_.set(new Uint8Array(e,f),0),this._stashUsed+=c,this._stashByteStart=t+f}}else{this._stashUsed+e.byteLength>this._bufferSize&&this._expandBuffer(this._stashUsed+e.byteLength);var m=new Uint8Array(this._stashBuffer,0,this._bufferSize);m.set(new Uint8Array(e),this._stashUsed),this._stashUsed+=e.byteLength;var p=this._dispatchChunks(this._stashBuffer.slice(0,this._stashUsed),this._stashByteStart);if(p0){var v=new Uint8Array(this._stashBuffer,p);m.set(v,0)}this._stashUsed-=p,this._stashByteStart+=p}}}},{key:"_flushStashBuffer",value:function(e){if(this._stashUsed>0){var t=this._stashBuffer.slice(0,this._stashUsed),n=this._dispatchChunks(t,this._stashByteStart),i=t.byteLength-n;if(n0){var r=new Uint8Array(this._stashBuffer,0,this._bufferSize),s=new Uint8Array(t,n);r.set(s,0),this._stashUsed=s.byteLength,this._stashByteStart+=n}return 0}o.default.w(this.TAG,i+" bytes unconsumed data remain when flush buffer, dropped")}return this._stashUsed=0,this._stashByteStart=0,i}return 0}},{key:"_onLoaderComplete",value:function(e,t){this._flushStashBuffer(!0),this._onComplete&&this._onComplete(this._extraData)}},{key:"_onLoaderError",value:function(e,t){switch(o.default.e(this.TAG,"Loader error, code = "+t.code+", msg = "+t.msg),this._flushStashBuffer(!1),this._isEarlyEofReconnecting&&(this._isEarlyEofReconnecting=!1,e=d.LoaderErrors.UNRECOVERABLE_EARLY_EOF),e){case d.LoaderErrors.EARLY_EOF:if(!this._config.isLive&&this._totalLength){var n=this._currentRange.to+1;return void(n0)for(var s=n.split("&"),a=0;a0;o[0]!==this._startName&&o[0]!==this._endName&&(u&&(r+="&"),r+=s[a])}return 0===r.length?t:t+"?"+r}}]),e}();n.default=s},{}],26:[function(e,t,n){"use strict";function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(n,"__esModule",{value:!0});var r=function(){function e(e,t){for(var n=0;n=500?this.currentKBps:0}},{key:"averageKBps",get:function(){var e=(this._now()-this._firstCheckpoint)/1e3;return this._totalBytes/e/1024}}]),e}();n.default=s},{}],28:[function(e,t,n){"use strict";function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function s(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(n,"__esModule",{value:!0});var a=function e(t,n,i){null===t&&(t=Function.prototype);var r=Object.getOwnPropertyDescriptor(t,n);if(void 0===r){var s=Object.getPrototypeOf(t);return null===s?void 0:e(s,n,i)}if("value"in r)return r.value;var a=r.get;if(void 0!==a)return a.call(i)},o=function(){function e(e,t){for(var n=0;n299)){if(this._status=h.LoaderStatus.kError,!this._onError)throw new f.RuntimeException("MozChunkedLoader: Http code invalid, "+t.status+" "+t.statusText);this._onError(h.LoaderErrors.HTTP_STATUS_CODE_INVALID,{code:t.status,msg:t.statusText})}else this._status=h.LoaderStatus.kBuffering}}},{key:"_onProgress",value:function(e){if(this._status!==h.LoaderStatus.kError){null===this._contentLength&&null!==e.total&&0!==e.total&&(this._contentLength=e.total,this._onContentLengthKnown&&this._onContentLengthKnown(this._contentLength));var t=e.target.response,n=this._range.from+this._receivedLength;this._receivedLength+=t.byteLength,this._onDataArrival&&this._onDataArrival(t,n,this._receivedLength)}}},{key:"_onLoadEnd",value:function(e){if(!0===this._requestAbort)return void(this._requestAbort=!1);this._status!==h.LoaderStatus.kError&&(this._status=h.LoaderStatus.kComplete,this._onComplete&&this._onComplete(this._range.from,this._range.from+this._receivedLength-1))}},{key:"_onXhrError",value:function(e){this._status=h.LoaderStatus.kError;var t=0,n=null;if(this._contentLength&&e.loaded=200&&t.status<=299){if(this._status=h.LoaderStatus.kBuffering,void 0!=t.responseURL){var n=this._seekHandler.removeURLParameters(t.responseURL);t.responseURL!==this._currentRequestURL&&n!==this._currentRedirectedURL&&(this._currentRedirectedURL=n,this._onURLRedirect&&this._onURLRedirect(n))}var i=t.getResponseHeader("Content-Length");if(null!=i&&null==this._contentLength){var r=parseInt(i);r>0&&(this._contentLength=r,this._onContentLengthKnown&&this._onContentLengthKnown(this._contentLength))}}else{if(this._status=h.LoaderStatus.kError,!this._onError)throw new f.RuntimeException("MSStreamLoader: Http code invalid, "+t.status+" "+t.statusText);this._onError(h.LoaderErrors.HTTP_STATUS_CODE_INVALID,{code:t.status,msg:t.statusText})}else if(3===t.readyState&&t.status>=200&&t.status<=299){this._status=h.LoaderStatus.kBuffering;var s=t.response;this._reader.readAsArrayBuffer(s)}}},{key:"_xhrOnError",value:function(e){this._status=h.LoaderStatus.kError;var t=h.LoaderErrors.EXCEPTION,n={code:-1,msg:e.constructor.name+" "+e.type};if(!this._onError)throw new f.RuntimeException(n.msg);this._onError(t,n)}},{key:"_msrOnProgress",value:function(e){var t=e.target,n=t.result;if(null==n)return void this._doReconnectIfNeeded();var i=n.slice(this._lastTimeBufferSize);this._lastTimeBufferSize=n.byteLength;var r=this._totalRange.from+this._receivedLength;this._receivedLength+=i.byteLength,this._onDataArrival&&this._onDataArrival(i,r,this._receivedLength),n.byteLength>=this._bufferLimit&&(d.default.v(this.TAG,"MSStream buffer exceeded max size near "+(r+i.byteLength)+", reconnecting..."),this._doReconnectIfNeeded())}},{key:"_doReconnectIfNeeded",value:function(){if(null==this._contentLength||this._receivedLength=this._contentLength&&(n=this._range.from+this._contentLength-1),this._currentRequestRange={from:t,to:n},this._internalOpen(this._dataSource,this._currentRequestRange)}},{key:"_internalOpen",value:function(e,t){this._lastTimeLoaded=0;var n=e.url;this._config.reuseRedirectedURL&&(void 0!=this._currentRedirectedURL?n=this._currentRedirectedURL:void 0!=e.redirectedURL&&(n=e.redirectedURL));var i=this._seekHandler.getConfig(n,t);this._currentRequestURL=i.url;var r=this._xhr=new XMLHttpRequest;if(r.open("GET",i.url,!0),r.responseType="arraybuffer",r.onreadystatechange=this._onReadyStateChange.bind(this),r.onprogress=this._onProgress.bind(this),r.onload=this._onLoad.bind(this),r.onerror=this._onXhrError.bind(this),e.withCredentials&&(r.withCredentials=!0),"object"===o(i.headers)){var s=i.headers;for(var a in s)s.hasOwnProperty(a)&&r.setRequestHeader(a,s[a])}r.send()}},{key:"abort",value:function(){this._requestAbort=!0,this._internalAbort(),this._status=_.LoaderStatus.kComplete}},{key:"_internalAbort",value:function(){this._xhr&&(this._xhr.onreadystatechange=null,this._xhr.onprogress=null,this._xhr.onload=null,this._xhr.onerror=null,this._xhr.abort(),this._xhr=null)}},{key:"_onReadyStateChange",value:function(e){var t=e.target;if(2===t.readyState){if(void 0!=t.responseURL){var n=this._seekHandler.removeURLParameters(t.responseURL);t.responseURL!==this._currentRequestURL&&n!==this._currentRedirectedURL&&(this._currentRedirectedURL=n,this._onURLRedirect&&this._onURLRedirect(n))}if(t.status>=200&&t.status<=299){if(this._waitForTotalLength)return;this._status=_.LoaderStatus.kBuffering}else{if(this._status=_.LoaderStatus.kError,!this._onError)throw new m.RuntimeException("RangeLoader: Http code invalid, "+t.status+" "+t.statusText);this._onError(_.LoaderErrors.HTTP_STATUS_CODE_INVALID,{code:t.status,msg:t.statusText})}}}},{key:"_onProgress",value:function(e){if(this._status!==_.LoaderStatus.kError){if(null===this._contentLength){var t=!1;if(this._waitForTotalLength){this._waitForTotalLength=!1,this._totalLengthReceived=!0,t=!0;var n=e.total;this._internalAbort(),null!=n&0!==n&&(this._totalLength=n)}if(-1===this._range.to?this._contentLength=this._totalLength-this._range.from:this._contentLength=this._range.to-this._range.from+1,t)return void this._openSubRange();this._onContentLengthKnown&&this._onContentLengthKnown(this._contentLength)}var i=e.loaded-this._lastTimeLoaded;this._lastTimeLoaded=e.loaded,this._speedSampler.addBytes(i)}}},{key:"_normalizeSpeed",value:function(e){var t=this._chunkSizeKBList,n=t.length-1,i=0,r=0,s=n;if(e=t[i]&&e=3&&(t=this._speedSampler.currentKBps),0!==t){var n=this._normalizeSpeed(t);this._currentSpeedNormalized!==n&&(this._currentSpeedNormalized=n,this._currentChunkSizeKB=n)}var i=e.target.response,r=this._range.from+this._receivedLength;this._receivedLength+=i.byteLength;var s=!1;null!=this._contentLength&&this._receivedLength0&&this._receivedLength0&&(this._requestSetTime=!0,this._mediaElement.currentTime=0),this._transmuxer=new p.default(this._mediaDataSource,this._config),this._transmuxer.on(g.default.INIT_SEGMENT,function(t,n){e._msectl.appendInitSegment(n)}),this._transmuxer.on(g.default.MEDIA_SEGMENT,function(t,n){if(e._msectl.appendMediaSegment(n),e._config.lazyLoad&&!e._config.isLive){var i=e._mediaElement.currentTime;n.info.endDts>=1e3*(i+e._config.lazyLoadMaxDuration)&&null==e._progressChecker&&(d.default.v(e.TAG,"Maximum buffering duration exceeded, suspend transmuxing task"),e._suspendTransmuxer())}}),this._transmuxer.on(g.default.LOADING_COMPLETE,function(){e._msectl.endOfStream(),e._emitter.emit(_.default.LOADING_COMPLETE)}),
+this._transmuxer.on(g.default.RECOVERED_EARLY_EOF,function(){e._emitter.emit(_.default.RECOVERED_EARLY_EOF)}),this._transmuxer.on(g.default.IO_ERROR,function(t,n){e._emitter.emit(_.default.ERROR,k.ErrorTypes.NETWORK_ERROR,t,n)}),this._transmuxer.on(g.default.DEMUX_ERROR,function(t,n){e._emitter.emit(_.default.ERROR,k.ErrorTypes.MEDIA_ERROR,t,{code:-1,msg:n})}),this._transmuxer.on(g.default.MEDIA_INFO,function(t){e._mediaInfo=t,e._emitter.emit(_.default.MEDIA_INFO,Object.assign({},t))}),this._transmuxer.on(g.default.STATISTICS_INFO,function(t){e._statisticsInfo=e._fillStatisticsInfo(t),e._emitter.emit(_.default.STATISTICS_INFO,Object.assign({},e._statisticsInfo))}),this._transmuxer.on(g.default.RECOMMEND_SEEKPOINT,function(t){e._mediaElement&&!e._config.accurateSeek&&(e._requestSetTime=!0,e._mediaElement.currentTime=t/1e3)}),this._transmuxer.open()}}},{key:"unload",value:function(){this._mediaElement&&this._mediaElement.pause(),this._msectl&&this._msectl.seek(0),this._transmuxer&&(this._transmuxer.close(),this._transmuxer.destroy(),this._transmuxer=null)}},{key:"play",value:function(){return this._mediaElement.play()}},{key:"pause",value:function(){this._mediaElement.pause()}},{key:"_fillStatisticsInfo",value:function(e){if(e.playerType=this._type,!(this._mediaElement instanceof HTMLVideoElement))return e;var t=!0,n=0,i=0;if(this._mediaElement.getVideoPlaybackQuality){var r=this._mediaElement.getVideoPlaybackQuality();n=r.totalVideoFrames,i=r.droppedVideoFrames}else void 0!=this._mediaElement.webkitDecodedFrameCount?(n=this._mediaElement.webkitDecodedFrameCount,i=this._mediaElement.webkitDroppedFrameCount):t=!1;return t&&(e.decodedFrames=n,e.droppedFrames=i),e}},{key:"_onmseUpdateEnd",value:function(){if(this._config.lazyLoad&&!this._config.isLive){for(var e=this._mediaElement.buffered,t=this._mediaElement.currentTime,n=0,i=0;i=t+this._config.lazyLoadMaxDuration&&null==this._progressChecker&&(d.default.v(this.TAG,"Maximum buffering duration exceeded, suspend transmuxing task"),this._suspendTransmuxer())}}},{key:"_onmseBufferFull",value:function(){d.default.v(this.TAG,"MSE SourceBuffer is full, suspend transmuxing task"),null==this._progressChecker&&this._suspendTransmuxer()}},{key:"_suspendTransmuxer",value:function(){this._transmuxer&&(this._transmuxer.pause(),null==this._progressChecker&&(this._progressChecker=window.setInterval(this._checkProgressAndResume.bind(this),1e3)))}},{key:"_checkProgressAndResume",value:function(){for(var e=this._mediaElement.currentTime,t=this._mediaElement.buffered,n=!1,i=0;i=r&&e=s-this._config.lazyLoadRecoverDuration&&(n=!0);break}}n&&(window.clearInterval(this._progressChecker),this._progressChecker=null,n&&(d.default.v(this.TAG,"Continue loading from paused position"),this._transmuxer.resume()))}},{key:"_isTimepointBuffered",value:function(e){for(var t=this._mediaElement.buffered,n=0;n=i&&e0){var r=this._mediaElement.buffered.start(0);(r<1&&e0&&t.currentTime0){var i=n.start(0);if(i<1&&t0&&(this._mediaElement.currentTime=0),this._mediaElement.preload="auto",this._mediaElement.load(),this._statisticsReporter=window.setInterval(this._reportStatisticsInfo.bind(this),this._config.statisticsInfoReportInterval)}},{key:"unload",value:function(){this._mediaElement&&(this._mediaElement.src="",this._mediaElement.removeAttribute("src")),null!=this._statisticsReporter&&(window.clearInterval(this._statisticsReporter),this._statisticsReporter=null)}},{key:"play",value:function(){return this._mediaElement.play()}},{key:"pause",value:function(){this._mediaElement.pause()}},{key:"_onvLoadedMetadata",value:function(e){null!=this._pendingSeekTime&&(this._mediaElement.currentTime=this._pendingSeekTime,this._pendingSeekTime=null),this._emitter.emit(d.default.MEDIA_INFO,this.mediaInfo)}},{key:"_reportStatisticsInfo",value:function(){this._emitter.emit(d.default.STATISTICS_INFO,this.statisticsInfo)}},{key:"type",get:function(){return this._type}},{key:"buffered",get:function(){return this._mediaElement.buffered}},{key:"duration",get:function(){return this._mediaElement.duration}},{key:"volume",get:function(){return this._mediaElement.volume},set:function(e){this._mediaElement.volume=e}},{key:"muted",get:function(){return this._mediaElement.muted},set:function(e){this._mediaElement.muted=e}},{key:"currentTime",get:function(){return this._mediaElement?this._mediaElement.currentTime:0},set:function(e){this._mediaElement?this._mediaElement.currentTime=e:this._pendingSeekTime=e}},{key:"mediaInfo",get:function(){var e=this._mediaElement instanceof HTMLAudioElement?"audio/":"video/",t={mimeType:e+this._mediaDataSource.type};return this._mediaElement&&(t.duration=Math.floor(1e3*this._mediaElement.duration),this._mediaElement instanceof HTMLVideoElement&&(t.width=this._mediaElement.videoWidth,t.height=this._mediaElement.videoHeight)),t}},{key:"statisticsInfo",get:function(){var e={playerType:this._type,url:this._mediaDataSource.url};if(!(this._mediaElement instanceof HTMLVideoElement))return e;var t=!0,n=0,i=0;if(this._mediaElement.getVideoPlaybackQuality){var r=this._mediaElement.getVideoPlaybackQuality();n=r.totalVideoFrames,i=r.droppedVideoFrames}else void 0!=this._mediaElement.webkitDecodedFrameCount?(n=this._mediaElement.webkitDecodedFrameCount,i=this._mediaElement.webkitDroppedFrameCount):t=!1;return t&&(e.decodedFrames=n,e.droppedFrames=i),e}}]),e}();n.default=c},{"../config.js":5,"../utils/exception.js":40,"./player-events.js":35,events:2}],34:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.ErrorDetails=n.ErrorTypes=void 0;var i=e("../io/loader.js"),r=e("../demux/demux-errors.js"),s=function(e){return e&&e.__esModule?e:{default:e}}(r);n.ErrorTypes={NETWORK_ERROR:"NetworkError",MEDIA_ERROR:"MediaError",OTHER_ERROR:"OtherError"},n.ErrorDetails={NETWORK_EXCEPTION:i.LoaderErrors.EXCEPTION,NETWORK_STATUS_CODE_INVALID:i.LoaderErrors.HTTP_STATUS_CODE_INVALID,NETWORK_TIMEOUT:i.LoaderErrors.CONNECTING_TIMEOUT,NETWORK_UNRECOVERABLE_EARLY_EOF:i.LoaderErrors.UNRECOVERABLE_EARLY_EOF,MEDIA_MSE_ERROR:"MediaMSEError",MEDIA_FORMAT_ERROR:s.default.FORMAT_ERROR,MEDIA_FORMAT_UNSUPPORTED:s.default.FORMAT_UNSUPPORTED,MEDIA_CODEC_UNSUPPORTED:s.default.CODEC_UNSUPPORTED}},{"../demux/demux-errors.js":16,"../io/loader.js":24}],35:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var i={ERROR:"error",LOADING_COMPLETE:"loading_complete",RECOVERED_EARLY_EOF:"recovered_early_eof",MEDIA_INFO:"media_info",STATISTICS_INFO:"statistics_info"};n.default=i},{}],36:[function(e,t,n){"use strict";function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(n,"__esModule",{value:!0});var r=function(){function e(e,t){for(var n=0;n>>24&255,n[1]=t>>>16&255,n[2]=t>>>8&255,n[3]=255&t,n.set(e,4);for(var a=8,o=0;o>>24&255,t>>>16&255,t>>>8&255,255&t,n>>>24&255,n>>>16&255,n>>>8&255,255&n,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]))}},{key:"trak",value:function(t){return e.box(e.types.trak,e.tkhd(t),e.mdia(t))}},{key:"tkhd",value:function(t){var n=t.id,i=t.duration,r=t.presentWidth,s=t.presentHeight;return e.box(e.types.tkhd,new Uint8Array([0,0,0,7,0,0,0,0,0,0,0,0,n>>>24&255,n>>>16&255,n>>>8&255,255&n,0,0,0,0,i>>>24&255,i>>>16&255,i>>>8&255,255&i,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,r>>>8&255,255&r,0,0,s>>>8&255,255&s,0,0]))}},{key:"mdia",value:function(t){return e.box(e.types.mdia,e.mdhd(t),e.hdlr(t),e.minf(t))}},{key:"mdhd",value:function(t){var n=t.timescale,i=t.duration;return e.box(e.types.mdhd,new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,n>>>24&255,n>>>16&255,n>>>8&255,255&n,i>>>24&255,i>>>16&255,i>>>8&255,255&i,85,196,0,0]))}},{key:"hdlr",value:function(t){var n=null;return n="audio"===t.type?e.constants.HDLR_AUDIO:e.constants.HDLR_VIDEO,e.box(e.types.hdlr,n)}},{key:"minf",value:function(t){var n=null;return n="audio"===t.type?e.box(e.types.smhd,e.constants.SMHD):e.box(e.types.vmhd,e.constants.VMHD),e.box(e.types.minf,n,e.dinf(),e.stbl(t))}},{key:"dinf",value:function(){return e.box(e.types.dinf,e.box(e.types.dref,e.constants.DREF))}},{key:"stbl",value:function(t){return e.box(e.types.stbl,e.stsd(t),e.box(e.types.stts,e.constants.STTS),e.box(e.types.stsc,e.constants.STSC),e.box(e.types.stsz,e.constants.STSZ),e.box(e.types.stco,e.constants.STCO))}},{key:"stsd",value:function(t){return"audio"===t.type?"mp3"===t.codec?e.box(e.types.stsd,e.constants.STSD_PREFIX,e.mp3(t)):e.box(e.types.stsd,e.constants.STSD_PREFIX,e.mp4a(t)):e.box(e.types.stsd,e.constants.STSD_PREFIX,e.avc1(t))}},{key:"mp3",value:function(t){var n=t.channelCount,i=t.audioSampleRate,r=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,n,0,16,0,0,0,0,i>>>8&255,255&i,0,0]);return e.box(e.types[".mp3"],r)}},{key:"mp4a",value:function(t){var n=t.channelCount,i=t.audioSampleRate,r=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,n,0,16,0,0,0,0,i>>>8&255,255&i,0,0]);return e.box(e.types.mp4a,r,e.esds(t))}},{key:"esds",value:function(t){var n=t.config||[],i=n.length,r=new Uint8Array([0,0,0,0,3,23+i,0,1,0,4,15+i,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([i]).concat(n).concat([6,1,2]));return e.box(e.types.esds,r)}},{key:"avc1",value:function(t){var n=t.avcc,i=t.codecWidth,r=t.codecHeight,s=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,i>>>8&255,255&i,r>>>8&255,255&r,0,72,0,0,0,72,0,0,0,0,0,0,0,1,10,120,113,113,47,102,108,118,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,255,255]);return e.box(e.types.avc1,s,e.box(e.types.avcC,n))}},{key:"mvex",value:function(t){return e.box(e.types.mvex,e.trex(t))}},{key:"trex",value:function(t){var n=t.id,i=new Uint8Array([0,0,0,0,n>>>24&255,n>>>16&255,n>>>8&255,255&n,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]);return e.box(e.types.trex,i)}},{key:"moof",value:function(t,n){return e.box(e.types.moof,e.mfhd(t.sequenceNumber),e.traf(t,n))}},{key:"mfhd",value:function(t){var n=new Uint8Array([0,0,0,0,t>>>24&255,t>>>16&255,t>>>8&255,255&t]);return e.box(e.types.mfhd,n)}},{key:"traf",value:function(t,n){var i=t.id,r=e.box(e.types.tfhd,new Uint8Array([0,0,0,0,i>>>24&255,i>>>16&255,i>>>8&255,255&i])),s=e.box(e.types.tfdt,new Uint8Array([0,0,0,0,n>>>24&255,n>>>16&255,n>>>8&255,255&n])),a=e.sdtp(t),o=e.trun(t,a.byteLength+16+16+8+16+8+8);return e.box(e.types.traf,r,s,o,a)}},{key:"sdtp",value:function(t){for(var n=t.samples||[],i=n.length,r=new Uint8Array(4+i),s=0;s>>24&255,r>>>16&255,r>>>8&255,255&r,n>>>24&255,n>>>16&255,n>>>8&255,255&n],0);for(var o=0;o>>24&255,u>>>16&255,u>>>8&255,255&u,l>>>24&255,l>>>16&255,l>>>8&255,255&l,d.isLeading<<2|d.dependsOn,d.isDependedOn<<6|d.hasRedundancy<<4|d.isNonSync,0,0,h>>>24&255,h>>>16&255,h>>>8&255,255&h],12+16*o)}return e.box(e.types.trun,a)}},{key:"mdat",value:function(t){return e.box(e.types.mdat,t)}}]),e}();s.init(),n.default=s},{}],38:[function(e,t,n){"use strict";function i(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(n,"__esModule",{value:!0});var s=function(){function e(e,t){for(var n=0;n1&&(y=i.pop(),g-=y.length),null!=this._audioStashedLastSample){var E=this._audioStashedLastSample;this._audioStashedLastSample=null,i.unshift(E),g+=E.length}null!=y&&(this._audioStashedLastSample=y);var b=i[0].dts-this._dtsBase;if(this._audioNextDts)r=b-this._audioNextDts;else if(this._audioSegmentInfoList.isEmpty())r=0,this._fillSilentAfterSeek&&!this._videoSegmentInfoList.isEmpty()&&"mp3"!==this._audioMeta.originalCodec&&(m=!0);else{var S=this._audioSegmentInfoList.getLastSampleBefore(b);if(null!=S){var k=b-(S.originalDts+S.duration);k<=3&&(k=0);var L=S.dts+S.duration+k;r=b-L}else r=0}if(m){var w=b-r,R=this._videoSegmentInfoList.getLastSegmentBefore(b);if(null!=R&&R.beginDts=1?C[C.length-1].duration:Math.floor(u);var U=!1,N=null;if(j>1.5*u&&"mp3"!==this._audioMeta.codec&&this._fillAudioTimestampGap&&!c.default.safari){U=!0;var F=Math.abs(j-u),G=Math.ceil(F/u),V=B+u;o.default.w(this.TAG,"Large audio timestamp gap detected, may cause AV sync to drift. Silent frames will be generated to avoid unsync.\ndts: "+(B+j)+" ms, expected: "+(B+Math.round(u))+" ms, delta: "+Math.round(F)+" ms, generate: "+G+" frames");var z=h.default.getSilentFrame(this._audioMeta.originalCodec,this._audioMeta.channelCount);null==z&&(o.default.w(this.TAG,"Unable to generate silent frame for "+this._audioMeta.originalCodec+" with "+this._audioMeta.channelCount+" channels, repeat last frame"),z=M),N=[];for(var H=0;H0){var q=N[N.length-1];q.duration=K-q.dts}var W={dts:K,pts:K,cts:0,unit:z,size:z.byteLength,duration:0,originalDts:D,flags:{isLeading:0,dependsOn:1,isDependedOn:0,hasRedundancy:0}};N.push(W),g+=M.byteLength,V+=u}var X=N[N.length-1];X.duration=B+j-X.dts,j=Math.round(u)}C.push({dts:B,pts:B,cts:0,unit:x.unit,size:x.unit.byteLength,duration:j,originalDts:D,flags:{isLeading:0,dependsOn:1,isDependedOn:0,hasRedundancy:0}}),U&&C.push.apply(C,N)}d?v=new Uint8Array(g):(v=new Uint8Array(g),v[0]=g>>>24&255,v[1]=g>>>16&255,v[2]=g>>>8&255,v[3]=255&g,v.set(l.default.types.mdat,4));for(var Y=0;Y1&&(c=i.pop(),f-=c.length),null!=this._videoStashedLastSample){var m=this._videoStashedLastSample;this._videoStashedLastSample=null,i.unshift(m),f+=m.length}null!=c&&(this._videoStashedLastSample=c);var p=i[0].dts-this._dtsBase;if(this._videoNextDts)r=p-this._videoNextDts;else if(this._videoSegmentInfoList.isEmpty())r=0;else{var v=this._videoSegmentInfoList.getLastSampleBefore(p);if(null!=v){var g=p-(v.originalDts+v.duration);g<=3&&(g=0);var y=v.dts+v.duration+g;r=p-y}else r=0}for(var E=new _.MediaSegmentInfo,b=[],S=0;S=1?b[b.length-1].duration:Math.floor(this._videoMeta.refSampleDuration);if(w){var I=new _.SampleInfo(R,O,T,k.dts,!0);I.fileposition=k.fileposition,E.appendSyncPoint(I)}b.push({dts:R,pts:O,cts:A,units:k.units,size:k.length,isKeyframe:w,duration:T,originalDts:L,flags:{isLeading:0,dependsOn:w?2:1,isDependedOn:w?1:0,hasRedundancy:0,isNonSync:w?0:1}})}h=new Uint8Array(f),h[0]=f>>>24&255,h[1]=f>>>16&255,h[2]=f>>>8&255,h[3]=255&f,h.set(l.default.types.mdat,4);for(var x=0;x=0&&/(rv)(?::| )([\w.]+)/.exec(e)||e.indexOf("compatible")<0&&/(firefox)[ \/]([\w.]+)/.exec(e)||[],n=/(ipad)/.exec(e)||/(ipod)/.exec(e)||/(windows phone)/.exec(e)||/(iphone)/.exec(e)||/(kindle)/.exec(e)||/(android)/.exec(e)||/(windows)/.exec(e)||/(mac)/.exec(e)||/(linux)/.exec(e)||/(cros)/.exec(e)||[],r={browser:t[5]||t[3]||t[1]||"",version:t[2]||t[4]||"0",majorVersion:t[4]||t[2]||"0",platform:n[0]||""},s={};if(r.browser){s[r.browser]=!0;var a=r.majorVersion.split(".");s.version={major:parseInt(r.majorVersion,10),string:r.version},a.length>1&&(s.version.minor=parseInt(a[1],10)),a.length>2&&(s.version.build=parseInt(a[2],10))}r.platform&&(s[r.platform]=!0),(s.chrome||s.opr||s.safari)&&(s.webkit=!0),(s.rv||s.iemobile)&&(s.rv&&delete s.rv,r.browser="msie",s.msie=!0),s.edge&&(delete s.edge,r.browser="msedge",s.msedge=!0),s.opr&&(r.browser="opera",s.opera=!0),s.safari&&s.android&&(r.browser="android",s.android=!0),s.name=r.browser,s.platform=r.platform;for(var o in i)i.hasOwnProperty(o)&&delete i[o];Object.assign(i,s)}(),n.default=i},{}],40:[function(e,t,n){"use strict";function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function r(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function s(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(n,"__esModule",{value:!0});var a=function(){function e(e,t){for(var n=0;n "+n;e.ENABLE_CALLBACK&&e.emitter.emit("log","error",i),e.ENABLE_ERROR&&(console.error?console.error(i):console.warn?console.warn(i):console.log(i))}},{key:"i",value:function(t,n){t&&!e.FORCE_GLOBAL_TAG||(t=e.GLOBAL_TAG);var i="["+t+"] > "+n;e.ENABLE_CALLBACK&&e.emitter.emit("log","info",i),e.ENABLE_INFO&&(console.info?console.info(i):console.log(i))}},{key:"w",value:function(t,n){t&&!e.FORCE_GLOBAL_TAG||(t=e.GLOBAL_TAG);var i="["+t+"] > "+n;e.ENABLE_CALLBACK&&e.emitter.emit("log","warn",i),e.ENABLE_WARN&&(console.warn?console.warn(i):console.log(i))}},{key:"d",value:function(t,n){t&&!e.FORCE_GLOBAL_TAG||(t=e.GLOBAL_TAG);var i="["+t+"] > "+n;e.ENABLE_CALLBACK&&e.emitter.emit("log","debug",i),e.ENABLE_DEBUG&&(console.debug?console.debug(i):console.log(i))}},{key:"v",value:function(t,n){t&&!e.FORCE_GLOBAL_TAG||(t=e.GLOBAL_TAG);var i="["+t+"] > "+n;e.ENABLE_CALLBACK&&e.emitter.emit("log","verbose",i),e.ENABLE_VERBOSE&&console.log(i)}}]),e}();o.GLOBAL_TAG="flv.js",o.FORCE_GLOBAL_TAG=!1,o.ENABLE_ERROR=!0,o.ENABLE_INFO=!0,o.ENABLE_WARN=!0,o.ENABLE_DEBUG=!0,o.ENABLE_VERBOSE=!0,o.ENABLE_CALLBACK=!1,o.emitter=new a.default,n.default=o},{events:2}],42:[function(e,t,n){"use strict";function i(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(n,"__esModule",{value:!0});var s=function(){function e(e,t){for(var n=0;n0){var n=e.getConfig();t.emit("change",n)}}},{key:"registerListener",value:function(t){e.emitter.addListener("change",t)}},{key:"removeListener",value:function(t){e.emitter.removeListener("change",t)}},{key:"addLogListener",value:function(t){l.default.emitter.addListener("log",t),l.default.emitter.listenerCount("log")>0&&(l.default.ENABLE_CALLBACK=!0,e._notifyChange())}},{key:"removeLogListener",value:function(t){l.default.emitter.removeListener("log",t),0===l.default.emitter.listenerCount("log")&&(l.default.ENABLE_CALLBACK=!1,e._notifyChange())}},{key:"forceGlobalTag",get:function(){return l.default.FORCE_GLOBAL_TAG},set:function(t){l.default.FORCE_GLOBAL_TAG=t,e._notifyChange()}},{key:"globalTag",get:function(){return l.default.GLOBAL_TAG},set:function(t){l.default.GLOBAL_TAG=t,e._notifyChange()}},{key:"enableAll",get:function(){return l.default.ENABLE_VERBOSE&&l.default.ENABLE_DEBUG&&l.default.ENABLE_INFO&&l.default.ENABLE_WARN&&l.default.ENABLE_ERROR},set:function(t){l.default.ENABLE_VERBOSE=t,l.default.ENABLE_DEBUG=t,l.default.ENABLE_INFO=t,l.default.ENABLE_WARN=t,l.default.ENABLE_ERROR=t,e._notifyChange()}},{key:"enableDebug",get:function(){return l.default.ENABLE_DEBUG},set:function(t){l.default.ENABLE_DEBUG=t,e._notifyChange()}},{key:"enableVerbose",get:function(){return l.default.ENABLE_VERBOSE},set:function(t){l.default.ENABLE_VERBOSE=t,e._notifyChange()}},{key:"enableInfo",get:function(){return l.default.ENABLE_INFO},set:function(t){l.default.ENABLE_INFO=t,e._notifyChange()}},{key:"enableWarn",get:function(){return l.default.ENABLE_WARN},set:function(t){l.default.ENABLE_WARN=t,e._notifyChange()}},{key:"enableError",get:function(){return l.default.ENABLE_ERROR},set:function(t){l.default.ENABLE_ERROR=t,e._notifyChange()}}]),e}();d.emitter=new o.default,n.default=d},{"./logger.js":41,events:2}],43:[function(e,t,n){"use strict";function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(n,"__esModule",{value:!0});var r=function(){function e(e,t){for(var n=0;n=128){t.push(String.fromCharCode(65535&a)),r+=2;continue}}}else if(n[r]<240){if(i(n,r,2)){var o=(15&n[r])<<12|(63&n[r+1])<<6|63&n[r+2];if(o>=2048&&55296!=(63488&o)){t.push(String.fromCharCode(65535&o)),r+=3;continue}}}else if(n[r]<248&&i(n,r,3)){var u=(7&n[r])<<18|(63&n[r+1])<<12|(63&n[r+2])<<6|63&n[r+3];if(u>65536&&u<1114112){u-=65536,t.push(String.fromCharCode(u>>>10|55296)),t.push(String.fromCharCode(1023&u|56320)),r+=4;continue}}t.push(String.fromCharCode(65533)),++r}return t.join("")}Object.defineProperty(n,"__esModule",{value:!0}),n.default=r},{}]},{},[21])(21)});
+//# sourceMappingURL=flv.min.js.map
diff --git a/src/bower_components/emby-webcomponents/focusmanager.js b/src/bower_components/emby-webcomponents/focusmanager.js
index c80ca2e3a3..5977dc0715 100644
--- a/src/bower_components/emby-webcomponents/focusmanager.js
+++ b/src/bower_components/emby-webcomponents/focusmanager.js
@@ -1,249 +1,544 @@
-define(["dom"], function(dom) {
- "use strict";
+define(['dom'], function (dom) {
+ 'use strict';
+ var scopes = [];
function pushScope(elem) {
- scopes.push(elem)
+ scopes.push(elem);
}
function popScope(elem) {
- scopes.length && (scopes.length -= 1)
- }
- function autoFocus(view, defaultToFirst, findAutoFocusElement) {
- var element;
- return !1 !== findAutoFocusElement && (element = view.querySelector("*[autofocus]")) ? (focus(element), element) : !1 !== defaultToFirst && (element = getFocusableElements(view, 1, "noautofocus")[0]) ? (focus(element), element) : null
- }
-
- function focus(element) {
- try {
- element.focus({
- preventScroll: !0
- })
- } catch (err) {
- console.log("Error in focusManager.autoFocus: " + err)
+ if (scopes.length) {
+ scopes.length -= 1;
}
}
+ function autoFocus(view, defaultToFirst, findAutoFocusElement) {
+
+ var element;
+ if (findAutoFocusElement !== false) {
+ element = view.querySelector('*[autofocus]');
+ if (element) {
+ focus(element);
+ return element;
+ }
+ }
+
+ if (defaultToFirst !== false) {
+ element = getFocusableElements(view, 1, 'noautofocus')[0];
+
+ if (element) {
+ focus(element);
+ return element;
+ }
+ }
+
+ return null;
+ }
+
+ function focus(element) {
+
+ try {
+ element.focus({
+ preventScroll: true
+ });
+ } catch (err) {
+ console.log('Error in focusManager.autoFocus: ' + err);
+ }
+ }
+
+ var focusableTagNames = ['INPUT', 'TEXTAREA', 'SELECT', 'BUTTON', 'A'];
+ var focusableContainerTagNames = ['BODY', 'DIALOG'];
+ var focusableQuery = focusableTagNames.map(function (t) {
+
+ if (t === 'INPUT') {
+ t += ':not([type="range"]):not([type="file"])';
+ }
+ return t + ':not([tabindex="-1"]):not(:disabled)';
+
+ }).join(',') + ',.focusable';
+
function isFocusable(elem) {
- return -1 !== focusableTagNames.indexOf(elem.tagName) || !(!elem.classList || !elem.classList.contains("focusable"))
+
+ if (focusableTagNames.indexOf(elem.tagName) !== -1) {
+ return true;
+ }
+
+ if (elem.classList && elem.classList.contains('focusable')) {
+ return true;
+ }
+
+ return false;
}
function normalizeFocusable(elem, originalElement) {
if (elem) {
var tagName = elem.tagName;
- tagName && "HTML" !== tagName && "BODY" !== tagName || (elem = originalElement)
+ if (!tagName || tagName === 'HTML' || tagName === 'BODY') {
+ elem = originalElement;
+ }
}
- return elem
+
+ return elem;
}
function focusableParent(elem) {
- for (var originalElement = elem; !isFocusable(elem);) {
+
+ var originalElement = elem;
+
+ while (!isFocusable(elem)) {
var parent = elem.parentNode;
- if (!parent) return normalizeFocusable(elem, originalElement);
- elem = parent
+
+ if (!parent) {
+ return normalizeFocusable(elem, originalElement);
+ }
+
+ elem = parent;
}
- return normalizeFocusable(elem, originalElement)
+
+ return normalizeFocusable(elem, originalElement);
}
+ // Determines if a focusable element can be focused at a given point in time
function isCurrentlyFocusableInternal(elem) {
- return null !== elem.offsetParent
+
+ // http://stackoverflow.com/questions/19669786/check-if-element-is-visible-in-dom
+ if (elem.offsetParent === null) {
+ return false;
+ }
+
+ return true;
}
+ // Determines if a focusable element can be focused at a given point in time
function isCurrentlyFocusable(elem) {
- if (elem.disabled) return !1;
- if ("-1" === elem.getAttribute("tabindex")) return !1;
- if ("INPUT" === elem.tagName) {
- var type = elem.type;
- if ("range" === type) return !1;
- if ("file" === type) return !1
+
+ if (elem.disabled) {
+ return false;
}
- return isCurrentlyFocusableInternal(elem)
+
+ if (elem.getAttribute('tabindex') === "-1") {
+ return false;
+ }
+
+ if (elem.tagName === 'INPUT') {
+ var type = elem.type;
+ if (type === 'range') {
+ return false;
+ }
+ if (type === 'file') {
+ return false;
+ }
+ }
+
+ return isCurrentlyFocusableInternal(elem);
}
function getDefaultScope() {
- return scopes[0] || document.body
+ return scopes[0] || document.body;
}
function getFocusableElements(parent, limit, excludeClass) {
- for (var elems = (parent || getDefaultScope()).querySelectorAll(focusableQuery), focusableElements = [], i = 0, length = elems.length; i < length; i++) {
+ var elems = (parent || getDefaultScope()).querySelectorAll(focusableQuery);
+ var focusableElements = [];
+
+ for (var i = 0, length = elems.length; i < length; i++) {
+
var elem = elems[i];
- if ((!excludeClass || !elem.classList.contains(excludeClass)) && (isCurrentlyFocusableInternal(elem) && (focusableElements.push(elem), limit && focusableElements.length >= limit))) break
+
+ if (excludeClass && elem.classList.contains(excludeClass)) {
+ continue;
+ }
+
+ if (isCurrentlyFocusableInternal(elem)) {
+ focusableElements.push(elem);
+
+ if (limit && focusableElements.length >= limit) {
+ break;
+ }
+ }
}
- return focusableElements
+
+ return focusableElements;
}
function isFocusContainer(elem, direction) {
- if (-1 !== focusableContainerTagNames.indexOf(elem.tagName)) return !0;
- var classList = elem.classList;
- if (classList.contains("focuscontainer")) return !0;
- if (0 === direction) {
- if (classList.contains("focuscontainer-x")) return !0;
- if (classList.contains("focuscontainer-left")) return !0
- } else if (1 === direction) {
- if (classList.contains("focuscontainer-x")) return !0;
- if (classList.contains("focuscontainer-right")) return !0
- } else if (2 === direction) {
- if (classList.contains("focuscontainer-y")) return !0
- } else if (3 === direction) {
- if (classList.contains("focuscontainer-y")) return !0;
- if (classList.contains("focuscontainer-down")) return !0
+
+ if (focusableContainerTagNames.indexOf(elem.tagName) !== -1) {
+ return true;
}
- return !1
+
+ var classList = elem.classList;
+
+ if (classList.contains('focuscontainer')) {
+ return true;
+ }
+
+ if (direction === 0) {
+ if (classList.contains('focuscontainer-x')) {
+ return true;
+ }
+ if (classList.contains('focuscontainer-left')) {
+ return true;
+ }
+ }
+ else if (direction === 1) {
+ if (classList.contains('focuscontainer-x')) {
+ return true;
+ }
+ if (classList.contains('focuscontainer-right')) {
+ return true;
+ }
+ }
+ else if (direction === 2) {
+ if (classList.contains('focuscontainer-y')) {
+ return true;
+ }
+ }
+ else if (direction === 3) {
+ if (classList.contains('focuscontainer-y')) {
+ return true;
+ }
+ if (classList.contains('focuscontainer-down')) {
+ return true;
+ }
+ }
+
+ return false;
}
function getFocusContainer(elem, direction) {
- for (; !isFocusContainer(elem, direction);)
- if (!(elem = elem.parentNode)) return getDefaultScope();
- return elem
+ while (!isFocusContainer(elem, direction)) {
+ elem = elem.parentNode;
+
+ if (!elem) {
+ return getDefaultScope();
+ }
+ }
+
+ return elem;
}
function getOffset(elem) {
+
var box;
- if (box = elem.getBoundingClientRect ? elem.getBoundingClientRect() : {
+
+ // Support: BlackBerry 5, iOS 3 (original iPhone)
+ // If we don't have gBCR, just use 0,0 rather than error
+ if (elem.getBoundingClientRect) {
+ box = elem.getBoundingClientRect();
+ } else {
+ box = {
top: 0,
left: 0,
width: 0,
height: 0
- }, null === box.right) {
- box = {
+ };
+ }
+
+ if (box.right === null) {
+
+ // Create a new object because some browsers will throw an error when trying to set data onto the Rect object
+ var newBox = {
top: box.top,
left: box.left,
width: box.width,
height: box.height
- }, box.right = box.left + box.width, box.bottom = box.top + box.height
+ };
+
+ box = newBox;
+
+ box.right = box.left + box.width;
+ box.bottom = box.top + box.height;
}
- return box
+
+ return box;
}
function nav(activeElement, direction, container, focusableElements) {
- if (activeElement = activeElement || document.activeElement, activeElement && (activeElement = focusableParent(activeElement)), container = container || (activeElement ? getFocusContainer(activeElement, direction) : getDefaultScope()), !activeElement) return void autoFocus(container, !0, !1);
- for (var nearestElement, focusableContainer = dom.parentWithClass(activeElement, "focusable"), rect = getOffset(activeElement), point1x = parseFloat(rect.left) || 0, point1y = parseFloat(rect.top) || 0, point2x = parseFloat(point1x + rect.width - 1) || point1x, point2y = parseFloat(point1y + rect.height - 1) || point1y, sourceMidX = (Math.min, Math.max, rect.left + rect.width / 2), sourceMidY = rect.top + rect.height / 2, focusable = focusableElements || container.querySelectorAll(focusableQuery), minDistance = 1 / 0, i = 0, length = focusable.length; i < length; i++) {
+
+ activeElement = activeElement || document.activeElement;
+
+ if (activeElement) {
+ activeElement = focusableParent(activeElement);
+ }
+
+ container = container || (activeElement ? getFocusContainer(activeElement, direction) : getDefaultScope());
+
+ if (!activeElement) {
+ autoFocus(container, true, false);
+ return;
+ }
+
+ var focusableContainer = dom.parentWithClass(activeElement, 'focusable');
+
+ var rect = getOffset(activeElement);
+
+ // Get elements and work out x/y points
+ var cache = [],
+ point1x = parseFloat(rect.left) || 0,
+ point1y = parseFloat(rect.top) || 0,
+ point2x = parseFloat(point1x + rect.width - 1) || point1x,
+ point2y = parseFloat(point1y + rect.height - 1) || point1y,
+ // Shortcuts to help with compression
+ min = Math.min,
+ max = Math.max;
+
+ var sourceMidX = rect.left + (rect.width / 2);
+ var sourceMidY = rect.top + (rect.height / 2);
+
+ var focusable = focusableElements || container.querySelectorAll(focusableQuery);
+
+ var maxDistance = Infinity;
+ var minDistance = maxDistance;
+ var nearestElement;
+
+ for (var i = 0, length = focusable.length; i < length; i++) {
var curr = focusable[i];
- if (curr !== activeElement && curr !== focusableContainer) {
- var elementRect = getOffset(curr);
- if (elementRect.width || elementRect.height) {
- switch (direction) {
- case 0:
- if (elementRect.left >= rect.left) continue;
- if (elementRect.right === rect.right) continue;
- break;
- case 1:
- if (elementRect.right <= rect.right) continue;
- if (elementRect.left === rect.left) continue;
- break;
- case 2:
- if (elementRect.top >= rect.top) continue;
- if (elementRect.bottom >= rect.bottom) continue;
- break;
- case 3:
- if (elementRect.bottom <= rect.bottom) continue;
- if (elementRect.top <= rect.top) continue
+
+ if (curr === activeElement) {
+ continue;
+ }
+ // Don't refocus into the same container
+ if (curr === focusableContainer) {
+ continue;
+ }
+
+ //if (!isCurrentlyFocusableInternal(curr)) {
+ // continue;
+ //}
+
+ var elementRect = getOffset(curr);
+
+ // not currently visible
+ if (!elementRect.width && !elementRect.height) {
+ continue;
+ }
+
+ switch (direction) {
+
+ case 0:
+ // left
+ if (elementRect.left >= rect.left) {
+ continue;
}
- var distX, distY, x = elementRect.left,
- y = elementRect.top,
- x2 = x + elementRect.width - 1,
- y2 = y + elementRect.height - 1,
- intersectX = intersects(point1x, point2x, x, x2),
- intersectY = intersects(point1y, point2y, y, y2),
- midX = elementRect.left + elementRect.width / 2,
- midY = elementRect.top + elementRect.height / 2;
- switch (direction) {
- case 0:
- distX = Math.abs(point1x - Math.min(point1x, x2)), distY = intersectY ? 0 : Math.abs(sourceMidY - midY);
- break;
- case 1:
- distX = Math.abs(point2x - Math.max(point2x, x)), distY = intersectY ? 0 : Math.abs(sourceMidY - midY);
- break;
- case 2:
- distY = Math.abs(point1y - Math.min(point1y, y2)), distX = intersectX ? 0 : Math.abs(sourceMidX - midX);
- break;
- case 3:
- distY = Math.abs(point2y - Math.max(point2y, y)), distX = intersectX ? 0 : Math.abs(sourceMidX - midX)
+ if (elementRect.right === rect.right) {
+ continue;
}
- var dist = Math.sqrt(distX * distX + distY * distY);
- dist < minDistance && (nearestElement = curr, minDistance = dist)
- }
+ break;
+ case 1:
+ // right
+ if (elementRect.right <= rect.right) {
+ continue;
+ }
+ if (elementRect.left === rect.left) {
+ continue;
+ }
+ break;
+ case 2:
+ // up
+ if (elementRect.top >= rect.top) {
+ continue;
+ }
+ if (elementRect.bottom >= rect.bottom) {
+ continue;
+ }
+ break;
+ case 3:
+ // down
+ if (elementRect.bottom <= rect.bottom) {
+ continue;
+ }
+ if (elementRect.top <= rect.top) {
+ continue;
+ }
+ break;
+ default:
+ break;
+ }
+
+ var x = elementRect.left,
+ y = elementRect.top,
+ x2 = x + elementRect.width - 1,
+ y2 = y + elementRect.height - 1;
+
+ var intersectX = intersects(point1x, point2x, x, x2);
+ var intersectY = intersects(point1y, point2y, y, y2);
+
+ var midX = elementRect.left + (elementRect.width / 2);
+ var midY = elementRect.top + (elementRect.height / 2);
+
+ var distX;
+ var distY;
+
+ switch (direction) {
+
+ case 0:
+ // left
+ distX = Math.abs(point1x - Math.min(point1x, x2));
+ distY = intersectY ? 0 : Math.abs(sourceMidY - midY);
+ break;
+ case 1:
+ // right
+ distX = Math.abs(point2x - Math.max(point2x, x));
+ distY = intersectY ? 0 : Math.abs(sourceMidY - midY);
+ break;
+ case 2:
+ // up
+ distY = Math.abs(point1y - Math.min(point1y, y2));
+ distX = intersectX ? 0 : Math.abs(sourceMidX - midX);
+ break;
+ case 3:
+ // down
+ distY = Math.abs(point2y - Math.max(point2y, y));
+ distX = intersectX ? 0 : Math.abs(sourceMidX - midX);
+ break;
+ default:
+ break;
+ }
+
+ var dist = Math.sqrt(distX * distX + distY * distY);
+
+ if (dist < minDistance) {
+ nearestElement = curr;
+ minDistance = dist;
}
}
+
if (nearestElement) {
+
+ // See if there's a focusable container, and if so, send the focus command to that
if (activeElement) {
- var nearestElementFocusableParent = dom.parentWithClass(nearestElement, "focusable");
- nearestElementFocusableParent && nearestElementFocusableParent !== nearestElement && focusableContainer !== nearestElementFocusableParent && (nearestElement = nearestElementFocusableParent)
+ var nearestElementFocusableParent = dom.parentWithClass(nearestElement, 'focusable');
+ if (nearestElementFocusableParent && nearestElementFocusableParent !== nearestElement) {
+ if (focusableContainer !== nearestElementFocusableParent) {
+ nearestElement = nearestElementFocusableParent;
+ }
+ }
}
- focus(nearestElement)
+ focus(nearestElement);
}
}
function intersectsInternal(a1, a2, b1, b2) {
- return b1 >= a1 && b1 <= a2 || b2 >= a1 && b2 <= a2
+
+ return (b1 >= a1 && b1 <= a2) || (b2 >= a1 && b2 <= a2);
}
function intersects(a1, a2, b1, b2) {
- return intersectsInternal(a1, a2, b1, b2) || intersectsInternal(b1, b2, a1, a2)
+
+ return intersectsInternal(a1, a2, b1, b2) || intersectsInternal(b1, b2, a1, a2);
}
function sendText(text) {
- document.activeElement.value = text
+ var elem = document.activeElement;
+
+ elem.value = text;
}
function focusFirst(container, focusableSelector) {
- for (var elems = container.querySelectorAll(focusableSelector), i = 0, length = elems.length; i < length; i++) {
+
+ var elems = container.querySelectorAll(focusableSelector);
+
+ for (var i = 0, length = elems.length; i < length; i++) {
+
var elem = elems[i];
+
if (isCurrentlyFocusableInternal(elem)) {
focus(elem);
- break
+ break;
}
}
}
function focusLast(container, focusableSelector) {
- for (var elems = [].slice.call(container.querySelectorAll(focusableSelector), 0).reverse(), i = 0, length = elems.length; i < length; i++) {
+
+ var elems = [].slice.call(container.querySelectorAll(focusableSelector), 0).reverse();
+
+ for (var i = 0, length = elems.length; i < length; i++) {
+
var elem = elems[i];
+
if (isCurrentlyFocusableInternal(elem)) {
focus(elem);
- break
+ break;
}
}
}
function moveFocus(sourceElement, container, focusableSelector, offset) {
- var i, length, elem, elems = container.querySelectorAll(focusableSelector),
- list = [];
- for (i = 0, length = elems.length; i < length; i++) elem = elems[i], isCurrentlyFocusableInternal(elem) && list.push(elem);
+
+ var elems = container.querySelectorAll(focusableSelector);
+ var list = [];
+ var i, length, elem;
+
+ for (i = 0, length = elems.length; i < length; i++) {
+
+ elem = elems[i];
+
+ if (isCurrentlyFocusableInternal(elem)) {
+ list.push(elem);
+ }
+ }
+
var currentIndex = -1;
- for (i = 0, length = list.length; i < length; i++)
- if (elem = list[i], sourceElement === elem || elem.contains(sourceElement)) {
+
+ for (i = 0, length = list.length; i < length; i++) {
+
+ elem = list[i];
+
+ if (sourceElement === elem || elem.contains(sourceElement)) {
currentIndex = i;
- break
- } if (-1 !== currentIndex) {
- var newIndex = currentIndex + offset;
- newIndex = Math.max(0, newIndex), newIndex = Math.min(newIndex, list.length - 1);
- var newElem = list[newIndex];
- newElem && focus(newElem)
+ break;
+ }
+ }
+
+ if (currentIndex === -1) {
+ return;
+ }
+
+ var newIndex = currentIndex + offset;
+ newIndex = Math.max(0, newIndex);
+ newIndex = Math.min(newIndex, list.length - 1);
+
+ var newElem = list[newIndex];
+ if (newElem) {
+ focus(newElem);
}
}
- var scopes = [],
- focusableTagNames = ["INPUT", "TEXTAREA", "SELECT", "BUTTON", "A"],
- focusableContainerTagNames = ["BODY", "DIALOG"],
- focusableQuery = focusableTagNames.map(function(t) {
- return "INPUT" === t && (t += ':not([type="range"]):not([type="file"])'), t + ':not([tabindex="-1"]):not(:disabled)'
- }).join(",") + ",.focusable";
+
return {
autoFocus: autoFocus,
focus: focus,
focusableParent: focusableParent,
getFocusableElements: getFocusableElements,
- moveLeft: function(sourceElement, options) {
- nav(sourceElement, 0, options ? options.container : null, options ? options.focusableElements : null)
+ moveLeft: function (sourceElement, options) {
+
+ var container = options ? options.container : null;
+ var focusableElements = options ? options.focusableElements : null;
+ nav(sourceElement, 0, container, focusableElements);
+
},
- moveRight: function(sourceElement, options) {
- nav(sourceElement, 1, options ? options.container : null, options ? options.focusableElements : null)
+ moveRight: function (sourceElement, options) {
+
+ var container = options ? options.container : null;
+ var focusableElements = options ? options.focusableElements : null;
+ nav(sourceElement, 1, container, focusableElements);
+
},
- moveUp: function(sourceElement, options) {
- nav(sourceElement, 2, options ? options.container : null, options ? options.focusableElements : null)
+ moveUp: function (sourceElement, options) {
+
+ var container = options ? options.container : null;
+ var focusableElements = options ? options.focusableElements : null;
+ nav(sourceElement, 2, container, focusableElements);
+
},
- moveDown: function(sourceElement, options) {
- nav(sourceElement, 3, options ? options.container : null, options ? options.focusableElements : null)
+ moveDown: function (sourceElement, options) {
+
+ var container = options ? options.container : null;
+ var focusableElements = options ? options.focusableElements : null;
+ nav(sourceElement, 3, container, focusableElements);
+
},
sendText: sendText,
isCurrentlyFocusable: isCurrentlyFocusable,
@@ -252,5 +547,5 @@ define(["dom"], function(dom) {
focusFirst: focusFirst,
focusLast: focusLast,
moveFocus: moveFocus
- }
+ };
});
\ No newline at end of file
diff --git a/src/bower_components/emby-webcomponents/fonts/fonts.css b/src/bower_components/emby-webcomponents/fonts/fonts.css
index 112441ad18..12f1eaf4b7 100644
--- a/src/bower_components/emby-webcomponents/fonts/fonts.css
+++ b/src/bower_components/emby-webcomponents/fonts/fonts.css
@@ -1,39 +1,37 @@
-h1,
-h2,
-h3 {
- font-weight: 500
+html {
+ font-family: -apple-system, "Helvetica", system-ui, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen-Sans", "Ubuntu", "Cantarell", "Helvetica Neue", 'Open Sans', sans-serif;
}
html {
- font-family: -apple-system, Helvetica, system-ui, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", 'Open Sans', sans-serif;
font-size: 93%;
-webkit-text-size-adjust: 100%;
- -moz-text-size-adjust: 100%;
- text-size-adjust: 100%
+ text-size-adjust: 100%;
}
-h1,
-h2,
-h3 {
- font-family: -apple-system, system-ui, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", 'Open Sans', sans-serif
+h1, h2, h3 {
+ /* For better bolding, since Helvetica does not support 500 weight, and 600 is too thick */
+ font-family: -apple-system, system-ui, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen-Sans", "Ubuntu", "Cantarell", "Helvetica Neue", 'Open Sans', sans-serif;
}
h1 {
- font-size: 1.8em
+ font-weight: 500;
+ font-size: 1.8em;
}
h2 {
- font-size: 1.5em
+ font-weight: 500;
+ font-size: 1.5em;
}
h3 {
- font-size: 1.17em
+ font-weight: 500;
+ font-size: 1.17em;
}
.layout-tv {
- font-size: 2.5vh
+ font-size: 2.5vh;
}
.layout-mobile {
- font-size: 90%
-}
\ No newline at end of file
+ font-size: 90%;
+}
diff --git a/src/bower_components/emby-webcomponents/fonts/fonts.sized.css b/src/bower_components/emby-webcomponents/fonts/fonts.sized.css
index f8722d0016..073b74167c 100644
--- a/src/bower_components/emby-webcomponents/fonts/fonts.sized.css
+++ b/src/bower_components/emby-webcomponents/fonts/fonts.sized.css
@@ -1,33 +1,32 @@
-h1,
-h2,
-h3 {
- font-weight: 500
-}
-
h1 {
- font-size: 1.8em
+ font-weight: 500;
+ font-size: 1.8em;
}
.layout-desktop h1 {
- font-size: 2em
+ font-size: 2em;
}
h2 {
- font-size: 1.5em
+ font-weight: 500;
+ font-size: 1.5em;
}
h3 {
- font-size: 1.17em
+ font-weight: 500;
+ font-size: 1.17em;
}
-@media all and (min-height:720px) {
+@media all and (min-height: 720px) {
html {
- font-size: 20px
+ font-size: 20px;
}
}
-@media all and (min-height:1000px) {
+/* This is supposed to be 1080p, but had to reduce the min height to account for possible browser chrome */
+@media all and (min-height: 1000px) {
+
html {
- font-size: 27px
+ font-size: 27px;
}
-}
\ No newline at end of file
+}
diff --git a/src/bower_components/emby-webcomponents/fonts/material-icons/style.css b/src/bower_components/emby-webcomponents/fonts/material-icons/style.css
index bcaf041b93..2d410b9985 100644
--- a/src/bower_components/emby-webcomponents/fonts/material-icons/style.css
+++ b/src/bower_components/emby-webcomponents/fonts/material-icons/style.css
@@ -2,12 +2,12 @@
font-family: 'Material Icons';
font-style: normal;
font-weight: 400;
- src: local('Material Icons'), local('MaterialIcons-Regular'), url(flUhRq6tzZclQEJ-Vdg-IuiaDsNc.woff2) format('woff2'), url(flUhRq6tzZclQEJ-Vdg-IuiaDsNa.woff) format('woff')
+ src: local('Material Icons'), local('MaterialIcons-Regular'), url(flUhRq6tzZclQEJ-Vdg-IuiaDsNc.woff2) format('woff2'), url(flUhRq6tzZclQEJ-Vdg-IuiaDsNa.woff) format('woff');
}
.md-icon {
font-family: 'Material Icons';
- font-weight: 400;
+ font-weight: normal;
font-style: normal;
letter-spacing: normal;
text-transform: none;
@@ -15,12 +15,11 @@
white-space: nowrap;
word-wrap: normal;
direction: ltr;
+ -webkit-font-feature-settings: 'liga';
-webkit-font-smoothing: antialiased;
text-rendering: optimizeLegibility;
- -webkit-font-feature-settings: "liga"1;
- -moz-font-feature-settings: "liga"1;
- font-feature-settings: "liga"1;
+ font-feature-settings: "liga" 1;
line-height: 1;
overflow: hidden;
- vertical-align: middle
-}
\ No newline at end of file
+ vertical-align: middle;
+}
diff --git a/src/bower_components/emby-webcomponents/formdialog.css b/src/bower_components/emby-webcomponents/formdialog.css
index d44a7ed871..b976d8130e 100644
--- a/src/bower_components/emby-webcomponents/formdialog.css
+++ b/src/bower_components/emby-webcomponents/formdialog.css
@@ -1,145 +1,115 @@
-.formDialog,
-.formDialogHeader {
- display: -webkit-box;
- display: -webkit-flex
-}
-
-.formDialog,
-.formDialogFooter-vertical {
- -webkit-box-orient: vertical;
- -webkit-box-direction: normal
-}
-
.formDialog {
display: flex;
- -webkit-flex-direction: column;
flex-direction: column;
- position: relative
+ position: relative;
}
.formDialogHeader {
padding: 1em .5em;
display: flex;
- -webkit-box-align: center;
- -webkit-align-items: center;
align-items: center;
- -webkit-flex-shrink: 0;
- flex-shrink: 0
+ flex-shrink: 0;
}
.formDialogHeaderTitle {
margin-left: .25em;
+ /* In case of h1, h2, h3 */
margin-top: 0;
- margin-bottom: 0
+ margin-bottom: 0;
}
.formDialogContent:not(.no-grow) {
- -webkit-box-flex: 1;
- -webkit-flex-grow: 1;
- flex-grow: 1
+ flex-grow: 1;
}
.dialogContentInner {
- padding: .5em 1em 20em
+ padding: .5em 1em 20em 1em;
}
.dialogContentInner-mini {
- padding-bottom: 10em
+ padding-bottom: 10em;
}
.dialog-content-centered {
margin: 0 auto;
- max-width: 53em
+ max-width: 53em;
}
.dialogContentTitle {
- margin-top: 1em
+ margin-top: 1em;
}
.formDialogFooter {
bottom: 0;
left: 0;
right: 0;
- display: -webkit-box;
- display: -webkit-flex;
display: flex;
position: absolute;
padding: 1.25em 1em;
+ /* Without this emby-checkbox is able to appear on top */
z-index: 1;
- -webkit-box-align: center;
- -webkit-align-items: center;
align-items: center;
- -webkit-box-pack: center;
- -webkit-justify-content: center;
justify-content: center;
- -webkit-flex-wrap: wrap;
- flex-wrap: wrap
+ flex-wrap: wrap;
}
.formDialogFooter-flex {
position: static;
- width: 100%
+ width: 100%;
}
.formDialogFooter-vertical {
padding-bottom: 1.5em;
- -webkit-flex-direction: column;
flex-direction: column;
width: 80% !important;
- padding-top: .5em
+ padding-top: .5em;
}
.formDialogFooterItem {
margin: .5em !important;
- -webkit-box-flex: 1;
- -webkit-flex-grow: 1;
flex-grow: 1;
text-align: center;
- -webkit-flex-basis: 0;
- flex-basis: 0
+ flex-basis: 0;
}
.formDialogFooterItem-vertical {
max-width: none !important;
width: 100%;
- -webkit-box-pack: center;
- -webkit-justify-content: center;
justify-content: center;
- margin: 1em !important
+ margin: 1em !important;
}
.formDialogFooterItem-nomarginbottom {
- margin-bottom: 0 !important
+ margin-bottom: 0 !important;
}
.formDialogFooterItem-autosize {
- -webkit-flex-basis: initial;
flex-basis: initial;
- -webkit-box-flex: initial;
- -webkit-flex-grow: initial;
flex-grow: initial;
padding-left: 2em;
- padding-right: 2em
+ padding-right: 2em;
}
-@media all and (min-width:50em) {
+@media all and (min-width: 50em) {
+
.formDialogFooterItem {
- max-width: 80%
+ max-width: 80%;
}
.dialogContentInner {
padding-left: 1.5em;
- padding-right: 1.5em
+ padding-right: 1.5em;
}
}
-@media all and (min-width:80em) {
+@media all and (min-width: 80em) {
+
.formDialogFooterItem {
- max-width: 70%
+ max-width: 70%;
}
.dialogContentInner {
padding-left: 2em;
- padding-right: 2em
+ padding-right: 2em;
}
-}
\ No newline at end of file
+}
diff --git a/src/bower_components/emby-webcomponents/fullscreen/fullscreen-dc.js b/src/bower_components/emby-webcomponents/fullscreen/fullscreen-dc.js
index a7f6ff1e13..bc12a6a76d 100644
--- a/src/bower_components/emby-webcomponents/fullscreen/fullscreen-dc.js
+++ b/src/bower_components/emby-webcomponents/fullscreen/fullscreen-dc.js
@@ -1,12 +1,26 @@
-define(["dom", "fullscreenManager"], function(dom, fullscreenManager) {
- "use strict";
+define(['dom', 'fullscreenManager'], function (dom, fullscreenManager) {
+ 'use strict';
function isTargetValid(target) {
- return !dom.parentWithTag(target, ["BUTTON", "INPUT", "TEXTAREA"])
+
+ if (dom.parentWithTag(target, ['BUTTON', 'INPUT', 'TEXTAREA'])) {
+ return false;
+ }
+
+ return true;
}
- dom.addEventListener(window, "dblclick", function(e) {
- isTargetValid(e.target) && (fullscreenManager.isFullScreen() ? fullscreenManager.exitFullscreen() : fullscreenManager.requestFullscreen())
+
+ dom.addEventListener(window, 'dblclick', function (e) {
+
+ if (isTargetValid(e.target)) {
+ if (fullscreenManager.isFullScreen()) {
+ fullscreenManager.exitFullscreen();
+ } else {
+ fullscreenManager.requestFullscreen();
+ }
+ }
+
}, {
- passive: !0
- })
+ passive: true
+ });
});
\ No newline at end of file
diff --git a/src/bower_components/emby-webcomponents/fullscreen/fullscreenmanager.js b/src/bower_components/emby-webcomponents/fullscreen/fullscreenmanager.js
index adfee87460..d39d8fd3b6 100644
--- a/src/bower_components/emby-webcomponents/fullscreen/fullscreenmanager.js
+++ b/src/bower_components/emby-webcomponents/fullscreen/fullscreenmanager.js
@@ -1,24 +1,74 @@
-define(["events", "dom"], function(events, dom) {
- "use strict";
+define(['events', 'dom'], function (events, dom) {
+ 'use strict';
- function fullscreenManager() {}
+ function fullscreenManager() {
+
+ }
+
+ fullscreenManager.prototype.requestFullscreen = function (element) {
+
+ element = element || document.documentElement;
+
+ if (element.requestFullscreen) {
+ element.requestFullscreen();
+ return;
+ } else if (element.mozRequestFullScreen) {
+ element.mozRequestFullScreen();
+ return;
+ } else if (element.webkitRequestFullscreen) {
+ element.webkitRequestFullscreen();
+ return;
+ } else if (element.msRequestFullscreen) {
+ element.msRequestFullscreen();
+ return;
+ }
+
+ // Hack - This is only available for video elements in ios safari
+ if (element.tagName !== 'VIDEO') {
+ element = document.querySelector('video') || element;
+ }
+ if (element.webkitEnterFullscreen) {
+ element.webkitEnterFullscreen();
+ }
+ };
+
+ fullscreenManager.prototype.exitFullscreen = function () {
+
+ if (document.exitFullscreen) {
+ document.exitFullscreen();
+ } else if (document.mozCancelFullScreen) {
+ document.mozCancelFullScreen();
+ } else if (document.webkitExitFullscreen) {
+ document.webkitExitFullscreen();
+ } else if (document.webkitCancelFullscreen) {
+ document.webkitCancelFullscreen();
+ } else if (document.msExitFullscreen) {
+ document.msExitFullscreen();
+ }
+ };
+
+ fullscreenManager.prototype.isFullScreen = function () {
+
+ return document.fullscreen || document.mozFullScreen || document.webkitIsFullScreen || document.msFullscreenElement ? true : false;
+ };
+
+ var manager = new fullscreenManager();
function onFullScreenChange() {
- events.trigger(manager, "fullscreenchange")
+ events.trigger(manager, 'fullscreenchange');
}
- fullscreenManager.prototype.requestFullscreen = function(element) {
- return element = element || document.documentElement, element.requestFullscreen ? void element.requestFullscreen() : element.mozRequestFullScreen ? void element.mozRequestFullScreen() : element.webkitRequestFullscreen ? void element.webkitRequestFullscreen() : element.msRequestFullscreen ? void element.msRequestFullscreen() : ("VIDEO" !== element.tagName && (element = document.querySelector("video") || element), void(element.webkitEnterFullscreen && element.webkitEnterFullscreen()))
- }, fullscreenManager.prototype.exitFullscreen = function() {
- document.exitFullscreen ? document.exitFullscreen() : document.mozCancelFullScreen ? document.mozCancelFullScreen() : document.webkitExitFullscreen ? document.webkitExitFullscreen() : document.webkitCancelFullscreen ? document.webkitCancelFullscreen() : document.msExitFullscreen && document.msExitFullscreen()
- }, fullscreenManager.prototype.isFullScreen = function() {
- return !!(document.fullscreen || document.mozFullScreen || document.webkitIsFullScreen || document.msFullscreenElement)
- };
- var manager = new fullscreenManager;
- return dom.addEventListener(document, "fullscreenchange", onFullScreenChange, {
- passive: !0
- }), dom.addEventListener(document, "webkitfullscreenchange", onFullScreenChange, {
- passive: !0
- }), dom.addEventListener(document, "mozfullscreenchange", onFullScreenChange, {
- passive: !0
- }), manager
+
+ dom.addEventListener(document, 'fullscreenchange', onFullScreenChange, {
+ passive: true
+ });
+
+ dom.addEventListener(document, 'webkitfullscreenchange', onFullScreenChange, {
+ passive: true
+ });
+
+ dom.addEventListener(document, 'mozfullscreenchange', onFullScreenChange, {
+ passive: true
+ });
+
+ return manager;
});
\ No newline at end of file
diff --git a/src/bower_components/emby-webcomponents/globalize.js b/src/bower_components/emby-webcomponents/globalize.js
index 0390860404..c36dea1910 100644
--- a/src/bower_components/emby-webcomponents/globalize.js
+++ b/src/bower_components/emby-webcomponents/globalize.js
@@ -1,127 +1,287 @@
-define(["connectionManager", "userSettings", "events"], function(connectionManager, userSettings, events) {
- "use strict";
+define(['connectionManager', 'userSettings', 'events'], function (connectionManager, userSettings, events) {
+ 'use strict';
+
+ var allTranslations = {};
+ var currentCulture;
+ var currentDateTimeCulture;
function getCurrentLocale() {
- return currentCulture
+
+ return currentCulture;
}
function getCurrentDateTimeLocale() {
- return currentDateTimeCulture
+ return currentDateTimeCulture;
}
function getDefaultLanguage() {
- var culture = document.documentElement.getAttribute("data-culture");
- return culture || (navigator.language ? navigator.language : navigator.userLanguage ? navigator.userLanguage : navigator.languages && navigator.languages.length ? navigator.languages[0] : "en-us")
+
+ var culture = document.documentElement.getAttribute('data-culture');
+
+ if (culture) {
+ return culture;
+ }
+
+ if (navigator.language) {
+ return navigator.language;
+ }
+ if (navigator.userLanguage) {
+ return navigator.userLanguage;
+ }
+ if (navigator.languages && navigator.languages.length) {
+ return navigator.languages[0];
+ }
+
+ return 'en-us';
}
function updateCurrentCulture() {
+
var culture;
try {
- culture = userSettings.language()
- } catch (err) {}
- culture = culture || getDefaultLanguage(), currentCulture = normalizeLocaleName(culture);
+ culture = userSettings.language();
+ } catch (err) {
+
+ }
+ culture = culture || getDefaultLanguage();
+
+ currentCulture = normalizeLocaleName(culture);
+
var dateTimeCulture;
try {
- dateTimeCulture = userSettings.dateTimeLocale()
- } catch (err) {}
- currentDateTimeCulture = dateTimeCulture ? normalizeLocaleName(dateTimeCulture) : currentCulture, ensureTranslations(currentCulture)
+ dateTimeCulture = userSettings.dateTimeLocale();
+ } catch (err) {
+
+ }
+
+ if (dateTimeCulture) {
+ currentDateTimeCulture = normalizeLocaleName(dateTimeCulture);
+ }
+ else {
+ currentDateTimeCulture = currentCulture;
+ }
+
+ ensureTranslations(currentCulture);
}
function ensureTranslations(culture) {
- for (var i in allTranslations) ensureTranslation(allTranslations[i], culture)
- }
- function ensureTranslation(translationInfo, culture) {
- return translationInfo.dictionaries[culture] ? Promise.resolve() : loadTranslation(translationInfo.translations, culture).then(function(dictionary) {
- translationInfo.dictionaries[culture] = dictionary
- })
- }
-
- function normalizeLocaleName(culture) {
- culture = culture.replace("_", "-");
- var parts = culture.split("-");
- 2 === parts.length && parts[0].toLowerCase() === parts[1].toLowerCase() && (culture = parts[0].toLowerCase());
- var lower = culture.toLowerCase();
- return "ca-es" === lower ? "ca" : "sv-se" === lower ? "sv" : lower
- }
-
- function getDictionary(module) {
- module || (module = defaultModule());
- var translations = allTranslations[module];
- return translations ? translations.dictionaries[getCurrentLocale()] : {}
- }
-
- function register(options) {
- allTranslations[options.name] = {
- translations: options.strings || options.translations,
- dictionaries: {}
+ for (var i in allTranslations) {
+ ensureTranslation(allTranslations[i], culture);
}
}
- function loadStrings(options) {
- var locale = getCurrentLocale();
- return "string" == typeof options ? ensureTranslation(allTranslations[options], locale) : (register(options), ensureTranslation(allTranslations[options.name], locale))
+ function ensureTranslation(translationInfo, culture) {
+
+ if (translationInfo.dictionaries[culture]) {
+ return Promise.resolve();
+ }
+
+ return loadTranslation(translationInfo.translations, culture).then(function (dictionary) {
+
+ translationInfo.dictionaries[culture] = dictionary;
+ });
}
+ function normalizeLocaleName(culture) {
+
+ culture = culture.replace('_', '-');
+
+ // If it's de-DE, convert to just de
+ var parts = culture.split('-');
+ if (parts.length === 2) {
+ if (parts[0].toLowerCase() === parts[1].toLowerCase()) {
+ culture = parts[0].toLowerCase();
+ }
+ }
+
+ var lower = culture.toLowerCase();
+
+ if (lower === 'ca-es') {
+ return 'ca';
+ }
+
+ // normalize Swedish
+ if (lower === 'sv-se') {
+ return 'sv';
+ }
+
+ return lower;
+ }
+
+ function getDictionary(module) {
+
+ if (!module) {
+ module = defaultModule();
+ }
+
+ var translations = allTranslations[module];
+
+ if (!translations) {
+ return {};
+ }
+
+ return translations.dictionaries[getCurrentLocale()];
+ }
+
+ function register(options) {
+
+ allTranslations[options.name] = {
+ translations: options.strings || options.translations,
+ dictionaries: {}
+ };
+ }
+
+ function loadStrings(options) {
+
+ var locale = getCurrentLocale();
+
+ if (typeof options === 'string') {
+ return ensureTranslation(allTranslations[options], locale);
+ } else {
+ register(options);
+ return ensureTranslation(allTranslations[options.name], locale);
+ }
+ }
+
+ var cacheParam = new Date().getTime();
function loadTranslation(translations, lang) {
+
lang = normalizeLocaleName(lang);
- var filtered = translations.filter(function(t) {
- return normalizeLocaleName(t.lang) === lang
+
+ var filtered = translations.filter(function (t) {
+ return normalizeLocaleName(t.lang) === lang;
});
- return filtered.length || (filtered = translations.filter(function(t) {
- return "en-us" === normalizeLocaleName(t.lang)
- })), new Promise(function(resolve, reject) {
- if (!filtered.length) return void resolve();
+
+ if (!filtered.length) {
+ filtered = translations.filter(function (t) {
+ return normalizeLocaleName(t.lang) === 'en-us';
+ });
+ }
+
+ return new Promise(function (resolve, reject) {
+
+ if (!filtered.length) {
+ resolve();
+ return;
+ }
+
var url = filtered[0].path;
- url += -1 === url.indexOf("?") ? "?" : "&", url += "v=" + cacheParam;
- var xhr = new XMLHttpRequest;
- xhr.open("GET", url, !0), xhr.onload = function(e) {
- resolve(this.status < 400 ? JSON.parse(this.response) : {})
- }, xhr.onerror = function() {
- resolve({})
- }, xhr.send()
- })
+
+ url += url.indexOf('?') === -1 ? '?' : '&';
+ url += 'v=' + cacheParam;
+
+ var xhr = new XMLHttpRequest();
+ xhr.open('GET', url, true);
+
+ xhr.onload = function (e) {
+ if (this.status < 400) {
+ resolve(JSON.parse(this.response));
+ } else {
+ resolve({});
+ }
+ };
+
+ xhr.onerror = function () {
+ resolve({});
+ };
+ xhr.send();
+ });
}
function translateKey(key) {
- var module, parts = key.split("#");
- return parts.length > 1 && (module = parts[0], key = parts[1]), translateKeyFromModule(key, module)
+
+ var parts = key.split('#');
+ var module;
+
+ if (parts.length > 1) {
+ module = parts[0];
+ key = parts[1];
+ }
+
+ return translateKeyFromModule(key, module);
}
function translateKeyFromModule(key, module) {
+
var dictionary = getDictionary(module);
- return dictionary ? dictionary[key] || key : key
+
+ if (!dictionary) {
+ return key;
+ }
+
+ return dictionary[key] || key;
}
function replaceAll(str, find, replace) {
- return str.split(find).join(replace)
+
+ return str.split(find).join(replace);
}
function translate(key) {
- for (var val = translateKey(key), i = 1; i < arguments.length; i++) val = replaceAll(val, "{" + (i - 1) + "}", arguments[i]);
- return val
+
+ var val = translateKey(key);
+
+ for (var i = 1; i < arguments.length; i++) {
+
+ val = replaceAll(val, '{' + (i - 1) + '}', arguments[i]);
+
+ }
+
+ return val;
}
function translateHtml(html, module) {
- if (module || (module = defaultModule()), !module) throw new Error("module cannot be null or empty");
- var startIndex = html.indexOf("${");
- if (-1 === startIndex) return html;
+
+ if (!module) {
+ module = defaultModule();
+ }
+
+ if (!module) {
+ throw new Error('module cannot be null or empty');
+ }
+
+ var startIndex = html.indexOf('${');
+
+ if (startIndex === -1) {
+ return html;
+ }
+
startIndex += 2;
- var endIndex = html.indexOf("}", startIndex);
- if (-1 === endIndex) return html;
- var key = html.substring(startIndex, endIndex),
- val = translateKeyFromModule(key, module);
- return html = html.replace("${" + key + "}", val), translateHtml(html, module)
+ var endIndex = html.indexOf('}', startIndex);
+
+ if (endIndex === -1) {
+ return html;
+ }
+
+ var key = html.substring(startIndex, endIndex);
+ var val = translateKeyFromModule(key, module);
+
+ html = html.replace('${' + key + '}', val);
+ return translateHtml(html, module);
}
+ var _defaultModule;
function defaultModule(val) {
- return val && (_defaultModule = val), _defaultModule
+
+ if (val) {
+
+ _defaultModule = val;
+ }
+
+ return _defaultModule;
}
- var currentCulture, currentDateTimeCulture, _defaultModule, allTranslations = {},
- cacheParam = (new Date).getTime();
- return updateCurrentCulture(), events.on(connectionManager, "localusersignedin", updateCurrentCulture), events.on(userSettings, "change", function(e, name) {
- "language" !== name && "datetimelocale" !== name || updateCurrentCulture()
- }), {
+
+ updateCurrentCulture();
+
+ events.on(connectionManager, 'localusersignedin', updateCurrentCulture);
+ events.on(userSettings, 'change', function (e, name) {
+ if (name === 'language' || name === 'datetimelocale') {
+ updateCurrentCulture();
+ }
+ });
+
+ return {
getString: translate,
translate: translate,
translateDocument: translateHtml,
@@ -131,5 +291,5 @@ define(["connectionManager", "userSettings", "events"], function(connectionManag
getCurrentLocale: getCurrentLocale,
getCurrentDateTimeLocale: getCurrentDateTimeLocale,
register: register
- }
+ };
});
\ No newline at end of file
diff --git a/src/bower_components/emby-webcomponents/guide/guide-settings.js b/src/bower_components/emby-webcomponents/guide/guide-settings.js
index 624a582574..e95d750c9a 100644
--- a/src/bower_components/emby-webcomponents/guide/guide-settings.js
+++ b/src/bower_components/emby-webcomponents/guide/guide-settings.js
@@ -1,71 +1,172 @@
-define(["dialogHelper", "globalize", "userSettings", "layoutManager", "connectionManager", "require", "loading", "scrollHelper", "emby-checkbox", "emby-radio", "css!./../formdialog", "material-icons"], function(dialogHelper, globalize, userSettings, layoutManager, connectionManager, require, loading, scrollHelper) {
- "use strict";
+define(['dialogHelper', 'globalize', 'userSettings', 'layoutManager', 'connectionManager', 'require', 'loading', 'scrollHelper', 'emby-checkbox', 'emby-radio', 'css!./../formdialog', 'material-icons'], function (dialogHelper, globalize, userSettings, layoutManager, connectionManager, require, loading, scrollHelper) {
+ 'use strict';
function saveCategories(context, options) {
- for (var categories = [], chkCategorys = context.querySelectorAll(".chkCategory"), i = 0, length = chkCategorys.length; i < length; i++) {
- var type = chkCategorys[i].getAttribute("data-type");
- chkCategorys[i].checked && categories.push(type)
+
+ var categories = [];
+
+ var chkCategorys = context.querySelectorAll('.chkCategory');
+ for (var i = 0, length = chkCategorys.length; i < length; i++) {
+
+ var type = chkCategorys[i].getAttribute('data-type');
+
+ if (chkCategorys[i].checked) {
+ categories.push(type);
+ }
}
- categories.length >= 4 && categories.push("series"), categories.push("all"), options.categories = categories
+
+ if (categories.length >= 4) {
+ categories.push('series');
+ }
+
+ // differentiate between none and all
+ categories.push('all');
+ options.categories = categories;
}
function loadCategories(context, options) {
- for (var selectedCategories = options.categories || [], chkCategorys = context.querySelectorAll(".chkCategory"), i = 0, length = chkCategorys.length; i < length; i++) {
- var type = chkCategorys[i].getAttribute("data-type");
- chkCategorys[i].checked = !selectedCategories.length || -1 !== selectedCategories.indexOf(type)
+
+ var selectedCategories = options.categories || [];
+
+ var chkCategorys = context.querySelectorAll('.chkCategory');
+ for (var i = 0, length = chkCategorys.length; i < length; i++) {
+
+ var type = chkCategorys[i].getAttribute('data-type');
+
+ chkCategorys[i].checked = !selectedCategories.length || selectedCategories.indexOf(type) !== -1;
}
}
function save(context) {
- var i, length, chkIndicators = context.querySelectorAll(".chkIndicator");
+
+ var i, length;
+
+ var chkIndicators = context.querySelectorAll('.chkIndicator');
for (i = 0, length = chkIndicators.length; i < length; i++) {
- var type = chkIndicators[i].getAttribute("data-type");
- userSettings.set("guide-indicator-" + type, chkIndicators[i].checked)
+
+ var type = chkIndicators[i].getAttribute('data-type');
+ userSettings.set('guide-indicator-' + type, chkIndicators[i].checked);
}
- userSettings.set("guide-colorcodedbackgrounds", context.querySelector(".chkColorCodedBackgrounds").checked), userSettings.set("livetv-favoritechannelsattop", context.querySelector(".chkFavoriteChannelsAtTop").checked);
- var sortBys = context.querySelectorAll(".chkSortOrder");
- for (i = 0, length = sortBys.length; i < length; i++)
+
+ userSettings.set('guide-colorcodedbackgrounds', context.querySelector('.chkColorCodedBackgrounds').checked);
+ userSettings.set('livetv-favoritechannelsattop', context.querySelector('.chkFavoriteChannelsAtTop').checked);
+
+ var sortBys = context.querySelectorAll('.chkSortOrder');
+ for (i = 0, length = sortBys.length; i < length; i++) {
if (sortBys[i].checked) {
- userSettings.set("livetv-channelorder", sortBys[i].value);
- break
+ userSettings.set('livetv-channelorder', sortBys[i].value);
+ break;
}
+ }
}
function load(context) {
- var i, length, chkIndicators = context.querySelectorAll(".chkIndicator");
+
+ var i, length;
+
+ var chkIndicators = context.querySelectorAll('.chkIndicator');
for (i = 0, length = chkIndicators.length; i < length; i++) {
- var type = chkIndicators[i].getAttribute("data-type");
- "true" === chkIndicators[i].getAttribute("data-default") ? chkIndicators[i].checked = "false" !== userSettings.get("guide-indicator-" + type) : chkIndicators[i].checked = "true" === userSettings.get("guide-indicator-" + type)
+
+ var type = chkIndicators[i].getAttribute('data-type');
+
+ if (chkIndicators[i].getAttribute('data-default') === 'true') {
+ chkIndicators[i].checked = userSettings.get('guide-indicator-' + type) !== 'false';
+ } else {
+ chkIndicators[i].checked = userSettings.get('guide-indicator-' + type) === 'true';
+ }
+ }
+
+ context.querySelector('.chkColorCodedBackgrounds').checked = userSettings.get('guide-colorcodedbackgrounds') === 'true';
+ context.querySelector('.chkFavoriteChannelsAtTop').checked = userSettings.get('livetv-favoritechannelsattop') !== 'false';
+
+ var sortByValue = userSettings.get('livetv-channelorder') || 'Number';
+
+ var sortBys = context.querySelectorAll('.chkSortOrder');
+ for (i = 0, length = sortBys.length; i < length; i++) {
+ sortBys[i].checked = sortBys[i].value === sortByValue;
+ }
+ }
+
+ function onSortByChange() {
+ var newValue = this.value;
+ if (this.checked) {
+ var changed = options.query.SortBy !== newValue;
+
+ options.query.SortBy = newValue.replace('_', ',');
+ options.query.StartIndex = 0;
+
+ if (options.callback && changed) {
+ options.callback();
+ }
}
- context.querySelector(".chkColorCodedBackgrounds").checked = "true" === userSettings.get("guide-colorcodedbackgrounds"), context.querySelector(".chkFavoriteChannelsAtTop").checked = "false" !== userSettings.get("livetv-favoritechannelsattop");
- var sortByValue = userSettings.get("livetv-channelorder") || "Number",
- sortBys = context.querySelectorAll(".chkSortOrder");
- for (i = 0, length = sortBys.length; i < length; i++) sortBys[i].checked = sortBys[i].value === sortByValue
}
function showEditor(options) {
- return new Promise(function(resolve, reject) {
- var settingsChanged = !1;
- require(["text!./guide-settings.template.html"], function(template) {
+
+ return new Promise(function (resolve, reject) {
+
+ var settingsChanged = false;
+
+ require(['text!./guide-settings.template.html'], function (template) {
+
var dialogOptions = {
- removeOnClose: !0,
- scrollY: !1
+ removeOnClose: true,
+ scrollY: false
};
- layoutManager.tv ? dialogOptions.size = "fullscreen" : dialogOptions.size = "small";
+
+ if (layoutManager.tv) {
+ dialogOptions.size = 'fullscreen';
+ } else {
+ dialogOptions.size = 'small';
+ }
+
var dlg = dialogHelper.createDialog(dialogOptions);
- dlg.classList.add("formDialog");
- var html = "";
- html += globalize.translateDocument(template, "sharedcomponents"), dlg.innerHTML = html, dlg.addEventListener("change", function() {
- settingsChanged = !0
- }), dlg.addEventListener("close", function() {
- layoutManager.tv && scrollHelper.centerFocus.off(dlg.querySelector(".formDialogContent"), !1), save(dlg), saveCategories(dlg, options), settingsChanged ? resolve() : reject()
- }), dlg.querySelector(".btnCancel").addEventListener("click", function() {
- dialogHelper.close(dlg)
- }), layoutManager.tv && scrollHelper.centerFocus.on(dlg.querySelector(".formDialogContent"), !1), load(dlg), loadCategories(dlg, options), dialogHelper.open(dlg)
- })
- })
+
+ dlg.classList.add('formDialog');
+
+ var html = '';
+
+ html += globalize.translateDocument(template, 'sharedcomponents');
+
+ dlg.innerHTML = html;
+
+ dlg.addEventListener('change', function () {
+
+ settingsChanged = true;
+ });
+
+ dlg.addEventListener('close', function () {
+
+ if (layoutManager.tv) {
+ scrollHelper.centerFocus.off(dlg.querySelector('.formDialogContent'), false);
+ }
+
+ save(dlg);
+ saveCategories(dlg, options);
+
+ if (settingsChanged) {
+ resolve();
+ } else {
+ reject();
+ }
+ });
+
+ dlg.querySelector('.btnCancel').addEventListener('click', function () {
+ dialogHelper.close(dlg);
+ });
+
+ if (layoutManager.tv) {
+ scrollHelper.centerFocus.on(dlg.querySelector('.formDialogContent'), false);
+ }
+
+ load(dlg);
+ loadCategories(dlg, options);
+ dialogHelper.open(dlg);
+ });
+ });
}
+
return {
show: showEditor
- }
+ };
});
\ No newline at end of file
diff --git a/src/bower_components/emby-webcomponents/guide/guide.css b/src/bower_components/emby-webcomponents/guide/guide.css
index fa1d4f0204..fcac17f272 100644
--- a/src/bower_components/emby-webcomponents/guide/guide.css
+++ b/src/bower_components/emby-webcomponents/guide/guide.css
@@ -1,194 +1,141 @@
-.tvGuideHeader,
-.tvguide {
- display: -webkit-box;
- display: -webkit-flex
-}
-
-.channelPrograms,
-.programContainer,
-.timeslotHeadersInner,
-.tvProgram {
- position: relative
-}
-
-.channelPrograms,
-.channelsContainer,
-.tvGuideHeader,
-.tvguide {
- -webkit-box-orient: vertical;
- -webkit-box-direction: normal
-}
-
-.guideChannelName,
-.guideChannelNumber,
-.guideProgramName,
-.guideProgramNameText {
- -o-text-overflow: ellipsis
-}
-
.tvguide {
display: flex;
- -webkit-flex-direction: column;
flex-direction: column;
- -webkit-box-align: initial;
- -webkit-align-items: initial;
- align-items: initial
+ align-items: initial;
}
.tvGuideHeader {
white-space: nowrap;
width: 100%;
- -webkit-flex-direction: column;
flex-direction: column;
- -webkit-flex-shrink: 0;
flex-shrink: 0;
display: flex;
- contain: layout style paint
+ contain: layout style paint;
}
.layout-desktop .tvGuideHeader {
- margin-bottom: .5em
+ margin-bottom: .5em;
}
.guideHeaderDateSelection {
font-size: 86%;
- padding: .4em 0
+ padding: .4em 0;
}
.guide-headerTimeslots {
- display: -webkit-box;
- display: -webkit-flex;
- display: flex
+ display: flex;
}
.tvProgramSectionHeader {
- margin: 0
+ margin: 0;
}
.tvProgram {
display: block;
text-decoration: none;
- white-space: nowrap
+ white-space: nowrap;
+ position: relative;
}
.guideProgramIndicator {
text-transform: uppercase;
- -webkit-border-radius: .25em;
border-radius: .25em;
margin-right: .5em;
font-size: 82%;
padding: .2em .25em;
- display: -webkit-inline-box;
- display: -webkit-inline-flex;
display: inline-flex;
- -webkit-box-align: center;
- -webkit-align-items: center;
align-items: center;
- -webkit-box-pack: center;
- -webkit-justify-content: center;
justify-content: center;
text-align: center;
- margin-left: 1em
+ margin-left: 1em;
}
.guide-channelTimeslotHeader {
- -webkit-box-pack: center;
- -webkit-justify-content: center;
- justify-content: center
+ flex-shrink: 0;
+ justify-content: center;
}
.timeslotHeaders {
white-space: nowrap;
font-weight: 500;
- font-size: 120%
+ font-size: 120%;
}
.programContainer {
white-space: nowrap;
- -webkit-box-align: start;
- -webkit-align-items: flex-start;
+ position: relative;
align-items: flex-start;
- contain: strict
+ contain: strict;
+}
+
+.channelPrograms {
+ white-space: nowrap;
+ position: relative;
+ contain: strict;
+ box-sizing: border-box;
+}
+
+.timeslotHeadersInner {
+ position: relative;
}
.guideSpacer {
width: .3em;
- -webkit-flex-shrink: 0;
- flex-shrink: 0
+ flex-shrink: 0;
}
-.channelPrograms,
-.timeslotHeadersInner {
- width: 1800vw
+.channelPrograms, .timeslotHeadersInner {
+ width: 1800vw;
}
-@media all and (min-width:37.5em) {
+@media all and (min-width: 37.5em) {
- .channelPrograms,
- .timeslotHeadersInner {
- width: 1400vw
+ .channelPrograms, .timeslotHeadersInner {
+ width: 1400vw;
}
}
-@media all and (min-width:50em) {
+@media all and (min-width: 50em) {
- .channelPrograms,
- .timeslotHeadersInner {
- width: 1200vw
+ .channelPrograms, .timeslotHeadersInner {
+ width: 1200vw;
}
}
-@media all and (min-width:80em) {
+@media all and (min-width: 80em) {
- .channelPrograms,
- .timeslotHeadersInner {
- width: 810vw
+ .channelPrograms, .timeslotHeadersInner {
+ width: 810vw;
}
}
.timeslotHeader {
- display: -webkit-inline-box;
- display: -webkit-inline-flex;
display: inline-flex;
- -webkit-box-align: center;
- -webkit-align-items: center;
align-items: center;
text-indent: .25em;
- width: 2.0833333333333333333333333333333%
+ width: 2.0833333333333333333333333333333%;
}
-.guide-channelHeaderCell,
-.guide-channelTimeslotHeader,
-.programCell {
- color: inherit;
+.guide-channelHeaderCell, .guide-channelTimeslotHeader {
+ padding: 0 !important;
cursor: pointer;
+ outline: none !important;
+ width: 100%;
vertical-align: middle;
font-family: inherit;
- text-decoration: none;
- -webkit-box-align: center;
- text-align: left;
- overflow: hidden
-}
-
-.guide-channelHeaderCell,
-.guide-channelTimeslotHeader {
- padding: 0 !important;
- outline: 0 !important;
- width: 100%;
font-size: inherit;
- -o-text-overflow: ellipsis;
+ overflow: hidden;
text-overflow: ellipsis;
margin: 0 1px 0 0;
- display: -webkit-box;
- display: -webkit-flex;
display: flex;
- -webkit-align-items: center;
align-items: center;
+ text-decoration: none;
+ /* Needed in firefox */
+ text-align: left;
contain: strict;
- -webkit-flex-shrink: 0;
flex-shrink: 0;
- -webkit-border-radius: .12em;
- border-radius: .12em
+ border-radius: .12em;
+ color: inherit;
}
.guide-channelHeaderCell {
@@ -198,187 +145,151 @@
height: 4.42em;
contain: strict;
position: relative;
- background: 0 0
+ background: transparent;
}
.guide-channelTimeslotHeader {
border: 0 !important;
- border-right-color: transparent
}
-.channelsContainer,
-.guide-channelTimeslotHeader {
- width: 24vw
+/* Important - have to put the fixed width on channelsContainer, not the individual channelHeaderCell
+ This was causing channelsContainer to extend beyond the fixed width on ps4, tizen, lg and opera tv.
+*/
+.channelsContainer, .guide-channelTimeslotHeader {
+ width: 24vw;
}
@media all and (min-width:31.25em) {
-
- .channelsContainer,
- .guide-channelTimeslotHeader {
- width: 16vw
+ .channelsContainer, .guide-channelTimeslotHeader {
+ width: 16vw;
}
}
@media all and (min-width:37.5em) {
-
- .channelsContainer,
- .guide-channelTimeslotHeader {
- width: 16vw
+ .channelsContainer, .guide-channelTimeslotHeader {
+ width: 16vw;
}
}
@media all and (min-width:50em) {
-
- .channelsContainer,
- .guide-channelTimeslotHeader {
- width: 14vw
+ .channelsContainer, .guide-channelTimeslotHeader {
+ width: 14vw;
}
}
@media all and (min-width:80em) {
-
- .channelsContainer,
- .guide-channelTimeslotHeader {
- width: 12vw
+ .channelsContainer, .guide-channelTimeslotHeader {
+ width: 12vw;
}
}
.btnGuideViewSettings {
margin: 0;
- -webkit-flex-shrink: 0;
- flex-shrink: 0
+ flex-shrink: 0;
}
.btnGuideViewSettingsIcon {
- font-size: 1.5em !important
+ font-size: 1.5em !important;
}
.selectDateIcon {
- -webkit-flex-shrink: 0;
- flex-shrink: 0
+ flex-shrink: 0;
}
-@media all and (max-width:50em) {
+@media all and (max-width: 50em) {
- .guideHdIcon,
- .liveTvProgram,
- .newTvProgram,
- .premiereTvProgram {
- display: none
+ .newTvProgram, .liveTvProgram, .premiereTvProgram, .guideHdIcon {
+ display: none;
}
}
-.channelPrograms,
-.programCell {
- border-style: solid;
- display: -webkit-box;
- display: -webkit-flex;
- contain: strict
-}
-
.channelPrograms {
- white-space: nowrap;
- -webkit-box-sizing: border-box;
- box-sizing: border-box;
height: 4.42em;
+ contain: strict;
display: flex;
- -webkit-flex-direction: column;
flex-direction: column;
- border-width: 1px 0
+ border-style: solid;
+ border-width: 1px 0 1px 0;
}
-.channelPrograms+.channelPrograms,
-.guide-channelHeaderCell+.guide-channelHeaderCell {
- margin-top: -1px
+ .channelPrograms + .channelPrograms, .guide-channelHeaderCell + .guide-channelHeaderCell {
+ margin-top: -1px;
+ }
+
+.channelPrograms-tv, .guide-channelHeaderCell-tv {
+ height: 3em;
}
-.channelPrograms-tv,
-.guide-channelHeaderCell-tv {
- height: 3em
+.guide-channelTimeslotHeader {
+ border-right-color: transparent;
}
-.guide-channelTimeslotHeader,
-.timeslotHeader {
- background: 0 0 !important;
- height: 2.8em
+.guide-channelTimeslotHeader, .timeslotHeader {
+ background: transparent !important;
+ height: 2.8em;
}
.programGrid {
padding-bottom: 4px;
- -webkit-box-flex: 1;
- -webkit-flex-grow: 1;
- flex-grow: 1
+ flex-grow: 1;
}
.programCell {
- background: 0 0;
+ color: inherit;
+ background: transparent;
+ border-style: solid;
border-width: 0 0 0 1px;
padding: 0 !important;
+ cursor: pointer;
+ outline: none !important;
width: 100%;
+ vertical-align: middle;
+ font-family: inherit;
font-size: inherit;
position: absolute;
top: 0;
bottom: 0;
display: flex;
- -webkit-align-items: center;
+ text-decoration: none;
+ overflow: hidden;
align-items: center;
- -webkit-box-flex: 1;
- -webkit-flex-grow: 1;
+ /* Needed for Firefox */
+ text-align: left;
+ contain: strict;
flex-grow: 1;
- margin: 0 !important
-}
-
-.channelsContainer,
-.guideProgramName,
-.programGrid {
- contain: layout style paint
-}
-
-.guide-programNameCaret,
-.guideProgramName {
- display: -webkit-box;
- display: -webkit-flex;
- -webkit-box-align: center
+ margin: 0 !important;
}
.guideProgramName {
- padding: 0 .7em;
+ padding: 0 .7em 0;
overflow: hidden;
text-overflow: ellipsis;
- -webkit-align-items: center;
align-items: center;
display: flex;
position: relative;
- -webkit-box-flex: 1;
- -webkit-flex-grow: 1;
- flex-grow: 1
+ flex-grow: 1;
+ contain: layout style paint;
+ /*transition: transform 60ms ease-out;*/
}
.guide-programNameCaret {
display: flex;
- -webkit-align-items: center;
align-items: center;
- -webkit-box-pack: center;
- -webkit-justify-content: center;
justify-content: center;
- font-size: 200%
+ font-size: 200%;
}
.guideProgramNameText {
margin: 0;
- font-weight: 400;
+ font-weight: normal;
overflow: hidden;
- text-overflow: ellipsis
+ text-overflow: ellipsis;
}
.guideProgramSecondaryInfo {
- display: -webkit-box;
- display: -webkit-flex;
display: flex;
- -webkit-box-align: center;
- -webkit-align-items: center;
align-items: center;
- margin-top: .1em
+ margin-top: .1em;
}
.programIcon {
@@ -387,26 +298,22 @@
width: 1em;
font-size: 1.6em;
color: #ddd;
- -webkit-flex-shrink: 0;
flex-shrink: 0;
- -webkit-box-flex: 0;
- -webkit-flex-grow: 0;
- flex-grow: 0
+ flex-grow: 0;
}
.guide-programTextIcon {
- font-weight: 700;
+ font-weight: bold;
font-size: .9em;
padding: .16em .3em;
- -webkit-border-radius: .25em;
border-radius: .25em;
margin-right: .35em;
width: auto;
- height: auto
+ height: auto;
}
.guide-programTextIcon-tv {
- font-size: .74em
+ font-size: .74em;
}
.guideChannelNumber {
@@ -414,8 +321,8 @@
max-width: 30%;
text-overflow: ellipsis;
overflow: hidden;
- font-weight: 400;
- margin: 0
+ font-weight: normal;
+ margin: 0;
}
.guideChannelName {
@@ -423,7 +330,7 @@
margin-right: 1em;
text-overflow: ellipsis;
overflow: hidden;
- max-width: 70%
+ max-width: 70%;
}
.guideChannelImage {
@@ -432,68 +339,62 @@
top: 15%;
bottom: 15%;
width: 40%;
- -webkit-background-size: contain;
background-size: contain;
background-repeat: no-repeat;
- background-position: right center
+ background-position: right center;
}
-@media all and (min-width:62.5em) {
+@media all and (min-width: 62.5em) {
+
.guideChannelName {
- max-width: 40%
+ max-width: 40%;
}
}
-@media all and (max-width:62.5em) {
+@media all and (max-width: 62.5em) {
+
.guideChannelNumber {
- display: none
+ display: none;
}
.guideChannelImage {
- width: 70%
+ width: 70%;
}
}
.channelsContainer {
- display: -webkit-box;
- display: -webkit-flex;
display: flex;
- -webkit-flex-shrink: 0;
flex-shrink: 0;
- -webkit-flex-direction: column;
- flex-direction: column
+ flex-direction: column;
}
-.guide-channelHeaderCell,
-.programCell {
- outline: 0 !important
+.channelsContainer, .programGrid {
+ contain: layout style paint;
}
-.seriesTimerIcon,
-.timerIcon {
- color: #c33 !important
+.programCell, .guide-channelHeaderCell {
+ outline: none !important;
+}
+
+.timerIcon, .seriesTimerIcon {
+ color: #cc3333 !important;
}
.seriesTimerIcon-inactive {
color: inherit !important;
- opacity: .7
+ opacity: .7;
}
.guideOptions {
- -webkit-flex-shrink: 0;
flex-shrink: 0;
- display: -webkit-box;
- display: -webkit-flex;
display: flex;
- -webkit-box-align: center;
- -webkit-align-items: center;
- align-items: center
+ align-items: center;
}
-@media all and (max-width:50em),
-all and (max-height:37.5em) {
+@media all and (max-width: 50em), all and (max-height: 37.5em) {
+
.tvGuideHeader {
- padding-left: 0
+ padding-left: 0;
}
}
@@ -501,31 +402,29 @@ all and (max-height:37.5em) {
margin: 1em auto;
text-align: center;
padding: 1em;
- -webkit-flex-shrink: 0;
- flex-shrink: 0
+ flex-shrink: 0;
}
.noRubberBanding {
- padding-bottom: 7em
+ /* This is needed to combat the rubber banding in iOS */
+ padding-bottom: 7em;
}
.guideDateTabsSlider {
- text-align: center
+ text-align: center;
}
.guide-date-tab-button {
padding: .3em .7em !important;
margin: 0 .3em !important;
- font-weight: 400
+ font-weight: normal;
}
-.guide-date-tab-button.emby-tab-button-active {
- border-color: transparent !important
-}
+ .guide-date-tab-button.emby-tab-button-active {
+ border-color: transparent !important;
+ }
-.guide-date-tab-button.emby-button-tv:focus {
- -webkit-border-radius: .15em !important;
- border-radius: .15em !important;
- -webkit-transform: none !important;
- transform: none !important
-}
\ No newline at end of file
+ .guide-date-tab-button.emby-button-tv:focus {
+ border-radius: .15em !important;
+ transform: none !important;
+ }
diff --git a/src/bower_components/emby-webcomponents/guide/guide.js b/src/bower_components/emby-webcomponents/guide/guide.js
index 87fcaf8218..0924339ff2 100644
--- a/src/bower_components/emby-webcomponents/guide/guide.js
+++ b/src/bower_components/emby-webcomponents/guide/guide.js
@@ -1,517 +1,1290 @@
-define(["require", "inputManager", "browser", "globalize", "connectionManager", "scrollHelper", "serverNotifications", "loading", "datetime", "focusManager", "playbackManager", "userSettings", "imageLoader", "events", "layoutManager", "itemShortcuts", "dom", "css!./guide.css", "programStyles", "material-icons", "scrollStyles", "emby-button", "paper-icon-button-light", "emby-tabs", "emby-scroller", "flexStyles", "registerElement"], function(require, inputManager, browser, globalize, connectionManager, scrollHelper, serverNotifications, loading, datetime, focusManager, playbackManager, userSettings, imageLoader, events, layoutManager, itemShortcuts, dom) {
- "use strict";
+define(['require', 'inputManager', 'browser', 'globalize', 'connectionManager', 'scrollHelper', 'serverNotifications', 'loading', 'datetime', 'focusManager', 'playbackManager', 'userSettings', 'imageLoader', 'events', 'layoutManager', 'itemShortcuts', 'dom', 'css!./guide.css', 'programStyles', 'material-icons', 'scrollStyles', 'emby-button', 'paper-icon-button-light', 'emby-tabs', 'emby-scroller', 'flexStyles', 'registerElement'], function (require, inputManager, browser, globalize, connectionManager, scrollHelper, serverNotifications, loading, datetime, focusManager, playbackManager, userSettings, imageLoader, events, layoutManager, itemShortcuts, dom) {
+ 'use strict';
function showViewSettings(instance) {
- require(["guide-settings-dialog"], function(guideSettingsDialog) {
- guideSettingsDialog.show(instance.categoryOptions).then(function() {
- instance.refresh()
- })
- })
+
+ require(['guide-settings-dialog'], function (guideSettingsDialog) {
+ guideSettingsDialog.show(instance.categoryOptions).then(function () {
+ instance.refresh();
+ });
+ });
}
function updateProgramCellOnScroll(cell, scrollPct) {
+
var left = cell.posLeft;
- left || (left = parseFloat(cell.style.left.replace("%", "")), cell.posLeft = left);
+ if (!left) {
+ left = parseFloat(cell.style.left.replace('%', ''));
+ cell.posLeft = left;
+ }
var width = cell.posWidth;
- width || (width = parseFloat(cell.style.width.replace("%", "")), cell.posWidth = width);
- var right = left + width,
- newPct = Math.max(Math.min(scrollPct, right), left),
- offset = newPct - left,
- pctOfWidth = offset / width * 100,
- guideProgramName = cell.guideProgramName;
- guideProgramName || (guideProgramName = cell.querySelector(".guideProgramName"), cell.guideProgramName = guideProgramName);
+ if (!width) {
+ width = parseFloat(cell.style.width.replace('%', ''));
+ cell.posWidth = width;
+ }
+
+ var right = left + width;
+ var newPct = Math.max(Math.min(scrollPct, right), left);
+
+ var offset = newPct - left;
+ var pctOfWidth = (offset / width) * 100;
+
+ //console.log(pctOfWidth);
+ var guideProgramName = cell.guideProgramName;
+ if (!guideProgramName) {
+ guideProgramName = cell.querySelector('.guideProgramName');
+ cell.guideProgramName = guideProgramName;
+ }
+
var caret = cell.caret;
- caret || (caret = cell.querySelector(".guide-programNameCaret"), cell.caret = caret), guideProgramName && (pctOfWidth > 0 && pctOfWidth <= 100 ? (guideProgramName.style.transform = "translateX(" + pctOfWidth + "%)", caret.classList.remove("hide")) : (guideProgramName.style.transform = "none", caret.classList.add("hide")))
+ if (!caret) {
+ caret = cell.querySelector('.guide-programNameCaret');
+ cell.caret = caret;
+ }
+
+ if (guideProgramName) {
+ if (pctOfWidth > 0 && pctOfWidth <= 100) {
+ //guideProgramName.style.marginLeft = pctOfWidth + '%';
+ guideProgramName.style.transform = 'translateX(' + pctOfWidth + '%)';
+ caret.classList.remove('hide');
+ } else {
+ //guideProgramName.style.marginLeft = '0';
+ guideProgramName.style.transform = 'none';
+ caret.classList.add('hide');
+ }
+ }
}
+ var isUpdatingProgramCellScroll = false;
function updateProgramCellsOnScroll(programGrid, programCells) {
- isUpdatingProgramCellScroll || (isUpdatingProgramCellScroll = !0, requestAnimationFrame(function() {
- for (var scrollLeft = programGrid.scrollLeft, scrollPct = scrollLeft ? scrollLeft / programGrid.scrollWidth * 100 : 0, i = 0, length = programCells.length; i < length; i++) updateProgramCellOnScroll(programCells[i], scrollPct);
- isUpdatingProgramCellScroll = !1
- }))
+
+ if (isUpdatingProgramCellScroll) {
+ return;
+ }
+
+ isUpdatingProgramCellScroll = true;
+
+ requestAnimationFrame(function () {
+
+ var scrollLeft = programGrid.scrollLeft;
+
+ var scrollPct = scrollLeft ? (scrollLeft / programGrid.scrollWidth) * 100 : 0;
+
+ for (var i = 0, length = programCells.length; i < length; i++) {
+
+ updateProgramCellOnScroll(programCells[i], scrollPct);
+ }
+
+ isUpdatingProgramCellScroll = false;
+ });
}
function onProgramGridClick(e) {
- if (layoutManager.tv) {
- var programCell = dom.parentWithClass(e.target, "programCell");
- if (programCell) {
- var startDate = programCell.getAttribute("data-startdate"),
- endDate = programCell.getAttribute("data-enddate");
- startDate = datetime.parseISO8601Date(startDate, {
- toLocal: !0
- }).getTime(), endDate = datetime.parseISO8601Date(endDate, {
- toLocal: !0
- }).getTime();
- var now = (new Date).getTime();
- if (now >= startDate && now < endDate) {
- var channelId = programCell.getAttribute("data-channelid"),
- serverId = programCell.getAttribute("data-serverid");
- e.preventDefault(), e.stopPropagation(), playbackManager.play({
- ids: [channelId],
- serverId: serverId
- })
- }
+
+ if (!layoutManager.tv) {
+ return;
+ }
+
+ var programCell = dom.parentWithClass(e.target, 'programCell');
+ if (programCell) {
+
+ var startDate = programCell.getAttribute('data-startdate');
+ var endDate = programCell.getAttribute('data-enddate');
+ startDate = datetime.parseISO8601Date(startDate, { toLocal: true }).getTime();
+ endDate = datetime.parseISO8601Date(endDate, { toLocal: true }).getTime();
+
+ var now = new Date().getTime();
+ if (now >= startDate && now < endDate) {
+
+ var channelId = programCell.getAttribute('data-channelid');
+ var serverId = programCell.getAttribute('data-serverid');
+
+ e.preventDefault();
+ e.stopPropagation();
+
+ playbackManager.play({
+ ids: [channelId],
+ serverId: serverId
+ });
}
}
}
function Guide(options) {
- function restartAutoRefresh() {
+
+ var self = this;
+ var items = {};
+
+ self.options = options;
+ self.categoryOptions = { categories: [] };
+
+ // 30 mins
+ var cellCurationMinutes = 30;
+ var cellDurationMs = cellCurationMinutes * 60 * 1000;
+ var msPerDay = 86400000;
+ var totalRendererdMs = msPerDay;
+
+ var currentDate;
+ var currentStartIndex = 0;
+ var currentChannelLimit = 0;
+ var autoRefreshInterval;
+ var programCells;
+ var lastFocusDirection;
+ var programGrid;
+
+ self.refresh = function () {
+
+ currentDate = null;
+ reloadPage(options.element);
+ restartAutoRefresh();
+ };
+
+ self.pause = function () {
stopAutoRefresh();
- autoRefreshInterval = setInterval(function() {
- self.refresh()
- }, 9e5)
+ };
+
+ self.resume = function (refreshData) {
+ if (refreshData) {
+ self.refresh();
+ } else {
+ restartAutoRefresh();
+ }
+ };
+
+ self.destroy = function () {
+
+ stopAutoRefresh();
+
+ events.off(serverNotifications, 'TimerCreated', onTimerCreated);
+ events.off(serverNotifications, 'SeriesTimerCreated', onSeriesTimerCreated);
+ events.off(serverNotifications, 'TimerCancelled', onTimerCancelled);
+ events.off(serverNotifications, 'SeriesTimerCancelled', onSeriesTimerCancelled);
+
+ setScrollEvents(options.element, false);
+ itemShortcuts.off(options.element);
+ items = {};
+ };
+
+ function restartAutoRefresh() {
+
+ stopAutoRefresh();
+
+ var intervalMs = 60000 * 15; // (minutes)
+
+ autoRefreshInterval = setInterval(function () {
+ self.refresh();
+ }, intervalMs);
}
function stopAutoRefresh() {
- autoRefreshInterval && (clearInterval(autoRefreshInterval), autoRefreshInterval = null)
+ if (autoRefreshInterval) {
+ clearInterval(autoRefreshInterval);
+ autoRefreshInterval = null;
+ }
}
function normalizeDateToTimeslot(date) {
- return date.getMinutes() - cellCurationMinutes >= 0 ? date.setHours(date.getHours(), cellCurationMinutes, 0, 0) : date.setHours(date.getHours(), 0, 0, 0), date
+
+ var minutesOffset = date.getMinutes() - cellCurationMinutes;
+
+ if (minutesOffset >= 0) {
+
+ date.setHours(date.getHours(), cellCurationMinutes, 0, 0);
+
+ } else {
+
+ date.setHours(date.getHours(), 0, 0, 0);
+ }
+
+ return date;
}
function showLoading() {
- loading.show()
+ loading.show();
}
function hideLoading() {
- loading.hide()
+ loading.hide();
}
function reloadGuide(context, newStartDate, scrollToTimeMs, focusToTimeMs, startTimeOfDayMs, focusProgramOnRender) {
- var apiClient = connectionManager.getApiClient(options.serverId),
- channelQuery = {
- StartIndex: 0,
- EnableFavoriteSorting: "false" !== userSettings.get("livetv-favoritechannelsattop")
- };
+
+ var apiClient = connectionManager.getApiClient(options.serverId);
+
+ var channelQuery = {
+
+ StartIndex: 0,
+ EnableFavoriteSorting: userSettings.get('livetv-favoritechannelsattop') !== 'false'
+ };
+
channelQuery.UserId = apiClient.getCurrentUserId();
- currentChannelLimit = 500, showLoading(), channelQuery.StartIndex = currentStartIndex, channelQuery.Limit = 500, channelQuery.AddCurrentProgram = !1, channelQuery.EnableUserData = !1, channelQuery.EnableImageTypes = "Primary";
- var categories = self.categoryOptions.categories || [],
- displayMovieContent = !categories.length || -1 !== categories.indexOf("movies"),
- displaySportsContent = !categories.length || -1 !== categories.indexOf("sports"),
- displayNewsContent = !categories.length || -1 !== categories.indexOf("news"),
- displayKidsContent = !categories.length || -1 !== categories.indexOf("kids"),
- displaySeriesContent = !categories.length || -1 !== categories.indexOf("series");
- displayMovieContent && displaySportsContent && displayNewsContent && displayKidsContent ? (channelQuery.IsMovie = null, channelQuery.IsSports = null, channelQuery.IsKids = null, channelQuery.IsNews = null, channelQuery.IsSeries = null) : (displayNewsContent && (channelQuery.IsNews = !0), displaySportsContent && (channelQuery.IsSports = !0), displayKidsContent && (channelQuery.IsKids = !0), displayMovieContent && (channelQuery.IsMovie = !0), displaySeriesContent && (channelQuery.IsSeries = !0)), "DatePlayed" === userSettings.get("livetv-channelorder") ? (channelQuery.SortBy = "DatePlayed", channelQuery.SortOrder = "Descending") : (channelQuery.SortBy = null, channelQuery.SortOrder = null);
+
+ var channelLimit = 500;
+ currentChannelLimit = channelLimit;
+
+ showLoading();
+
+ channelQuery.StartIndex = currentStartIndex;
+ channelQuery.Limit = channelLimit;
+ channelQuery.AddCurrentProgram = false;
+ channelQuery.EnableUserData = false;
+ channelQuery.EnableImageTypes = "Primary";
+
+ var categories = self.categoryOptions.categories || [];
+ var displayMovieContent = !categories.length || categories.indexOf('movies') !== -1;
+ var displaySportsContent = !categories.length || categories.indexOf('sports') !== -1;
+ var displayNewsContent = !categories.length || categories.indexOf('news') !== -1;
+ var displayKidsContent = !categories.length || categories.indexOf('kids') !== -1;
+ var displaySeriesContent = !categories.length || categories.indexOf('series') !== -1;
+
+ if (displayMovieContent && displaySportsContent && displayNewsContent && displayKidsContent) {
+ channelQuery.IsMovie = null;
+ channelQuery.IsSports = null;
+ channelQuery.IsKids = null;
+ channelQuery.IsNews = null;
+ channelQuery.IsSeries = null;
+ } else {
+ if (displayNewsContent) {
+ channelQuery.IsNews = true;
+ }
+ if (displaySportsContent) {
+ channelQuery.IsSports = true;
+ }
+ if (displayKidsContent) {
+ channelQuery.IsKids = true;
+ }
+ if (displayMovieContent) {
+ channelQuery.IsMovie = true;
+ }
+ if (displaySeriesContent) {
+ channelQuery.IsSeries = true;
+ }
+ }
+
+ if (userSettings.get('livetv-channelorder') === 'DatePlayed') {
+ channelQuery.SortBy = "DatePlayed";
+ channelQuery.SortOrder = "Descending";
+ } else {
+ channelQuery.SortBy = null;
+ channelQuery.SortOrder = null;
+ }
+
var date = newStartDate;
- date = new Date(date.getTime() + 1e3);
- var nextDay = new Date(date.getTime() + msPerDay - 2e3),
- allowIndicators = dom.getWindowSize().innerWidth >= 600,
- renderOptions = {
- showHdIcon: allowIndicators && "true" === userSettings.get("guide-indicator-hd"),
- showLiveIndicator: allowIndicators && "false" !== userSettings.get("guide-indicator-live"),
- showPremiereIndicator: allowIndicators && "false" !== userSettings.get("guide-indicator-premiere"),
- showNewIndicator: allowIndicators && "false" !== userSettings.get("guide-indicator-new"),
- showRepeatIndicator: allowIndicators && "true" === userSettings.get("guide-indicator-repeat"),
- showEpisodeTitle: !layoutManager.tv
+ // Add one second to avoid getting programs that are just ending
+ date = new Date(date.getTime() + 1000);
+
+ // Subtract to avoid getting programs that are starting when the grid ends
+ var nextDay = new Date(date.getTime() + msPerDay - 2000);
+
+ // Normally we'd want to just let responsive css handle this,
+ // but since mobile browsers are often underpowered,
+ // it can help performance to get them out of the markup
+ var allowIndicators = dom.getWindowSize().innerWidth >= 600;
+
+ var renderOptions = {
+ showHdIcon: allowIndicators && userSettings.get('guide-indicator-hd') === 'true',
+ showLiveIndicator: allowIndicators && userSettings.get('guide-indicator-live') !== 'false',
+ showPremiereIndicator: allowIndicators && userSettings.get('guide-indicator-premiere') !== 'false',
+ showNewIndicator: allowIndicators && userSettings.get('guide-indicator-new') !== 'false',
+ showRepeatIndicator: allowIndicators && userSettings.get('guide-indicator-repeat') === 'true',
+ showEpisodeTitle: layoutManager.tv ? false : true
+ };
+
+ apiClient.getLiveTvChannels(channelQuery).then(function (channelsResult) {
+
+ var btnPreviousPage = context.querySelector('.btnPreviousPage');
+ var btnNextPage = context.querySelector('.btnNextPage');
+
+ if (channelsResult.TotalRecordCount > channelLimit) {
+
+ context.querySelector('.guideOptions').classList.remove('hide');
+
+ btnPreviousPage.classList.remove('hide');
+ btnNextPage.classList.remove('hide');
+
+ if (channelQuery.StartIndex) {
+ context.querySelector('.btnPreviousPage').disabled = false;
+ } else {
+ context.querySelector('.btnPreviousPage').disabled = true;
+ }
+
+ if ((channelQuery.StartIndex + channelLimit) < channelsResult.TotalRecordCount) {
+ btnNextPage.disabled = false;
+ } else {
+ btnNextPage.disabled = true;
+ }
+
+ } else {
+ context.querySelector('.guideOptions').classList.add('hide');
+ }
+
+ var programFields = [];
+
+ var programQuery = {
+ UserId: apiClient.getCurrentUserId(),
+ MaxStartDate: nextDay.toISOString(),
+ MinEndDate: date.toISOString(),
+ channelIds: channelsResult.Items.map(function (c) {
+ return c.Id;
+ }).join(','),
+ ImageTypeLimit: 1,
+ EnableImages: false,
+ //EnableImageTypes: layoutManager.tv ? "Primary,Backdrop" : "Primary",
+ SortBy: "StartDate",
+ EnableTotalRecordCount: false,
+ EnableUserData: false
};
- apiClient.getLiveTvChannels(channelQuery).then(function(channelsResult) {
- var btnPreviousPage = context.querySelector(".btnPreviousPage"),
- btnNextPage = context.querySelector(".btnNextPage");
- channelsResult.TotalRecordCount > 500 ? (context.querySelector(".guideOptions").classList.remove("hide"), btnPreviousPage.classList.remove("hide"), btnNextPage.classList.remove("hide"), channelQuery.StartIndex ? context.querySelector(".btnPreviousPage").disabled = !1 : context.querySelector(".btnPreviousPage").disabled = !0, channelQuery.StartIndex + 500 < channelsResult.TotalRecordCount ? btnNextPage.disabled = !1 : btnNextPage.disabled = !0) : context.querySelector(".guideOptions").classList.add("hide");
- var programFields = [],
- programQuery = {
- UserId: apiClient.getCurrentUserId(),
- MaxStartDate: nextDay.toISOString(),
- MinEndDate: date.toISOString(),
- channelIds: channelsResult.Items.map(function(c) {
- return c.Id
- }).join(","),
- ImageTypeLimit: 1,
- EnableImages: !1,
- SortBy: "StartDate",
- EnableTotalRecordCount: !1,
- EnableUserData: !1
- };
- renderOptions.showHdIcon && programFields.push("IsHD"), programFields.length && (programQuery.Fields = programFields.join("")), apiClient.getLiveTvPrograms(programQuery).then(function(programsResult) {
- renderGuide(context, date, channelsResult.Items, programsResult.Items, renderOptions, apiClient, scrollToTimeMs, focusToTimeMs, startTimeOfDayMs, focusProgramOnRender), hideLoading()
- })
- })
+
+ if (renderOptions.showHdIcon) {
+ programFields.push('IsHD');
+ }
+
+ if (programFields.length) {
+ programQuery.Fields = programFields.join('');
+ }
+
+ apiClient.getLiveTvPrograms(programQuery).then(function (programsResult) {
+
+ renderGuide(context, date, channelsResult.Items, programsResult.Items, renderOptions, apiClient, scrollToTimeMs, focusToTimeMs, startTimeOfDayMs, focusProgramOnRender);
+
+ hideLoading();
+
+ });
+ });
}
function getDisplayTime(date) {
- if ("string" === (typeof date).toString().toLowerCase()) try {
- date = datetime.parseISO8601Date(date, {
- toLocal: !0
- })
- } catch (err) {
- return date
+
+ if ((typeof date).toString().toLowerCase() === 'string') {
+ try {
+
+ date = datetime.parseISO8601Date(date, { toLocal: true });
+
+ } catch (err) {
+ return date;
+ }
}
- return datetime.getDisplayTime(date).toLowerCase()
+
+ return datetime.getDisplayTime(date).toLowerCase();
}
function getTimeslotHeadersHtml(startDate, endDateTime) {
- var html = "";
- for (startDate = new Date(startDate.getTime()), html += '