1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00

Merge pull request #1779 from Camc314/migrate-to-ES6-67

Migration of experimentalWarnings and sessionPlayer to ES6 modules
This commit is contained in:
dkanada 2020-08-16 22:44:53 +09:00 committed by GitHub
commit 8685cc383a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 313 additions and 331 deletions

View file

@ -172,6 +172,8 @@
"src/components/remotecontrol/remotecontrol.js", "src/components/remotecontrol/remotecontrol.js",
"src/components/sanatizefilename.js", "src/components/sanatizefilename.js",
"src/components/scrollManager.js", "src/components/scrollManager.js",
"src/plugins/experimentalWarnings/plugin.js",
"src/plugins/sessionPlayer/plugin.js",
"src/plugins/htmlAudioPlayer/plugin.js", "src/plugins/htmlAudioPlayer/plugin.js",
"src/plugins/chromecastPlayer/plugin.js", "src/plugins/chromecastPlayer/plugin.js",
"src/components/slideshow/slideshow.js", "src/components/slideshow/slideshow.js",

View file

@ -1416,8 +1416,8 @@ class PlaybackManager {
self.toggleFullscreen = function (player) { self.toggleFullscreen = function (player) {
player = player || self._currentPlayer; player = player || self._currentPlayer;
if (!player.isLocalPlayer || player.toggleFulscreen) { if (!player.isLocalPlayer || player.toggleFullscreen) {
return player.toggleFulscreen(); return player.toggleFullscreen();
} }
if (screenfull.isEnabled) { if (screenfull.isEnabled) {

View file

@ -1,15 +1,14 @@
define(['connectionManager', 'globalize', 'userSettings', 'apphost'], function (connectionManager, globalize, userSettings, appHost) { import globalize from 'globalize';
'use strict'; import * as userSettings from 'userSettings';
import appHost from 'apphost';
appHost = appHost.default || appHost;
// TODO: Replace with date-fns // TODO: Replace with date-fns
// https://stackoverflow.com/questions/6117814/get-week-of-year-in-javascript-like-in-php // https://stackoverflow.com/questions/6117814/get-week-of-year-in-javascript-like-in-php
function getWeek(date) { function getWeek(date) {
var d = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate())); const d = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()));
var dayNum = d.getUTCDay() || 7; const dayNum = d.getUTCDay() || 7;
d.setUTCDate(d.getUTCDate() + 4 - dayNum); d.setUTCDate(d.getUTCDate() + 4 - dayNum);
var yearStart = new Date(Date.UTC(d.getUTCFullYear(), 0, 1)); const yearStart = new Date(Date.UTC(d.getUTCFullYear(), 0, 1));
return Math.ceil((((d - yearStart) / 86400000) + 1) / 7); return Math.ceil((((d - yearStart) / 86400000) + 1) / 7);
} }
@ -18,7 +17,7 @@ define(['connectionManager', 'globalize', 'userSettings', 'apphost'], function (
return Promise.resolve(); return Promise.resolve();
} }
var now = new Date(); const now = new Date();
// TODO: Use date-fns // TODO: Use date-fns
userSettingsKey += now.getFullYear() + '-w' + getWeek(now); userSettingsKey += now.getFullYear() + '-w' + getWeek(now);
@ -30,7 +29,7 @@ define(['connectionManager', 'globalize', 'userSettings', 'apphost'], function (
return new Promise(function (resolve, reject) { return new Promise(function (resolve, reject) {
userSettings.set(userSettingsKey, '1', false); userSettings.set(userSettingsKey, '1', false);
require(['alert'], function (alert) { import('alert').then(({default: alert}) => {
return alert(text).then(resolve, resolve); return alert(text).then(resolve, resolve);
}); });
}); });
@ -48,14 +47,15 @@ define(['connectionManager', 'globalize', 'userSettings', 'apphost'], function (
return showMessage(globalize.translate('UnsupportedPlayback'), 'isoexpirementalinfo', 'nativeisoplayback'); return showMessage(globalize.translate('UnsupportedPlayback'), 'isoexpirementalinfo', 'nativeisoplayback');
} }
function ExpirementalPlaybackWarnings() { class ExpirementalPlaybackWarnings {
constructor() {
this.name = 'Experimental playback warnings'; this.name = 'Experimental playback warnings';
this.type = 'preplayintercept'; this.type = 'preplayintercept';
this.id = 'expirementalplaybackwarnings'; this.id = 'expirementalplaybackwarnings';
} }
ExpirementalPlaybackWarnings.prototype.intercept = function (options) { intercept(options) {
var item = options.item; const item = options.item;
if (!item) { if (!item) {
return Promise.resolve(); return Promise.resolve();
} }
@ -73,7 +73,7 @@ define(['connectionManager', 'globalize', 'userSettings', 'apphost'], function (
} }
return Promise.resolve(); return Promise.resolve();
}; }
}
return ExpirementalPlaybackWarnings; export default ExpirementalPlaybackWarnings;
});

View file

@ -1,22 +1,21 @@
define(['playbackManager', 'events', 'serverNotifications', 'connectionManager'], function (playbackManager, events, serverNotifications, connectionManager) { import playbackManager from 'playbackManager';
'use strict'; import events from 'events';
import serverNotifications from 'serverNotifications';
serverNotifications = serverNotifications.default || serverNotifications; import connectionManager from 'connectionManager';
playbackManager = playbackManager.default || playbackManager;
function getActivePlayerId() { function getActivePlayerId() {
var info = playbackManager.getPlayerInfo(); const info = playbackManager.getPlayerInfo();
return info ? info.id : null; return info ? info.id : null;
} }
function sendPlayCommand(apiClient, options, playType) { function sendPlayCommand(apiClient, options, playType) {
var sessionId = getActivePlayerId(); const sessionId = getActivePlayerId();
var ids = options.ids || options.items.map(function (i) { const ids = options.ids || options.items.map(function (i) {
return i.Id; return i.Id;
}); });
var remoteOptions = { const remoteOptions = {
ItemIds: ids.join(','), ItemIds: ids.join(','),
PlayCommand: playType PlayCommand: playType
@ -46,13 +45,13 @@ define(['playbackManager', 'events', 'serverNotifications', 'connectionManager']
} }
function sendPlayStateCommand(apiClient, command, options) { function sendPlayStateCommand(apiClient, command, options) {
var sessionId = getActivePlayerId(); const sessionId = getActivePlayerId();
apiClient.sendPlayStateCommand(sessionId, command, options); apiClient.sendPlayStateCommand(sessionId, command, options);
} }
function getCurrentApiClient(instance) { function getCurrentApiClient(instance) {
var currentServerId = instance.currentServerId; const currentServerId = instance.currentServerId;
if (currentServerId) { if (currentServerId) {
return connectionManager.getApiClient(currentServerId); return connectionManager.getApiClient(currentServerId);
@ -62,7 +61,7 @@ define(['playbackManager', 'events', 'serverNotifications', 'connectionManager']
} }
function sendCommandByName(instance, name, options) { function sendCommandByName(instance, name, options) {
var command = { const command = {
Name: name Name: name
}; };
@ -76,7 +75,7 @@ define(['playbackManager', 'events', 'serverNotifications', 'connectionManager']
function unsubscribeFromPlayerUpdates(instance) { function unsubscribeFromPlayerUpdates(instance) {
instance.isUpdating = true; instance.isUpdating = true;
var apiClient = getCurrentApiClient(instance); const apiClient = getCurrentApiClient(instance);
apiClient.sendMessage('SessionsStop'); apiClient.sendMessage('SessionsStop');
if (instance.pollInterval) { if (instance.pollInterval) {
clearInterval(instance.pollInterval); clearInterval(instance.pollInterval);
@ -85,7 +84,7 @@ define(['playbackManager', 'events', 'serverNotifications', 'connectionManager']
} }
function processUpdatedSessions(instance, sessions, apiClient) { function processUpdatedSessions(instance, sessions, apiClient) {
var serverId = apiClient.serverId(); const serverId = apiClient.serverId();
sessions.map(function (s) { sessions.map(function (s) {
if (s.NowPlayingItem) { if (s.NowPlayingItem) {
@ -93,19 +92,19 @@ define(['playbackManager', 'events', 'serverNotifications', 'connectionManager']
} }
}); });
var currentTargetId = getActivePlayerId(); const currentTargetId = getActivePlayerId();
var session = sessions.filter(function (s) { const session = sessions.filter(function (s) {
return s.Id === currentTargetId; return s.Id === currentTargetId;
})[0]; })[0];
if (session) { if (session) {
normalizeImages(session, apiClient); normalizeImages(session, apiClient);
var eventNames = getChangedEvents(instance.lastPlayerData, session); const eventNames = getChangedEvents(instance.lastPlayerData, session);
instance.lastPlayerData = session; instance.lastPlayerData = session;
for (var i = 0, length = eventNames.length; i < length; i++) { for (let i = 0, length = eventNames.length; i < length; i++) {
events.trigger(instance, eventNames[i], [session]); events.trigger(instance, eventNames[i], [session]);
} }
} else { } else {
@ -116,7 +115,7 @@ define(['playbackManager', 'events', 'serverNotifications', 'connectionManager']
} }
function getChangedEvents(state1, state2) { function getChangedEvents(state1, state2) {
var names = []; const names = [];
if (!state1) { if (!state1) {
names.push('statechange'); names.push('statechange');
@ -135,8 +134,8 @@ define(['playbackManager', 'events', 'serverNotifications', 'connectionManager']
} }
function onPollIntervalFired() { function onPollIntervalFired() {
var instance = this; const instance = this;
var apiClient = getCurrentApiClient(instance); const apiClient = getCurrentApiClient(instance);
if (!apiClient.isMessageChannelOpen()) { if (!apiClient.isMessageChannelOpen()) {
apiClient.getSessions().then(function (sessions) { apiClient.getSessions().then(function (sessions) {
processUpdatedSessions(instance, sessions, apiClient); processUpdatedSessions(instance, sessions, apiClient);
@ -147,7 +146,7 @@ define(['playbackManager', 'events', 'serverNotifications', 'connectionManager']
function subscribeToPlayerUpdates(instance) { function subscribeToPlayerUpdates(instance) {
instance.isUpdating = true; instance.isUpdating = true;
var apiClient = getCurrentApiClient(instance); const apiClient = getCurrentApiClient(instance);
apiClient.sendMessage('SessionsStart', '100,800'); apiClient.sendMessage('SessionsStart', '100,800');
if (instance.pollInterval) { if (instance.pollInterval) {
clearInterval(instance.pollInterval); clearInterval(instance.pollInterval);
@ -158,7 +157,7 @@ define(['playbackManager', 'events', 'serverNotifications', 'connectionManager']
function normalizeImages(state, apiClient) { function normalizeImages(state, apiClient) {
if (state && state.NowPlayingItem) { if (state && state.NowPlayingItem) {
var item = state.NowPlayingItem; const item = state.NowPlayingItem;
if (!item.ImageTags || !item.ImageTags.Primary) { if (!item.ImageTags || !item.ImageTags.Primary) {
if (item.PrimaryImageTag) { if (item.PrimaryImageTag) {
@ -179,8 +178,9 @@ define(['playbackManager', 'events', 'serverNotifications', 'connectionManager']
} }
} }
function SessionPlayer() { class SessionPlayer {
var self = this; constructor() {
const self = this;
this.name = 'Remote Control'; this.name = 'Remote Control';
this.type = 'mediaplayer'; this.type = 'mediaplayer';
@ -192,7 +192,7 @@ define(['playbackManager', 'events', 'serverNotifications', 'connectionManager']
}); });
} }
SessionPlayer.prototype.beginPlayerUpdates = function () { beginPlayerUpdates() {
this.playerListenerCount = this.playerListenerCount || 0; this.playerListenerCount = this.playerListenerCount || 0;
if (this.playerListenerCount <= 0) { if (this.playerListenerCount <= 0) {
@ -202,9 +202,9 @@ define(['playbackManager', 'events', 'serverNotifications', 'connectionManager']
} }
this.playerListenerCount++; this.playerListenerCount++;
}; }
SessionPlayer.prototype.endPlayerUpdates = function () { endPlayerUpdates() {
this.playerListenerCount = this.playerListenerCount || 0; this.playerListenerCount = this.playerListenerCount || 0;
this.playerListenerCount--; this.playerListenerCount--;
@ -212,21 +212,21 @@ define(['playbackManager', 'events', 'serverNotifications', 'connectionManager']
unsubscribeFromPlayerUpdates(this); unsubscribeFromPlayerUpdates(this);
this.playerListenerCount = 0; this.playerListenerCount = 0;
} }
}; }
SessionPlayer.prototype.getPlayerState = function () { getPlayerState() {
return this.lastPlayerData || {}; return this.lastPlayerData || {};
}; }
SessionPlayer.prototype.getTargets = function () { getTargets() {
var apiClient = getCurrentApiClient(this); const apiClient = getCurrentApiClient(this);
var sessionQuery = { const sessionQuery = {
ControllableByUserId: apiClient.getCurrentUserId() ControllableByUserId: apiClient.getCurrentUserId()
}; };
if (apiClient) { if (apiClient) {
var name = this.name; const name = this.name;
return apiClient.getSessions(sessionQuery).then(function (sessions) { return apiClient.getSessions(sessionQuery).then(function (sessions) {
return sessions.filter(function (s) { return sessions.filter(function (s) {
@ -243,11 +243,9 @@ define(['playbackManager', 'events', 'serverNotifications', 'connectionManager']
isLocalPlayer: false, isLocalPlayer: false,
supportedCommands: s.Capabilities.SupportedCommands, supportedCommands: s.Capabilities.SupportedCommands,
user: s.UserId ? { user: s.UserId ? {
Id: s.UserId, Id: s.UserId,
Name: s.UserName, Name: s.UserName,
PrimaryImageTag: s.UserPrimaryImageTag PrimaryImageTag: s.UserPrimaryImageTag
} : null } : null
}; };
}); });
@ -255,16 +253,16 @@ define(['playbackManager', 'events', 'serverNotifications', 'connectionManager']
} else { } else {
return Promise.resolve([]); return Promise.resolve([]);
} }
}; }
SessionPlayer.prototype.sendCommand = function (command) { sendCommand(command) {
var sessionId = getActivePlayerId(); const sessionId = getActivePlayerId();
var apiClient = getCurrentApiClient(this); const apiClient = getCurrentApiClient(this);
apiClient.sendCommand(sessionId, command); apiClient.sendCommand(sessionId, command);
}; }
SessionPlayer.prototype.play = function (options) { play(options) {
options = Object.assign({}, options); options = Object.assign({}, options);
if (options.items) { if (options.items) {
@ -276,251 +274,233 @@ define(['playbackManager', 'events', 'serverNotifications', 'connectionManager']
} }
return sendPlayCommand(getCurrentApiClient(this), options, 'PlayNow'); return sendPlayCommand(getCurrentApiClient(this), options, 'PlayNow');
}; }
SessionPlayer.prototype.shuffle = function (item) { shuffle(item) {
sendPlayCommand(getCurrentApiClient(this), { ids: [item.Id] }, 'PlayShuffle'); sendPlayCommand(getCurrentApiClient(this), { ids: [item.Id] }, 'PlayShuffle');
}; }
SessionPlayer.prototype.instantMix = function (item) { instantMix(item) {
sendPlayCommand(getCurrentApiClient(this), { ids: [item.Id] }, 'PlayInstantMix'); sendPlayCommand(getCurrentApiClient(this), { ids: [item.Id] }, 'PlayInstantMix');
}; }
SessionPlayer.prototype.queue = function (options) { queue(options) {
sendPlayCommand(getCurrentApiClient(this), options, 'PlayNext'); sendPlayCommand(getCurrentApiClient(this), options, 'PlayNext');
}; }
SessionPlayer.prototype.queueNext = function (options) { queueNext(options) {
sendPlayCommand(getCurrentApiClient(this), options, 'PlayLast'); sendPlayCommand(getCurrentApiClient(this), options, 'PlayLast');
}; }
SessionPlayer.prototype.canPlayMediaType = function (mediaType) { canPlayMediaType(mediaType) {
mediaType = (mediaType || '').toLowerCase(); mediaType = (mediaType || '').toLowerCase();
return mediaType === 'audio' || mediaType === 'video'; return mediaType === 'audio' || mediaType === 'video';
}; }
SessionPlayer.prototype.canQueueMediaType = function (mediaType) { canQueueMediaType(mediaType) {
return this.canPlayMediaType(mediaType); return this.canPlayMediaType(mediaType);
}; }
SessionPlayer.prototype.stop = function () { stop() {
sendPlayStateCommand(getCurrentApiClient(this), 'stop'); sendPlayStateCommand(getCurrentApiClient(this), 'stop');
}; }
SessionPlayer.prototype.nextTrack = function () { nextTrack() {
sendPlayStateCommand(getCurrentApiClient(this), 'nextTrack'); sendPlayStateCommand(getCurrentApiClient(this), 'nextTrack');
}; }
SessionPlayer.prototype.previousTrack = function () { previousTrack() {
sendPlayStateCommand(getCurrentApiClient(this), 'previousTrack'); sendPlayStateCommand(getCurrentApiClient(this), 'previousTrack');
}; }
SessionPlayer.prototype.seek = function (positionTicks) { seek(positionTicks) {
sendPlayStateCommand(getCurrentApiClient(this), 'seek', sendPlayStateCommand(getCurrentApiClient(this), 'seek',
{ {
SeekPositionTicks: positionTicks SeekPositionTicks: positionTicks
}); });
}; }
SessionPlayer.prototype.currentTime = function (val) { currentTime(val) {
if (val != null) { if (val != null) {
return this.seek(val); return this.seek(val);
} }
var state = this.lastPlayerData || {}; let state = this.lastPlayerData || {};
state = state.PlayState || {}; state = state.PlayState || {};
return state.PositionTicks; return state.PositionTicks;
}; }
SessionPlayer.prototype.duration = function () { duration() {
var state = this.lastPlayerData || {}; let state = this.lastPlayerData || {};
state = state.NowPlayingItem || {}; state = state.NowPlayingItem || {};
return state.RunTimeTicks; return state.RunTimeTicks;
}; }
SessionPlayer.prototype.paused = function () { paused() {
var state = this.lastPlayerData || {}; let state = this.lastPlayerData || {};
state = state.PlayState || {}; state = state.PlayState || {};
return state.IsPaused; return state.IsPaused;
}; }
SessionPlayer.prototype.getVolume = function () { getVolume() {
var state = this.lastPlayerData || {}; let state = this.lastPlayerData || {};
state = state.PlayState || {}; state = state.PlayState || {};
return state.VolumeLevel; return state.VolumeLevel;
}; }
SessionPlayer.prototype.isMuted = function () { isMuted() {
var state = this.lastPlayerData || {}; let state = this.lastPlayerData || {};
state = state.PlayState || {}; state = state.PlayState || {};
return state.IsMuted; return state.IsMuted;
}; }
SessionPlayer.prototype.pause = function () { pause() {
sendPlayStateCommand(getCurrentApiClient(this), 'Pause'); sendPlayStateCommand(getCurrentApiClient(this), 'Pause');
}; }
SessionPlayer.prototype.unpause = function () { unpause() {
sendPlayStateCommand(getCurrentApiClient(this), 'Unpause'); sendPlayStateCommand(getCurrentApiClient(this), 'Unpause');
}; }
SessionPlayer.prototype.playPause = function () { playPause() {
sendPlayStateCommand(getCurrentApiClient(this), 'PlayPause'); sendPlayStateCommand(getCurrentApiClient(this), 'PlayPause');
}; }
SessionPlayer.prototype.setMute = function (isMuted) { setMute(isMuted) {
if (isMuted) { if (isMuted) {
sendCommandByName(this, 'Mute'); sendCommandByName(this, 'Mute');
} else { } else {
sendCommandByName(this, 'Unmute'); sendCommandByName(this, 'Unmute');
} }
}; }
SessionPlayer.prototype.toggleMute = function () { toggleMute() {
sendCommandByName(this, 'ToggleMute'); sendCommandByName(this, 'ToggleMute');
}; }
SessionPlayer.prototype.setVolume = function (vol) { setVolume(vol) {
sendCommandByName(this, 'SetVolume', { sendCommandByName(this, 'SetVolume', {
Volume: vol Volume: vol
}); });
}; }
SessionPlayer.prototype.volumeUp = function () { volumeUp() {
sendCommandByName(this, 'VolumeUp'); sendCommandByName(this, 'VolumeUp');
}; }
SessionPlayer.prototype.volumeDown = function () { volumeDown() {
sendCommandByName(this, 'VolumeDown'); sendCommandByName(this, 'VolumeDown');
}; }
SessionPlayer.prototype.toggleFullscreen = function () { toggleFullscreen() {
sendCommandByName(this, 'ToggleFullscreen'); sendCommandByName(this, 'ToggleFullscreen');
}; }
SessionPlayer.prototype.audioTracks = function () { audioTracks() {
var state = this.lastPlayerData || {}; let state = this.lastPlayerData || {};
state = state.NowPlayingItem || {}; state = state.NowPlayingItem || {};
var streams = state.MediaStreams || []; const streams = state.MediaStreams || [];
return streams.filter(function (s) { return streams.filter(function (s) {
return s.Type === 'Audio'; return s.Type === 'Audio';
}); });
}; }
SessionPlayer.prototype.getAudioStreamIndex = function () { getAudioStreamIndex() {
var state = this.lastPlayerData || {}; let state = this.lastPlayerData || {};
state = state.PlayState || {}; state = state.PlayState || {};
return state.AudioStreamIndex; return state.AudioStreamIndex;
}; }
SessionPlayer.prototype.playTrailers = function (item) { playTrailers(item) {
sendCommandByName(this, 'PlayTrailers', { sendCommandByName(this, 'PlayTrailers', {
ItemId: item.Id ItemId: item.Id
}); });
}; }
SessionPlayer.prototype.setAudioStreamIndex = function (index) { setAudioStreamIndex(index) {
sendCommandByName(this, 'SetAudioStreamIndex', { sendCommandByName(this, 'SetAudioStreamIndex', {
Index: index Index: index
}); });
}; }
SessionPlayer.prototype.subtitleTracks = function () { subtitleTracks() {
var state = this.lastPlayerData || {}; let state = this.lastPlayerData || {};
state = state.NowPlayingItem || {}; state = state.NowPlayingItem || {};
var streams = state.MediaStreams || []; const streams = state.MediaStreams || [];
return streams.filter(function (s) { return streams.filter(function (s) {
return s.Type === 'Subtitle'; return s.Type === 'Subtitle';
}); });
}; }
SessionPlayer.prototype.getSubtitleStreamIndex = function () { getSubtitleStreamIndex() {
var state = this.lastPlayerData || {}; let state = this.lastPlayerData || {};
state = state.PlayState || {}; state = state.PlayState || {};
return state.SubtitleStreamIndex; return state.SubtitleStreamIndex;
}; }
SessionPlayer.prototype.setSubtitleStreamIndex = function (index) { setSubtitleStreamIndex(index) {
sendCommandByName(this, 'SetSubtitleStreamIndex', { sendCommandByName(this, 'SetSubtitleStreamIndex', {
Index: index Index: index
}); });
}; }
SessionPlayer.prototype.getMaxStreamingBitrate = function () { setRepeatMode(mode) {
};
SessionPlayer.prototype.setMaxStreamingBitrate = function (options) {
};
SessionPlayer.prototype.isFullscreen = function () {
};
SessionPlayer.prototype.toggleFullscreen = function () {
};
SessionPlayer.prototype.getRepeatMode = function () {
};
SessionPlayer.prototype.setRepeatMode = function (mode) {
sendCommandByName(this, 'SetRepeatMode', { sendCommandByName(this, 'SetRepeatMode', {
RepeatMode: mode RepeatMode: mode
}); });
}; }
SessionPlayer.prototype.setQueueShuffleMode = function (mode) { getRepeatMode() {
}
setQueueShuffleMode(mode) {
sendCommandByName(this, 'SetShuffleQueue', { sendCommandByName(this, 'SetShuffleQueue', {
ShuffleMode: mode ShuffleMode: mode
}); });
}; }
SessionPlayer.prototype.getQueueShuffleMode = function () { getQueueShuffleMode() {
}
}; displayContent(options) {
SessionPlayer.prototype.displayContent = function (options) {
sendCommandByName(this, 'DisplayContent', options); sendCommandByName(this, 'DisplayContent', options);
}; }
SessionPlayer.prototype.isPlaying = function () { isPlaying() {
var state = this.lastPlayerData || {}; const state = this.lastPlayerData || {};
return state.NowPlayingItem != null; return state.NowPlayingItem != null;
}; }
SessionPlayer.prototype.isPlayingVideo = function () { isPlayingVideo() {
var state = this.lastPlayerData || {}; let state = this.lastPlayerData || {};
state = state.NowPlayingItem || {}; state = state.NowPlayingItem || {};
return state.MediaType === 'Video'; return state.MediaType === 'Video';
}; }
SessionPlayer.prototype.isPlayingAudio = function () { isPlayingAudio() {
var state = this.lastPlayerData || {}; let state = this.lastPlayerData || {};
state = state.NowPlayingItem || {}; state = state.NowPlayingItem || {};
return state.MediaType === 'Audio'; return state.MediaType === 'Audio';
}; }
SessionPlayer.prototype.getPlaylist = function () { getPlaylist() {
return Promise.resolve([]); return Promise.resolve([]);
}; }
SessionPlayer.prototype.getCurrentPlaylistItemId = function () { getCurrentPlaylistItemId() {
}; }
SessionPlayer.prototype.setCurrentPlaylistItem = function (playlistItemId) { setCurrentPlaylistItem(playlistItemId) {
return Promise.resolve(); return Promise.resolve();
}; }
SessionPlayer.prototype.removeFromPlaylist = function (playlistItemIds) { removeFromPlaylist(playlistItemIds) {
return Promise.resolve(); return Promise.resolve();
}; }
SessionPlayer.prototype.tryPair = function (target) { tryPair(target) {
return Promise.resolve(); return Promise.resolve();
}; }
}
return SessionPlayer; export default SessionPlayer;
});

View file

@ -340,7 +340,7 @@ function initClient() {
function getPlaybackManager(playbackManager) { function getPlaybackManager(playbackManager) {
window.addEventListener('beforeunload', function () { window.addEventListener('beforeunload', function () {
try { try {
playbackManager.onAppClose(); playbackManager.default.onAppClose();
} catch (err) { } catch (err) {
console.error('error in onAppClose: ' + err); console.error('error in onAppClose: ' + err);
} }