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

update selection buttons

This commit is contained in:
Luke Pulverenti 2015-07-14 12:39:34 -04:00
parent 59a3cada00
commit 1c27cdeb2c
35 changed files with 226 additions and 115 deletions

View file

@ -190,6 +190,19 @@
return deferred.promise();
};
var pollInterval;
function onPollIntervalFired() {
if (!ApiClient.isWebSocketOpen()) {
var apiClient = window.ApiClient;
if (apiClient) {
apiClient.getSessions().done(processUpdatedSessions);
}
}
}
self.subscribeToPlayerUpdates = function () {
self.isUpdating = true;
@ -198,16 +211,25 @@
ApiClient.sendWebSocketMessage("SessionsStart", "100,800");
}
if (pollInterval) {
clearInterval(pollInterval);
pollInterval = null;
}
pollInterval = setInterval(onPollIntervalFired, 1500);
};
function unsubscribeFromPlayerUpdates() {
self.false = true;
self.isUpdating = true;
if (ApiClient.isWebSocketOpen()) {
ApiClient.sendWebSocketMessage("SessionsStop");
}
if (pollInterval) {
clearInterval(pollInterval);
pollInterval = null;
}
}
var playerListenerCount = 0;
@ -307,23 +329,28 @@
}
}
function processUpdatedSessions(sessions) {
var currentTargetId = MediaController.getPlayerInfo().id;
// Update existing data
//updateSessionInfo(popup, msg.Data);
var session = sessions.filter(function (s) {
return s.Id == currentTargetId;
})[0];
if (session) {
firePlaybackEvent('playstatechange', session);
}
}
function onWebSocketMessageReceived(e, msg) {
var apiClient = this;
if (msg.MessageType === "Sessions") {
var currentTargetId = MediaController.getPlayerInfo().id;
// Update existing data
//updateSessionInfo(popup, msg.Data);
var session = msg.Data.filter(function (s) {
return s.Id == currentTargetId;
})[0];
if (session) {
firePlaybackEvent('playstatechange', session);
}
processUpdatedSessions(msg.Data);
}
else if (msg.MessageType === "SessionEnded") {