mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
Merge remote-tracking branch 'upstream/master' into more-es6
This commit is contained in:
commit
936ff4186d
310 changed files with 9162 additions and 13374 deletions
|
@ -2,6 +2,7 @@ define(['playbackManager', 'events', 'serverNotifications', 'connectionManager']
|
|||
'use strict';
|
||||
|
||||
serverNotifications = serverNotifications.default || serverNotifications;
|
||||
playbackManager = playbackManager.default || playbackManager;
|
||||
|
||||
function getActivePlayerId() {
|
||||
var info = playbackManager.getPlayerInfo();
|
||||
|
@ -9,7 +10,6 @@ define(['playbackManager', 'events', 'serverNotifications', 'connectionManager']
|
|||
}
|
||||
|
||||
function sendPlayCommand(apiClient, options, playType) {
|
||||
|
||||
var sessionId = getActivePlayerId();
|
||||
|
||||
var ids = options.ids || options.items.map(function (i) {
|
||||
|
@ -46,14 +46,12 @@ define(['playbackManager', 'events', 'serverNotifications', 'connectionManager']
|
|||
}
|
||||
|
||||
function sendPlayStateCommand(apiClient, command, options) {
|
||||
|
||||
var sessionId = getActivePlayerId();
|
||||
|
||||
apiClient.sendPlayStateCommand(sessionId, command, options);
|
||||
}
|
||||
|
||||
function getCurrentApiClient(instance) {
|
||||
|
||||
var currentServerId = instance.currentServerId;
|
||||
|
||||
if (currentServerId) {
|
||||
|
@ -64,7 +62,6 @@ define(['playbackManager', 'events', 'serverNotifications', 'connectionManager']
|
|||
}
|
||||
|
||||
function sendCommandByName(instance, name, options) {
|
||||
|
||||
var command = {
|
||||
Name: name
|
||||
};
|
||||
|
@ -77,7 +74,6 @@ define(['playbackManager', 'events', 'serverNotifications', 'connectionManager']
|
|||
}
|
||||
|
||||
function unsubscribeFromPlayerUpdates(instance) {
|
||||
|
||||
instance.isUpdating = true;
|
||||
|
||||
var apiClient = getCurrentApiClient(instance);
|
||||
|
@ -89,7 +85,6 @@ define(['playbackManager', 'events', 'serverNotifications', 'connectionManager']
|
|||
}
|
||||
|
||||
function processUpdatedSessions(instance, sessions, apiClient) {
|
||||
|
||||
var serverId = apiClient.serverId();
|
||||
|
||||
sessions.map(function (s) {
|
||||
|
@ -105,7 +100,6 @@ define(['playbackManager', 'events', 'serverNotifications', 'connectionManager']
|
|||
})[0];
|
||||
|
||||
if (session) {
|
||||
|
||||
normalizeImages(session, apiClient);
|
||||
|
||||
var eventNames = getChangedEvents(instance.lastPlayerData, session);
|
||||
|
@ -114,9 +108,7 @@ define(['playbackManager', 'events', 'serverNotifications', 'connectionManager']
|
|||
for (var i = 0, length = eventNames.length; i < length; i++) {
|
||||
events.trigger(instance, eventNames[i], [session]);
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
instance.lastPlayerData = session;
|
||||
|
||||
playbackManager.setDefaultPlayerActive();
|
||||
|
@ -124,7 +116,6 @@ define(['playbackManager', 'events', 'serverNotifications', 'connectionManager']
|
|||
}
|
||||
|
||||
function getChangedEvents(state1, state2) {
|
||||
|
||||
var names = [];
|
||||
|
||||
if (!state1) {
|
||||
|
@ -144,11 +135,9 @@ define(['playbackManager', 'events', 'serverNotifications', 'connectionManager']
|
|||
}
|
||||
|
||||
function onPollIntervalFired() {
|
||||
|
||||
var instance = this;
|
||||
var apiClient = getCurrentApiClient(instance);
|
||||
if (!apiClient.isMessageChannelOpen()) {
|
||||
|
||||
apiClient.getSessions().then(function (sessions) {
|
||||
processUpdatedSessions(instance, sessions, apiClient);
|
||||
});
|
||||
|
@ -156,7 +145,6 @@ define(['playbackManager', 'events', 'serverNotifications', 'connectionManager']
|
|||
}
|
||||
|
||||
function subscribeToPlayerUpdates(instance) {
|
||||
|
||||
instance.isUpdating = true;
|
||||
|
||||
var apiClient = getCurrentApiClient(instance);
|
||||
|
@ -169,9 +157,7 @@ define(['playbackManager', 'events', 'serverNotifications', 'connectionManager']
|
|||
}
|
||||
|
||||
function normalizeImages(state, apiClient) {
|
||||
|
||||
if (state && state.NowPlayingItem) {
|
||||
|
||||
var item = state.NowPlayingItem;
|
||||
|
||||
if (!item.ImageTags || !item.ImageTags.Primary) {
|
||||
|
@ -194,7 +180,6 @@ define(['playbackManager', 'events', 'serverNotifications', 'connectionManager']
|
|||
}
|
||||
|
||||
function SessionPlayer() {
|
||||
|
||||
var self = this;
|
||||
|
||||
this.name = 'Remote Control';
|
||||
|
@ -208,11 +193,9 @@ define(['playbackManager', 'events', 'serverNotifications', 'connectionManager']
|
|||
}
|
||||
|
||||
SessionPlayer.prototype.beginPlayerUpdates = function () {
|
||||
|
||||
this.playerListenerCount = this.playerListenerCount || 0;
|
||||
|
||||
if (this.playerListenerCount <= 0) {
|
||||
|
||||
this.playerListenerCount = 0;
|
||||
|
||||
subscribeToPlayerUpdates(this);
|
||||
|
@ -222,24 +205,20 @@ define(['playbackManager', 'events', 'serverNotifications', 'connectionManager']
|
|||
};
|
||||
|
||||
SessionPlayer.prototype.endPlayerUpdates = function () {
|
||||
|
||||
this.playerListenerCount = this.playerListenerCount || 0;
|
||||
this.playerListenerCount--;
|
||||
|
||||
if (this.playerListenerCount <= 0) {
|
||||
|
||||
unsubscribeFromPlayerUpdates(this);
|
||||
this.playerListenerCount = 0;
|
||||
}
|
||||
};
|
||||
|
||||
SessionPlayer.prototype.getPlayerState = function () {
|
||||
|
||||
return this.lastPlayerData || {};
|
||||
};
|
||||
|
||||
SessionPlayer.prototype.getTargets = function () {
|
||||
|
||||
var apiClient = getCurrentApiClient(this);
|
||||
|
||||
var sessionQuery = {
|
||||
|
@ -247,14 +226,11 @@ define(['playbackManager', 'events', 'serverNotifications', 'connectionManager']
|
|||
};
|
||||
|
||||
if (apiClient) {
|
||||
|
||||
var name = this.name;
|
||||
|
||||
return apiClient.getSessions(sessionQuery).then(function (sessions) {
|
||||
|
||||
return sessions.filter(function (s) {
|
||||
return s.DeviceId !== apiClient.deviceId();
|
||||
|
||||
}).map(function (s) {
|
||||
return {
|
||||
name: s.DeviceName,
|
||||
|
@ -275,16 +251,13 @@ define(['playbackManager', 'events', 'serverNotifications', 'connectionManager']
|
|||
} : null
|
||||
};
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
} else {
|
||||
return Promise.resolve([]);
|
||||
}
|
||||
};
|
||||
|
||||
SessionPlayer.prototype.sendCommand = function (command) {
|
||||
|
||||
var sessionId = getActivePlayerId();
|
||||
|
||||
var apiClient = getCurrentApiClient(this);
|
||||
|
@ -292,7 +265,6 @@ define(['playbackManager', 'events', 'serverNotifications', 'connectionManager']
|
|||
};
|
||||
|
||||
SessionPlayer.prototype.play = function (options) {
|
||||
|
||||
options = Object.assign({}, options);
|
||||
|
||||
if (options.items) {
|
||||
|
@ -307,27 +279,22 @@ define(['playbackManager', 'events', 'serverNotifications', 'connectionManager']
|
|||
};
|
||||
|
||||
SessionPlayer.prototype.shuffle = function (item) {
|
||||
|
||||
sendPlayCommand(getCurrentApiClient(this), { ids: [item.Id] }, 'PlayShuffle');
|
||||
};
|
||||
|
||||
SessionPlayer.prototype.instantMix = function (item) {
|
||||
|
||||
sendPlayCommand(getCurrentApiClient(this), { ids: [item.Id] }, 'PlayInstantMix');
|
||||
};
|
||||
|
||||
SessionPlayer.prototype.queue = function (options) {
|
||||
|
||||
sendPlayCommand(getCurrentApiClient(this), options, 'PlayNext');
|
||||
};
|
||||
|
||||
SessionPlayer.prototype.queueNext = function (options) {
|
||||
|
||||
sendPlayCommand(getCurrentApiClient(this), options, 'PlayLast');
|
||||
};
|
||||
|
||||
SessionPlayer.prototype.canPlayMediaType = function (mediaType) {
|
||||
|
||||
mediaType = (mediaType || '').toLowerCase();
|
||||
return mediaType === 'audio' || mediaType === 'video';
|
||||
};
|
||||
|
@ -356,7 +323,6 @@ define(['playbackManager', 'events', 'serverNotifications', 'connectionManager']
|
|||
};
|
||||
|
||||
SessionPlayer.prototype.currentTime = function (val) {
|
||||
|
||||
if (val != null) {
|
||||
return this.seek(val);
|
||||
}
|
||||
|
@ -403,7 +369,6 @@ define(['playbackManager', 'events', 'serverNotifications', 'connectionManager']
|
|||
};
|
||||
|
||||
SessionPlayer.prototype.setMute = function (isMuted) {
|
||||
|
||||
if (isMuted) {
|
||||
sendCommandByName(this, 'Mute');
|
||||
} else {
|
||||
|
@ -502,14 +467,12 @@ define(['playbackManager', 'events', 'serverNotifications', 'connectionManager']
|
|||
};
|
||||
|
||||
SessionPlayer.prototype.setRepeatMode = function (mode) {
|
||||
|
||||
sendCommandByName(this, 'SetRepeatMode', {
|
||||
RepeatMode: mode
|
||||
});
|
||||
};
|
||||
|
||||
SessionPlayer.prototype.setQueueShuffleMode = function (mode) {
|
||||
|
||||
sendCommandByName(this, 'SetShuffleQueue', {
|
||||
ShuffleMode: mode
|
||||
});
|
||||
|
@ -520,7 +483,6 @@ define(['playbackManager', 'events', 'serverNotifications', 'connectionManager']
|
|||
};
|
||||
|
||||
SessionPlayer.prototype.displayContent = function (options) {
|
||||
|
||||
sendCommandByName(this, 'DisplayContent', options);
|
||||
};
|
||||
|
||||
|
@ -557,7 +519,6 @@ define(['playbackManager', 'events', 'serverNotifications', 'connectionManager']
|
|||
};
|
||||
|
||||
SessionPlayer.prototype.tryPair = function (target) {
|
||||
|
||||
return Promise.resolve();
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue