Merge remote-tracking branch 'upstream/master' into unavailable-yt-video-trailer-bug-fix
This commit is contained in:
commit
7774a4aa00
313 changed files with 12147 additions and 10106 deletions
|
@ -5,15 +5,15 @@ import browser from 'browser';
|
|||
import 'css!./iconosd';
|
||||
import 'material-icons';
|
||||
|
||||
var currentPlayer;
|
||||
var osdElement;
|
||||
var iconElement;
|
||||
var progressElement;
|
||||
let currentPlayer;
|
||||
let osdElement;
|
||||
let iconElement;
|
||||
let progressElement;
|
||||
|
||||
var enableAnimation;
|
||||
let enableAnimation;
|
||||
|
||||
function getOsdElementHtml() {
|
||||
var html = '';
|
||||
let html = '';
|
||||
|
||||
html += '<span class="material-icons iconOsdIcon brightness_high"></span>';
|
||||
|
||||
|
@ -23,7 +23,7 @@ function getOsdElementHtml() {
|
|||
}
|
||||
|
||||
function ensureOsdElement() {
|
||||
var elem = osdElement;
|
||||
let elem = osdElement;
|
||||
if (!elem) {
|
||||
enableAnimation = browser.supportsCssAnimation();
|
||||
|
||||
|
@ -46,11 +46,11 @@ function onHideComplete() {
|
|||
this.classList.add('hide');
|
||||
}
|
||||
|
||||
var hideTimeout;
|
||||
let hideTimeout;
|
||||
function showOsd() {
|
||||
clearHideTimeout();
|
||||
|
||||
var elem = osdElement;
|
||||
const elem = osdElement;
|
||||
|
||||
dom.removeEventListener(elem, dom.whichTransitionEvent(), onHideComplete, {
|
||||
once: true
|
||||
|
@ -78,7 +78,7 @@ function clearHideTimeout() {
|
|||
function hideOsd() {
|
||||
clearHideTimeout();
|
||||
|
||||
var elem = osdElement;
|
||||
const elem = osdElement;
|
||||
if (elem) {
|
||||
if (enableAnimation) {
|
||||
// trigger reflow
|
||||
|
@ -118,7 +118,7 @@ function updateElementsFromPlayer(brightness) {
|
|||
}
|
||||
|
||||
function releaseCurrentPlayer() {
|
||||
var player = currentPlayer;
|
||||
const player = currentPlayer;
|
||||
|
||||
if (player) {
|
||||
events.off(player, 'brightnesschange', onBrightnessChanged);
|
||||
|
@ -128,7 +128,7 @@ function releaseCurrentPlayer() {
|
|||
}
|
||||
|
||||
function onBrightnessChanged(e) {
|
||||
var player = this;
|
||||
const player = this;
|
||||
|
||||
ensureOsdElement();
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import playbackManager from 'playbackManager';
|
||||
import nowPlayingHelper from 'nowPlayingHelper';
|
||||
import shell from 'shell';
|
||||
import events from 'events';
|
||||
import connectionManager from 'connectionManager';
|
||||
/* eslint-disable indent */
|
||||
|
||||
// Reports media playback to the device for lock screen control
|
||||
|
@ -16,16 +16,16 @@ import connectionManager from 'connectionManager';
|
|||
} else if (options.type === 'Primary' && item.SeriesPrimaryImageTag) {
|
||||
options.tag = item.SeriesPrimaryImageTag;
|
||||
|
||||
return connectionManager.getApiClient(item.ServerId).getScaledImageUrl(item.SeriesId, options);
|
||||
return window.connectionManager.getApiClient(item.ServerId).getScaledImageUrl(item.SeriesId, options);
|
||||
} else if (options.type === 'Thumb') {
|
||||
if (item.SeriesThumbImageTag) {
|
||||
options.tag = item.SeriesThumbImageTag;
|
||||
|
||||
return connectionManager.getApiClient(item.ServerId).getScaledImageUrl(item.SeriesId, options);
|
||||
return window.connectionManager.getApiClient(item.ServerId).getScaledImageUrl(item.SeriesId, options);
|
||||
} else if (item.ParentThumbImageTag) {
|
||||
options.tag = item.ParentThumbImageTag;
|
||||
|
||||
return connectionManager.getApiClient(item.ServerId).getScaledImageUrl(item.ParentThumbItemId, options);
|
||||
return window.connectionManager.getApiClient(item.ServerId).getScaledImageUrl(item.ParentThumbItemId, options);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -38,11 +38,11 @@ import connectionManager from 'connectionManager';
|
|||
if (item.ImageTags && item.ImageTags[options.type]) {
|
||||
options.tag = item.ImageTags[options.type];
|
||||
|
||||
return connectionManager.getApiClient(item.ServerId).getScaledImageUrl(item.Id, options);
|
||||
return window.connectionManager.getApiClient(item.ServerId).getScaledImageUrl(item.Id, options);
|
||||
} else if (item.AlbumId && item.AlbumPrimaryImageTag) {
|
||||
options.tag = item.AlbumPrimaryImageTag;
|
||||
|
||||
return connectionManager.getApiClient(item.ServerId).getScaledImageUrl(item.AlbumId, options);
|
||||
return window.connectionManager.getApiClient(item.ServerId).getScaledImageUrl(item.AlbumId, options);
|
||||
}
|
||||
|
||||
return null;
|
||||
|
@ -128,8 +128,7 @@ import connectionManager from 'connectionManager';
|
|||
});
|
||||
} else {
|
||||
const itemImageUrl = seriesImageUrl(item, { maxHeight: 3000 }) || imageUrl(item, { maxHeight: 3000 });
|
||||
|
||||
window.NativeShell.updateMediaSession({
|
||||
shell.updateMediaSession({
|
||||
action: eventName,
|
||||
isLocalPlayer: isLocalPlayer,
|
||||
itemId: itemId,
|
||||
|
@ -183,7 +182,7 @@ import connectionManager from 'connectionManager';
|
|||
/* eslint-disable-next-line compat/compat */
|
||||
navigator.mediaSession.metadata = null;
|
||||
} else {
|
||||
window.NativeShell.hideMediaSession();
|
||||
shell.hideMediaSession();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
export function getNowPlayingNames(nowPlayingItem, includeNonNameInfo) {
|
||||
var topItem = nowPlayingItem;
|
||||
var bottomItem = null;
|
||||
var topText = nowPlayingItem.Name;
|
||||
let topItem = nowPlayingItem;
|
||||
let bottomItem = null;
|
||||
let topText = nowPlayingItem.Name;
|
||||
|
||||
if (nowPlayingItem.AlbumId && nowPlayingItem.MediaType === 'Audio') {
|
||||
topItem = {
|
||||
|
@ -21,7 +21,7 @@ export function getNowPlayingNames(nowPlayingItem, includeNonNameInfo) {
|
|||
}
|
||||
}
|
||||
|
||||
var bottomText = '';
|
||||
let bottomText = '';
|
||||
|
||||
if (nowPlayingItem.ArtistItems && nowPlayingItem.ArtistItems.length) {
|
||||
bottomItem = {
|
||||
|
@ -56,7 +56,7 @@ export function getNowPlayingNames(nowPlayingItem, includeNonNameInfo) {
|
|||
bottomText = nowPlayingItem.ProductionYear;
|
||||
}
|
||||
|
||||
var list = [];
|
||||
const list = [];
|
||||
|
||||
list.push({
|
||||
text: topText,
|
||||
|
|
|
@ -6,7 +6,6 @@ import pluginManager from 'pluginManager';
|
|||
import PlayQueueManager from 'playQueueManager';
|
||||
import * as userSettings from 'userSettings';
|
||||
import globalize from 'globalize';
|
||||
import connectionManager from 'connectionManager';
|
||||
import loading from 'loading';
|
||||
import appHost from 'apphost';
|
||||
import screenfull from 'screenfull';
|
||||
|
@ -69,7 +68,7 @@ function reportPlayback(playbackManagerInstance, state, player, reportPlaylist,
|
|||
addPlaylistToPlaybackReport(playbackManagerInstance, info, player, serverId);
|
||||
}
|
||||
|
||||
const apiClient = connectionManager.getApiClient(serverId);
|
||||
const apiClient = window.connectionManager.getApiClient(serverId);
|
||||
const reportPlaybackPromise = apiClient[method](info);
|
||||
// Notify that report has been sent
|
||||
reportPlaybackPromise.then(() => {
|
||||
|
@ -106,7 +105,7 @@ function normalizeName(t) {
|
|||
}
|
||||
|
||||
function getItemsForPlayback(serverId, query) {
|
||||
const apiClient = connectionManager.getApiClient(serverId);
|
||||
const apiClient = window.connectionManager.getApiClient(serverId);
|
||||
|
||||
if (query.Ids && query.Ids.split(',').length === 1) {
|
||||
const itemId = query.Ids.split(',');
|
||||
|
@ -640,22 +639,18 @@ function supportsDirectPlay(apiClient, item, mediaSource) {
|
|||
|
||||
function validatePlaybackInfoResult(instance, result) {
|
||||
if (result.ErrorCode) {
|
||||
showPlaybackInfoErrorMessage(instance, result.ErrorCode);
|
||||
showPlaybackInfoErrorMessage(instance, 'PlaybackError' + result.ErrorCode);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function showPlaybackInfoErrorMessage(instance, errorCode, playNextTrack) {
|
||||
function showPlaybackInfoErrorMessage(instance, errorCode) {
|
||||
import('alert').then(({ default: alert }) => {
|
||||
alert({
|
||||
text: globalize.translate('PlaybackError' + errorCode),
|
||||
text: globalize.translate(errorCode),
|
||||
title: globalize.translate('HeaderPlaybackError')
|
||||
}).then(function () {
|
||||
if (playNextTrack) {
|
||||
instance.nextTrack();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -874,7 +869,7 @@ class PlaybackManager {
|
|||
const promises = players.filter(displayPlayerIndividually).map(getPlayerTargets);
|
||||
|
||||
return Promise.all(promises).then(function (responses) {
|
||||
return connectionManager.currentApiClient().getCurrentUser().then(function (user) {
|
||||
return window.connectionManager.currentApiClient().getCurrentUser().then(function (user) {
|
||||
const targets = [];
|
||||
|
||||
targets.push({
|
||||
|
@ -1115,8 +1110,8 @@ class PlaybackManager {
|
|||
self.increasePlaybackRate = function (player) {
|
||||
player = player || self._currentPlayer;
|
||||
if (player) {
|
||||
let current = self.getPlaybackRate(player);
|
||||
let supported = self.getSupportedPlaybackRates(player);
|
||||
const current = self.getPlaybackRate(player);
|
||||
const supported = self.getSupportedPlaybackRates(player);
|
||||
|
||||
let index = -1;
|
||||
for (let i = 0, length = supported.length; i < length; i++) {
|
||||
|
@ -1134,8 +1129,8 @@ class PlaybackManager {
|
|||
self.decreasePlaybackRate = function (player) {
|
||||
player = player || self._currentPlayer;
|
||||
if (player) {
|
||||
let current = self.getPlaybackRate(player);
|
||||
let supported = self.getSupportedPlaybackRates(player);
|
||||
const current = self.getPlaybackRate(player);
|
||||
const supported = self.getSupportedPlaybackRates(player);
|
||||
|
||||
let index = -1;
|
||||
for (let i = 0, length = supported.length; i < length; i++) {
|
||||
|
@ -1372,7 +1367,7 @@ class PlaybackManager {
|
|||
function getSavedMaxStreamingBitrate(apiClient, mediaType) {
|
||||
if (!apiClient) {
|
||||
// This should hopefully never happen
|
||||
apiClient = connectionManager.currentApiClient();
|
||||
apiClient = window.connectionManager.currentApiClient();
|
||||
}
|
||||
|
||||
const endpointInfo = apiClient.getSavedEndpointInfo() || {};
|
||||
|
@ -1395,7 +1390,7 @@ class PlaybackManager {
|
|||
const mediaType = playerData.streamInfo ? playerData.streamInfo.mediaType : null;
|
||||
const currentItem = self.currentItem(player);
|
||||
|
||||
const apiClient = currentItem ? connectionManager.getApiClient(currentItem.ServerId) : connectionManager.currentApiClient();
|
||||
const apiClient = currentItem ? window.connectionManager.getApiClient(currentItem.ServerId) : window.connectionManager.currentApiClient();
|
||||
return getSavedMaxStreamingBitrate(apiClient, mediaType);
|
||||
};
|
||||
|
||||
|
@ -1409,7 +1404,7 @@ class PlaybackManager {
|
|||
const mediaType = playerData.streamInfo ? playerData.streamInfo.mediaType : null;
|
||||
const currentItem = self.currentItem(player);
|
||||
|
||||
const apiClient = currentItem ? connectionManager.getApiClient(currentItem.ServerId) : connectionManager.currentApiClient();
|
||||
const apiClient = currentItem ? window.connectionManager.getApiClient(currentItem.ServerId) : window.connectionManager.currentApiClient();
|
||||
const endpointInfo = apiClient.getSavedEndpointInfo() || {};
|
||||
|
||||
return appSettings.enableAutomaticBitrateDetection(endpointInfo.IsInNetwork, mediaType);
|
||||
|
@ -1421,7 +1416,7 @@ class PlaybackManager {
|
|||
return player.setMaxStreamingBitrate(options);
|
||||
}
|
||||
|
||||
const apiClient = connectionManager.getApiClient(self.currentItem(player).ServerId);
|
||||
const apiClient = window.connectionManager.getApiClient(self.currentItem(player).ServerId);
|
||||
|
||||
apiClient.getEndpointInfo().then(function (endpointInfo) {
|
||||
const playerData = getPlayerData(player);
|
||||
|
@ -1618,11 +1613,7 @@ class PlaybackManager {
|
|||
|
||||
player = player || self._currentPlayer;
|
||||
if (player && !enableLocalPlaylistManagement(player)) {
|
||||
if (player.isLocalPlayer) {
|
||||
return player.seek((ticks || 0) / 10000);
|
||||
} else {
|
||||
return player.seek(ticks);
|
||||
}
|
||||
return player.seek(ticks);
|
||||
}
|
||||
|
||||
changeStream(player, ticks);
|
||||
|
@ -1631,11 +1622,7 @@ class PlaybackManager {
|
|||
self.seekRelative = function (offsetTicks, player) {
|
||||
player = player || self._currentPlayer;
|
||||
if (player && !enableLocalPlaylistManagement(player) && player.seekRelative) {
|
||||
if (player.isLocalPlayer) {
|
||||
return player.seekRelative((ticks || 0) / 10000);
|
||||
} else {
|
||||
return player.seekRelative(ticks);
|
||||
}
|
||||
return player.seekRelative(ticks);
|
||||
}
|
||||
|
||||
const ticks = getCurrentTicks(player) + offsetTicks;
|
||||
|
@ -1691,7 +1678,7 @@ class PlaybackManager {
|
|||
const subtitleStreamIndex = params.SubtitleStreamIndex == null ? getPlayerData(player).subtitleStreamIndex : params.SubtitleStreamIndex;
|
||||
|
||||
let currentMediaSource = self.currentMediaSource(player);
|
||||
const apiClient = connectionManager.getApiClient(currentItem.ServerId);
|
||||
const apiClient = window.connectionManager.getApiClient(currentItem.ServerId);
|
||||
|
||||
if (ticks) {
|
||||
ticks = parseInt(ticks);
|
||||
|
@ -1710,7 +1697,7 @@ class PlaybackManager {
|
|||
streamInfo.lastMediaInfoQuery = lastMediaInfoQuery;
|
||||
|
||||
if (!streamInfo.url) {
|
||||
showPlaybackInfoErrorMessage(self, 'NoCompatibleStream', true);
|
||||
showPlaybackInfoErrorMessage(self, 'PlaybackErrorNoCompatibleStream');
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1847,7 +1834,7 @@ class PlaybackManager {
|
|||
}, queryOptions));
|
||||
} else if (firstItem.Type === 'Episode' && items.length === 1 && getPlayer(firstItem, options).supportsProgress !== false) {
|
||||
promise = new Promise(function (resolve, reject) {
|
||||
const apiClient = connectionManager.getApiClient(firstItem.ServerId);
|
||||
const apiClient = window.connectionManager.getApiClient(firstItem.ServerId);
|
||||
|
||||
apiClient.getCurrentUser().then(function (user) {
|
||||
if (!user.Configuration.EnableNextEpisodeAutoPlay || !firstItem.SeriesId) {
|
||||
|
@ -2070,7 +2057,7 @@ class PlaybackManager {
|
|||
|
||||
// If it's still null then there's nothing to play
|
||||
if (!firstItem) {
|
||||
showPlaybackInfoErrorMessage(self, 'NoCompatibleStream', false);
|
||||
showPlaybackInfoErrorMessage(self, 'PlaybackErrorNoCompatibleStream');
|
||||
return Promise.reject();
|
||||
}
|
||||
|
||||
|
@ -2078,7 +2065,7 @@ class PlaybackManager {
|
|||
return playOther(items, options, user);
|
||||
}
|
||||
|
||||
const apiClient = connectionManager.getApiClient(firstItem.ServerId);
|
||||
const apiClient = window.connectionManager.getApiClient(firstItem.ServerId);
|
||||
|
||||
return getIntros(firstItem, apiClient, options).then(function (introsResult) {
|
||||
const introItems = introsResult.Items;
|
||||
|
@ -2119,7 +2106,7 @@ class PlaybackManager {
|
|||
function playInternal(item, playOptions, onPlaybackStartedFn) {
|
||||
if (item.IsPlaceHolder) {
|
||||
loading.hide();
|
||||
showPlaybackInfoErrorMessage(self, 'PlaceHolder', true);
|
||||
showPlaybackInfoErrorMessage(self, 'PlaybackErrorPlaceHolder');
|
||||
return Promise.reject();
|
||||
}
|
||||
|
||||
|
@ -2141,14 +2128,14 @@ class PlaybackManager {
|
|||
const mediaType = item.MediaType;
|
||||
|
||||
const onBitrateDetectionFailure = function () {
|
||||
return playAfterBitrateDetect(getSavedMaxStreamingBitrate(connectionManager.getApiClient(item.ServerId), mediaType), item, playOptions, onPlaybackStartedFn);
|
||||
return playAfterBitrateDetect(getSavedMaxStreamingBitrate(window.connectionManager.getApiClient(item.ServerId), mediaType), item, playOptions, onPlaybackStartedFn);
|
||||
};
|
||||
|
||||
if (!isServerItem(item) || itemHelper.isLocalItem(item)) {
|
||||
return onBitrateDetectionFailure();
|
||||
}
|
||||
|
||||
const apiClient = connectionManager.getApiClient(item.ServerId);
|
||||
const apiClient = window.connectionManager.getApiClient(item.ServerId);
|
||||
apiClient.getEndpointInfo().then(function (endpointInfo) {
|
||||
if ((mediaType === 'Video' || mediaType === 'Audio') && appSettings.enableAutomaticBitrateDetection(endpointInfo.IsInNetwork, mediaType)) {
|
||||
return apiClient.detectBitrate().then(function (bitrate) {
|
||||
|
@ -2271,7 +2258,7 @@ class PlaybackManager {
|
|||
return Promise.all([promise, player.getDeviceProfile(item)]).then(function (responses) {
|
||||
const deviceProfile = responses[1];
|
||||
|
||||
const apiClient = connectionManager.getApiClient(item.ServerId);
|
||||
const apiClient = window.connectionManager.getApiClient(item.ServerId);
|
||||
|
||||
const mediaSourceId = playOptions.mediaSourceId;
|
||||
const audioStreamIndex = playOptions.audioStreamIndex;
|
||||
|
@ -2316,11 +2303,11 @@ class PlaybackManager {
|
|||
const startPosition = options.startPositionTicks || 0;
|
||||
const mediaType = options.mediaType || item.MediaType;
|
||||
const player = getPlayer(item, options);
|
||||
const apiClient = connectionManager.getApiClient(item.ServerId);
|
||||
const apiClient = window.connectionManager.getApiClient(item.ServerId);
|
||||
|
||||
// Call this just to ensure the value is recorded, it is needed with getSavedMaxStreamingBitrate
|
||||
return apiClient.getEndpointInfo().then(function () {
|
||||
const maxBitrate = getSavedMaxStreamingBitrate(connectionManager.getApiClient(item.ServerId), mediaType);
|
||||
const maxBitrate = getSavedMaxStreamingBitrate(window.connectionManager.getApiClient(item.ServerId), mediaType);
|
||||
|
||||
return player.getDeviceProfile(item).then(function (deviceProfile) {
|
||||
return getPlaybackMediaSource(player, apiClient, deviceProfile, maxBitrate, item, startPosition, options.mediaSourceId, options.audioStreamIndex, options.subtitleStreamIndex).then(function (mediaSource) {
|
||||
|
@ -2336,11 +2323,11 @@ class PlaybackManager {
|
|||
const mediaType = options.mediaType || item.MediaType;
|
||||
// TODO: Remove the true forceLocalPlayer hack
|
||||
const player = getPlayer(item, options, true);
|
||||
const apiClient = connectionManager.getApiClient(item.ServerId);
|
||||
const apiClient = window.connectionManager.getApiClient(item.ServerId);
|
||||
|
||||
// Call this just to ensure the value is recorded, it is needed with getSavedMaxStreamingBitrate
|
||||
return apiClient.getEndpointInfo().then(function () {
|
||||
const maxBitrate = getSavedMaxStreamingBitrate(connectionManager.getApiClient(item.ServerId), mediaType);
|
||||
const maxBitrate = getSavedMaxStreamingBitrate(window.connectionManager.getApiClient(item.ServerId), mediaType);
|
||||
|
||||
return player.getDeviceProfile(item).then(function (deviceProfile) {
|
||||
return getPlaybackInfo(player, apiClient, item, deviceProfile, maxBitrate, startPosition, false, null, null, null, null).then(function (playbackInfoResult) {
|
||||
|
@ -2492,7 +2479,7 @@ class PlaybackManager {
|
|||
return mediaSource;
|
||||
}
|
||||
} else {
|
||||
showPlaybackInfoErrorMessage(self, 'NoCompatibleStream');
|
||||
showPlaybackInfoErrorMessage(self, 'PlaybackErrorNoCompatibleStream');
|
||||
return Promise.reject();
|
||||
}
|
||||
});
|
||||
|
@ -2724,7 +2711,7 @@ class PlaybackManager {
|
|||
const queueDirectToPlayer = player && !enableLocalPlaylistManagement(player);
|
||||
|
||||
if (queueDirectToPlayer) {
|
||||
const apiClient = connectionManager.getApiClient(items[0].ServerId);
|
||||
const apiClient = window.connectionManager.getApiClient(items[0].ServerId);
|
||||
|
||||
player.getDeviceProfile(items[0]).then(function (profile) {
|
||||
setStreamUrls(items, profile, self.getMaxStreamingBitrate(player), apiClient, 0).then(function () {
|
||||
|
@ -2981,7 +2968,7 @@ class PlaybackManager {
|
|||
}
|
||||
|
||||
if (displayErrorCode && typeof (displayErrorCode) === 'string') {
|
||||
showPlaybackInfoErrorMessage(self, displayErrorCode, nextItem);
|
||||
showPlaybackInfoErrorMessage(self, 'PlaybackError' + displayErrorCode);
|
||||
} else if (nextItem) {
|
||||
self.nextTrack();
|
||||
} else {
|
||||
|
@ -3174,13 +3161,13 @@ class PlaybackManager {
|
|||
|
||||
streamInfo.lastMediaInfoQuery = new Date().getTime();
|
||||
|
||||
const apiClient = connectionManager.getApiClient(serverId);
|
||||
const apiClient = window.connectionManager.getApiClient(serverId);
|
||||
|
||||
if (!apiClient.isMinServerVersion('3.2.70.7')) {
|
||||
return;
|
||||
}
|
||||
|
||||
connectionManager.getApiClient(serverId).getLiveStreamMediaInfo(liveStreamId).then(function (info) {
|
||||
window.connectionManager.getApiClient(serverId).getLiveStreamMediaInfo(liveStreamId).then(function (info) {
|
||||
mediaSource.MediaStreams = info.MediaStreams;
|
||||
events.trigger(player, 'mediastreamschange');
|
||||
}, function () {
|
||||
|
@ -3223,7 +3210,7 @@ class PlaybackManager {
|
|||
return player.currentTime();
|
||||
}
|
||||
|
||||
return this.getCurrentTicks(player);
|
||||
return this.getCurrentTicks(player) / 10000;
|
||||
}
|
||||
|
||||
nextItem(player = this._currentPlayer) {
|
||||
|
@ -3237,7 +3224,7 @@ class PlaybackManager {
|
|||
return Promise.reject();
|
||||
}
|
||||
|
||||
const apiClient = connectionManager.getApiClient(nextItem.item.ServerId);
|
||||
const apiClient = window.connectionManager.getApiClient(nextItem.item.ServerId);
|
||||
return apiClient.getItem(apiClient.getCurrentUserId(), nextItem.item.Id);
|
||||
}
|
||||
|
||||
|
@ -3378,7 +3365,7 @@ class PlaybackManager {
|
|||
return player.playTrailers(item);
|
||||
}
|
||||
|
||||
const apiClient = connectionManager.getApiClient(item.ServerId);
|
||||
const apiClient = window.connectionManager.getApiClient(item.ServerId);
|
||||
|
||||
const instance = this;
|
||||
|
||||
|
@ -3410,7 +3397,7 @@ class PlaybackManager {
|
|||
}
|
||||
|
||||
getSubtitleUrl(textStream, serverId) {
|
||||
const apiClient = connectionManager.getApiClient(serverId);
|
||||
const apiClient = window.connectionManager.getApiClient(serverId);
|
||||
|
||||
return !textStream.IsExternalUrl ? apiClient.getUrl(textStream.DeliveryUrl) : textStream.DeliveryUrl;
|
||||
}
|
||||
|
@ -3490,7 +3477,7 @@ class PlaybackManager {
|
|||
return player.instantMix(item);
|
||||
}
|
||||
|
||||
const apiClient = connectionManager.getApiClient(item.ServerId);
|
||||
const apiClient = window.connectionManager.getApiClient(item.ServerId);
|
||||
|
||||
const options = {};
|
||||
options.UserId = apiClient.getCurrentUserId();
|
||||
|
|
|
@ -2,7 +2,7 @@ import playbackManager from 'playbackManager';
|
|||
import layoutManager from 'layoutManager';
|
||||
import events from 'events';
|
||||
|
||||
var orientationLocked;
|
||||
let orientationLocked;
|
||||
|
||||
function onOrientationChangeSuccess() {
|
||||
orientationLocked = true;
|
||||
|
@ -14,15 +14,15 @@ function onOrientationChangeError(err) {
|
|||
}
|
||||
|
||||
events.on(playbackManager, 'playbackstart', function (e, player, state) {
|
||||
var isLocalVideo = player.isLocalPlayer && !player.isExternalPlayer && playbackManager.isPlayingVideo(player);
|
||||
const isLocalVideo = player.isLocalPlayer && !player.isExternalPlayer && playbackManager.isPlayingVideo(player);
|
||||
|
||||
if (isLocalVideo && layoutManager.mobile) {
|
||||
/* eslint-disable-next-line compat/compat */
|
||||
var lockOrientation = screen.lockOrientation || screen.mozLockOrientation || screen.msLockOrientation || (screen.orientation && screen.orientation.lock);
|
||||
const lockOrientation = window.screen.lockOrientation || window.screen.mozLockOrientation || window.screen.msLockOrientation || (window.screen.orientation && window.screen.orientation.lock);
|
||||
|
||||
if (lockOrientation) {
|
||||
try {
|
||||
var promise = lockOrientation('landscape');
|
||||
const promise = lockOrientation('landscape');
|
||||
if (promise.then) {
|
||||
promise.then(onOrientationChangeSuccess, onOrientationChangeError);
|
||||
} else {
|
||||
|
@ -39,7 +39,7 @@ events.on(playbackManager, 'playbackstart', function (e, player, state) {
|
|||
events.on(playbackManager, 'playbackstop', function (e, playbackStopInfo) {
|
||||
if (orientationLocked && !playbackStopInfo.nextMediaType) {
|
||||
/* eslint-disable-next-line compat/compat */
|
||||
var unlockOrientation = screen.unlockOrientation || screen.mozUnlockOrientation || screen.msUnlockOrientation || (screen.orientation && screen.orientation.unlock);
|
||||
const unlockOrientation = window.screen.unlockOrientation || window.screen.mozUnlockOrientation || window.screen.msUnlockOrientation || (window.screen.orientation && window.screen.orientation.unlock);
|
||||
|
||||
if (unlockOrientation) {
|
||||
try {
|
||||
|
|
|
@ -6,9 +6,10 @@ import playbackManager from 'playbackManager';
|
|||
import appRouter from 'appRouter';
|
||||
import globalize from 'globalize';
|
||||
import appHost from 'apphost';
|
||||
import * as autocast from 'autocast';
|
||||
|
||||
function mirrorItem(info, player) {
|
||||
var item = info.item;
|
||||
const item = info.item;
|
||||
|
||||
playbackManager.displayContent({
|
||||
|
||||
|
@ -21,7 +22,7 @@ function mirrorItem(info, player) {
|
|||
|
||||
function mirrorIfEnabled(info) {
|
||||
if (info && playbackManager.enableDisplayMirroring()) {
|
||||
var getPlayerInfo = playbackManager.getPlayerInfo();
|
||||
const getPlayerInfo = playbackManager.getPlayerInfo();
|
||||
|
||||
if (getPlayerInfo) {
|
||||
if (!getPlayerInfo.isLocalPlayer && getPlayerInfo.supportedCommands.indexOf('DisplayContent') !== -1) {
|
||||
|
@ -44,7 +45,7 @@ function getTargetSecondaryText(target) {
|
|||
}
|
||||
|
||||
function getIcon(target) {
|
||||
var deviceType = target.deviceType;
|
||||
let deviceType = target.deviceType;
|
||||
|
||||
if (!deviceType && target.isLocalPlayer) {
|
||||
if (browser.tv) {
|
||||
|
@ -77,7 +78,7 @@ function getIcon(target) {
|
|||
}
|
||||
|
||||
export function show(button) {
|
||||
var currentPlayerInfo = playbackManager.getPlayerInfo();
|
||||
const currentPlayerInfo = playbackManager.getPlayerInfo();
|
||||
|
||||
if (currentPlayerInfo) {
|
||||
if (!currentPlayerInfo.isLocalPlayer) {
|
||||
|
@ -86,13 +87,13 @@ export function show(button) {
|
|||
}
|
||||
}
|
||||
|
||||
var currentPlayerId = currentPlayerInfo ? currentPlayerInfo.id : null;
|
||||
const currentPlayerId = currentPlayerInfo ? currentPlayerInfo.id : null;
|
||||
|
||||
loading.show();
|
||||
|
||||
playbackManager.getTargets().then(function (targets) {
|
||||
var menuItems = targets.map(function (t) {
|
||||
var name = t.name;
|
||||
const menuItems = targets.map(function (t) {
|
||||
let name = t.name;
|
||||
|
||||
if (t.appName && t.appName !== t.name) {
|
||||
name += ' - ' + t.appName;
|
||||
|
@ -110,7 +111,7 @@ export function show(button) {
|
|||
import('actionsheet').then(({default: actionsheet}) => {
|
||||
loading.hide();
|
||||
|
||||
var menuOptions = {
|
||||
const menuOptions = {
|
||||
title: globalize.translate('HeaderPlayOn'),
|
||||
items: menuItems,
|
||||
positionTo: button,
|
||||
|
@ -126,7 +127,7 @@ export function show(button) {
|
|||
}
|
||||
|
||||
actionsheet.show(menuOptions).then(function (id) {
|
||||
var target = targets.filter(function (t) {
|
||||
const target = targets.filter(function (t) {
|
||||
return t.id === id;
|
||||
})[0];
|
||||
|
||||
|
@ -152,7 +153,7 @@ function showActivePlayerMenu(playerInfo) {
|
|||
function disconnectFromPlayer(currentDeviceName) {
|
||||
if (playbackManager.getSupportedCommands().indexOf('EndSession') !== -1) {
|
||||
import('dialog').then(({default: dialog}) => {
|
||||
var menuItems = [];
|
||||
const menuItems = [];
|
||||
|
||||
menuItems.push({
|
||||
name: globalize.translate('Yes'),
|
||||
|
@ -187,9 +188,9 @@ function disconnectFromPlayer(currentDeviceName) {
|
|||
}
|
||||
|
||||
function showActivePlayerMenuInternal(dialogHelper, playerInfo) {
|
||||
var html = '';
|
||||
let html = '';
|
||||
|
||||
var dialogOptions = {
|
||||
const dialogOptions = {
|
||||
removeOnClose: true
|
||||
};
|
||||
|
||||
|
@ -198,11 +199,11 @@ function showActivePlayerMenuInternal(dialogHelper, playerInfo) {
|
|||
dialogOptions.exitAnimationDuration = 160;
|
||||
dialogOptions.autoFocus = false;
|
||||
|
||||
var dlg = dialogHelper.createDialog(dialogOptions);
|
||||
const dlg = dialogHelper.createDialog(dialogOptions);
|
||||
|
||||
dlg.classList.add('promptDialog');
|
||||
|
||||
var currentDeviceName = (playerInfo.deviceName || playerInfo.name);
|
||||
const currentDeviceName = (playerInfo.deviceName || playerInfo.name);
|
||||
|
||||
html += '<div class="promptDialogContent" style="padding:1.5em;">';
|
||||
html += '<h2 style="margin-top:.5em;">';
|
||||
|
@ -213,7 +214,7 @@ function showActivePlayerMenuInternal(dialogHelper, playerInfo) {
|
|||
|
||||
if (playerInfo.supportedCommands.indexOf('DisplayContent') !== -1) {
|
||||
html += '<label class="checkboxContainer">';
|
||||
var checkedHtml = playbackManager.enableDisplayMirroring() ? ' checked' : '';
|
||||
const checkedHtml = playbackManager.enableDisplayMirroring() ? ' checked' : '';
|
||||
html += '<input type="checkbox" is="emby-checkbox" class="chkMirror"' + checkedHtml + '/>';
|
||||
html += '<span>' + globalize.translate('EnableDisplayMirroring') + '</span>';
|
||||
html += '</label>';
|
||||
|
@ -221,6 +222,14 @@ function showActivePlayerMenuInternal(dialogHelper, playerInfo) {
|
|||
|
||||
html += '</div>';
|
||||
|
||||
if (autocast.supported()) {
|
||||
html += '<div><label class="checkboxContainer">';
|
||||
const checkedHtmlAC = autocast.isEnabled() ? ' checked' : '';
|
||||
html += '<input type="checkbox" is="emby-checkbox" class="chkAutoCast"' + checkedHtmlAC + '/>';
|
||||
html += '<span>' + globalize.translate('EnableAutoCast') + '</span>';
|
||||
html += '</label></div>';
|
||||
}
|
||||
|
||||
html += '<div style="margin-top:1em;display:flex;justify-content: flex-end;">';
|
||||
|
||||
html += '<button is="emby-button" type="button" class="button-flat btnRemoteControl promptDialogButton">' + globalize.translate('HeaderRemoteControl') + '</button>';
|
||||
|
@ -231,15 +240,21 @@ function showActivePlayerMenuInternal(dialogHelper, playerInfo) {
|
|||
html += '</div>';
|
||||
dlg.innerHTML = html;
|
||||
|
||||
var chkMirror = dlg.querySelector('.chkMirror');
|
||||
const chkMirror = dlg.querySelector('.chkMirror');
|
||||
|
||||
if (chkMirror) {
|
||||
chkMirror.addEventListener('change', onMirrorChange);
|
||||
}
|
||||
|
||||
var destination = '';
|
||||
const chkAutoCast = dlg.querySelector('.chkAutoCast');
|
||||
|
||||
var btnRemoteControl = dlg.querySelector('.btnRemoteControl');
|
||||
if (chkAutoCast) {
|
||||
chkAutoCast.addEventListener('change', onAutoCastChange);
|
||||
}
|
||||
|
||||
let destination = '';
|
||||
|
||||
const btnRemoteControl = dlg.querySelector('.btnRemoteControl');
|
||||
if (btnRemoteControl) {
|
||||
btnRemoteControl.addEventListener('click', function () {
|
||||
destination = 'nowplaying';
|
||||
|
@ -269,9 +284,13 @@ function onMirrorChange() {
|
|||
playbackManager.enableDisplayMirroring(this.checked);
|
||||
}
|
||||
|
||||
function onAutoCastChange() {
|
||||
autocast.enable(this.checked);
|
||||
}
|
||||
|
||||
document.addEventListener('viewshow', function (e) {
|
||||
var state = e.detail.state || {};
|
||||
var item = state.item;
|
||||
const state = e.detail.state || {};
|
||||
const item = state.item;
|
||||
|
||||
if (item && item.ServerId) {
|
||||
mirrorIfEnabled({
|
||||
|
|
|
@ -1,17 +1,16 @@
|
|||
import connectionManager from 'connectionManager';
|
||||
import actionsheet from 'actionsheet';
|
||||
import playbackManager from 'playbackManager';
|
||||
import globalize from 'globalize';
|
||||
import qualityoptions from 'qualityoptions';
|
||||
|
||||
function showQualityMenu(player, btn) {
|
||||
var videoStream = playbackManager.currentMediaSource(player).MediaStreams.filter(function (stream) {
|
||||
const videoStream = playbackManager.currentMediaSource(player).MediaStreams.filter(function (stream) {
|
||||
return stream.Type === 'Video';
|
||||
})[0];
|
||||
var videoWidth = videoStream ? videoStream.Width : null;
|
||||
var videoHeight = videoStream ? videoStream.Height : null;
|
||||
const videoWidth = videoStream ? videoStream.Width : null;
|
||||
const videoHeight = videoStream ? videoStream.Height : null;
|
||||
|
||||
var options = qualityoptions.getVideoQualityOptions({
|
||||
const options = qualityoptions.getVideoQualityOptions({
|
||||
currentMaxBitrate: playbackManager.getMaxStreamingBitrate(player),
|
||||
isAutomaticBitrateEnabled: playbackManager.enableAutomaticBitrateDetection(player),
|
||||
videoWidth: videoWidth,
|
||||
|
@ -19,8 +18,8 @@ function showQualityMenu(player, btn) {
|
|||
enableAuto: true
|
||||
});
|
||||
|
||||
var menuItems = options.map(function (o) {
|
||||
var opt = {
|
||||
const menuItems = options.map(function (o) {
|
||||
const opt = {
|
||||
name: o.name,
|
||||
id: o.bitrate,
|
||||
asideText: o.secondaryText
|
||||
|
@ -33,7 +32,7 @@ function showQualityMenu(player, btn) {
|
|||
return opt;
|
||||
});
|
||||
|
||||
var selectedId = options.filter(function (o) {
|
||||
let selectedId = options.filter(function (o) {
|
||||
return o.selected;
|
||||
});
|
||||
|
||||
|
@ -43,7 +42,7 @@ function showQualityMenu(player, btn) {
|
|||
items: menuItems,
|
||||
positionTo: btn
|
||||
}).then(function (id) {
|
||||
var bitrate = parseInt(id);
|
||||
const bitrate = parseInt(id);
|
||||
if (bitrate !== selectedId) {
|
||||
playbackManager.setMaxStreamingBitrate({
|
||||
enableAutomaticBitrateDetection: bitrate ? false : true,
|
||||
|
@ -54,8 +53,8 @@ function showQualityMenu(player, btn) {
|
|||
}
|
||||
|
||||
function showRepeatModeMenu(player, btn) {
|
||||
var menuItems = [];
|
||||
var currentValue = playbackManager.getRepeatMode(player);
|
||||
const menuItems = [];
|
||||
const currentValue = playbackManager.getRepeatMode(player);
|
||||
|
||||
menuItems.push({
|
||||
name: globalize.translate('RepeatAll'),
|
||||
|
@ -86,16 +85,16 @@ function showRepeatModeMenu(player, btn) {
|
|||
}
|
||||
|
||||
function getQualitySecondaryText(player) {
|
||||
var state = playbackManager.getPlayerState(player);
|
||||
const state = playbackManager.getPlayerState(player);
|
||||
|
||||
var videoStream = playbackManager.currentMediaSource(player).MediaStreams.filter(function (stream) {
|
||||
const videoStream = playbackManager.currentMediaSource(player).MediaStreams.filter(function (stream) {
|
||||
return stream.Type === 'Video';
|
||||
})[0];
|
||||
|
||||
var videoWidth = videoStream ? videoStream.Width : null;
|
||||
var videoHeight = videoStream ? videoStream.Height : null;
|
||||
const videoWidth = videoStream ? videoStream.Width : null;
|
||||
const videoHeight = videoStream ? videoStream.Height : null;
|
||||
|
||||
var options = qualityoptions.getVideoQualityOptions({
|
||||
const options = qualityoptions.getVideoQualityOptions({
|
||||
currentMaxBitrate: playbackManager.getMaxStreamingBitrate(player),
|
||||
isAutomaticBitrateEnabled: playbackManager.enableAutomaticBitrateDetection(player),
|
||||
videoWidth: videoWidth,
|
||||
|
@ -103,7 +102,7 @@ function getQualitySecondaryText(player) {
|
|||
enableAuto: true
|
||||
});
|
||||
|
||||
var selectedOption = options.filter(function (o) {
|
||||
let selectedOption = options.filter(function (o) {
|
||||
return o.selected;
|
||||
});
|
||||
|
||||
|
@ -112,7 +111,7 @@ function getQualitySecondaryText(player) {
|
|||
}
|
||||
|
||||
selectedOption = selectedOption[0];
|
||||
var text = selectedOption.name;
|
||||
let text = selectedOption.name;
|
||||
|
||||
if (selectedOption.autoText) {
|
||||
if (state.PlayState && state.PlayState.PlayMethod !== 'Transcode') {
|
||||
|
@ -127,8 +126,8 @@ function getQualitySecondaryText(player) {
|
|||
|
||||
function showAspectRatioMenu(player, btn) {
|
||||
// each has a name and id
|
||||
var currentId = playbackManager.getAspectRatio(player);
|
||||
var menuItems = playbackManager.getSupportedAspectRatios(player).map(function (i) {
|
||||
const currentId = playbackManager.getAspectRatio(player);
|
||||
const menuItems = playbackManager.getSupportedAspectRatios(player).map(function (i) {
|
||||
return {
|
||||
id: i.id,
|
||||
name: i.name,
|
||||
|
@ -172,12 +171,12 @@ function showPlaybackRateMenu(player, btn) {
|
|||
}
|
||||
|
||||
function showWithUser(options, player, user) {
|
||||
var supportedCommands = playbackManager.getSupportedCommands(player);
|
||||
const supportedCommands = playbackManager.getSupportedCommands(player);
|
||||
|
||||
var menuItems = [];
|
||||
const menuItems = [];
|
||||
if (supportedCommands.indexOf('SetAspectRatio') !== -1) {
|
||||
var currentAspectRatioId = playbackManager.getAspectRatio(player);
|
||||
var currentAspectRatio = playbackManager.getSupportedAspectRatios(player).filter(function (i) {
|
||||
const currentAspectRatioId = playbackManager.getAspectRatio(player);
|
||||
const currentAspectRatio = playbackManager.getSupportedAspectRatios(player).filter(function (i) {
|
||||
return i.id === currentAspectRatioId;
|
||||
})[0];
|
||||
|
||||
|
@ -200,7 +199,7 @@ function showWithUser(options, player, user) {
|
|||
}
|
||||
|
||||
if (user && user.Policy.EnableVideoPlaybackTranscoding) {
|
||||
var secondaryQualityText = getQualitySecondaryText(player);
|
||||
const secondaryQualityText = getQualitySecondaryText(player);
|
||||
|
||||
menuItems.push({
|
||||
name: globalize.translate('Quality'),
|
||||
|
@ -209,7 +208,7 @@ function showWithUser(options, player, user) {
|
|||
});
|
||||
}
|
||||
|
||||
var repeatMode = playbackManager.getRepeatMode(player);
|
||||
const repeatMode = playbackManager.getRepeatMode(player);
|
||||
|
||||
if (supportedCommands.indexOf('SetRepeatMode') !== -1 && playbackManager.currentMediaSource(player).RunTimeTicks) {
|
||||
menuItems.push({
|
||||
|
@ -244,14 +243,14 @@ function showWithUser(options, player, user) {
|
|||
}
|
||||
|
||||
export function show(options) {
|
||||
var player = options.player;
|
||||
var currentItem = playbackManager.currentItem(player);
|
||||
const player = options.player;
|
||||
const currentItem = playbackManager.currentItem(player);
|
||||
|
||||
if (!currentItem || !currentItem.ServerId) {
|
||||
return showWithUser(options, player, null);
|
||||
}
|
||||
|
||||
var apiClient = connectionManager.getApiClient(currentItem.ServerId);
|
||||
const apiClient = window.connectionManager.getApiClient(currentItem.ServerId);
|
||||
return apiClient.getCurrentUser().then(function (user) {
|
||||
return showWithUser(options, player, user);
|
||||
});
|
||||
|
|
|
@ -5,15 +5,15 @@ import browser from 'browser';
|
|||
import 'css!./iconosd';
|
||||
import 'material-icons';
|
||||
|
||||
var currentPlayer;
|
||||
var osdElement;
|
||||
var iconElement;
|
||||
var progressElement;
|
||||
let currentPlayer;
|
||||
let osdElement;
|
||||
let iconElement;
|
||||
let progressElement;
|
||||
|
||||
var enableAnimation;
|
||||
let enableAnimation;
|
||||
|
||||
function getOsdElementHtml() {
|
||||
var html = '';
|
||||
let html = '';
|
||||
|
||||
html += '<span class="material-icons iconOsdIcon volume_up"></span>';
|
||||
|
||||
|
@ -23,7 +23,7 @@ function getOsdElementHtml() {
|
|||
}
|
||||
|
||||
function ensureOsdElement() {
|
||||
var elem = osdElement;
|
||||
let elem = osdElement;
|
||||
if (!elem) {
|
||||
enableAnimation = browser.supportsCssAnimation();
|
||||
|
||||
|
@ -46,11 +46,11 @@ function onHideComplete() {
|
|||
this.classList.add('hide');
|
||||
}
|
||||
|
||||
var hideTimeout;
|
||||
let hideTimeout;
|
||||
function showOsd() {
|
||||
clearHideTimeout();
|
||||
|
||||
var elem = osdElement;
|
||||
const elem = osdElement;
|
||||
|
||||
dom.removeEventListener(elem, dom.whichTransitionEvent(), onHideComplete, {
|
||||
once: true
|
||||
|
@ -78,7 +78,7 @@ function clearHideTimeout() {
|
|||
function hideOsd() {
|
||||
clearHideTimeout();
|
||||
|
||||
var elem = osdElement;
|
||||
const elem = osdElement;
|
||||
if (elem) {
|
||||
if (enableAnimation) {
|
||||
// trigger reflow
|
||||
|
@ -108,7 +108,7 @@ function updatePlayerVolumeState(isMuted, volume) {
|
|||
}
|
||||
|
||||
function releaseCurrentPlayer() {
|
||||
var player = currentPlayer;
|
||||
const player = currentPlayer;
|
||||
|
||||
if (player) {
|
||||
events.off(player, 'volumechange', onVolumeChanged);
|
||||
|
@ -118,7 +118,7 @@ function releaseCurrentPlayer() {
|
|||
}
|
||||
|
||||
function onVolumeChanged(e) {
|
||||
var player = this;
|
||||
const player = this;
|
||||
|
||||
ensureOsdElement();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue