mirror of
https://github.com/jellyfin/jellyfin-web.git
synced 2024-11-17 19:08:18 -07:00
progress on remote control
This commit is contained in:
parent
78c3668859
commit
7e6c0fa340
32
ApiClient.js
32
ApiClient.js
@ -2379,6 +2379,16 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout) {
|
||||
throw new Error("null itemId");
|
||||
}
|
||||
|
||||
if (self.isWebSocketOpen()) {
|
||||
|
||||
var deferred = $.Deferred();
|
||||
|
||||
self.sendWebSocketMessage("PlaybackStart", itemId);
|
||||
|
||||
deferred.resolveWith(null, []);
|
||||
return deferred.promise();
|
||||
}
|
||||
|
||||
var url = self.getUrl("Users/" + userId + "/PlayingItems/" + itemId);
|
||||
|
||||
return self.ajax({
|
||||
@ -2392,7 +2402,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout) {
|
||||
* @param {String} userId
|
||||
* @param {String} itemId
|
||||
*/
|
||||
self.reportPlaybackProgress = function (userId, itemId, positionTicks) {
|
||||
self.reportPlaybackProgress = function (userId, itemId, positionTicks, isPaused) {
|
||||
|
||||
if (!userId) {
|
||||
throw new Error("null userId");
|
||||
@ -2402,6 +2412,16 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout) {
|
||||
throw new Error("null itemId");
|
||||
}
|
||||
|
||||
if (self.isWebSocketOpen()) {
|
||||
|
||||
var deferred = $.Deferred();
|
||||
|
||||
self.sendWebSocketMessage("PlaybackProgress", itemId + "|" + (positionTicks == null ? "" : positionTicks) + "|" + (isPaused == null ? "" : isPaused));
|
||||
|
||||
deferred.resolveWith(null, []);
|
||||
return deferred.promise();
|
||||
}
|
||||
|
||||
var params = {
|
||||
};
|
||||
|
||||
@ -2433,6 +2453,16 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout) {
|
||||
throw new Error("null itemId");
|
||||
}
|
||||
|
||||
if (self.isWebSocketOpen()) {
|
||||
|
||||
var deferred = $.Deferred();
|
||||
|
||||
self.sendWebSocketMessage("PlaybackStopped", itemId + "|" + (positionTicks == null ? "" : positionTicks));
|
||||
|
||||
deferred.resolveWith(null, []);
|
||||
return deferred.promise();
|
||||
}
|
||||
|
||||
var params = {
|
||||
};
|
||||
|
||||
|
@ -40,6 +40,10 @@
|
||||
|
||||
$(".autoNumeric").autoNumeric('init');
|
||||
|
||||
if (ApiClient.isWebSocketOpen()) {
|
||||
ApiClient.sendWebSocketMessage("Context", [item.Type, item.Id, context].join('|'));
|
||||
}
|
||||
|
||||
Dashboard.hideLoadingMsg();
|
||||
});
|
||||
}
|
||||
|
@ -59,6 +59,19 @@
|
||||
renderDetails(page, item);
|
||||
renderTabs(page, item);
|
||||
|
||||
if (ApiClient.isWebSocketOpen()) {
|
||||
|
||||
var vals = [item.Type, item.Name];
|
||||
|
||||
var context = getParameterByName('context');
|
||||
|
||||
if (context) {
|
||||
vals.push(vals);
|
||||
}
|
||||
|
||||
ApiClient.sendWebSocketMessage("Context", vals.join('|'));
|
||||
}
|
||||
|
||||
Dashboard.hideLoadingMsg();
|
||||
});
|
||||
}
|
||||
|
@ -76,7 +76,13 @@
|
||||
}
|
||||
|
||||
$('#itemName', page).html(name);
|
||||
|
||||
Dashboard.setPageTitle(name);
|
||||
|
||||
if (ApiClient.isWebSocketOpen()) {
|
||||
ApiClient.sendWebSocketMessage("Context", [item.Type, item.Id].join('|'));
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
Dashboard.getCurrentUser().done(function (user) {
|
||||
|
@ -264,6 +264,8 @@
|
||||
|
||||
ApiClient.reportPlaybackStart(Dashboard.getCurrentUserId(), itemId);
|
||||
|
||||
var intervalTime = ApiClient.isWebSocketOpen() ? 10000 : 30000;
|
||||
|
||||
currentProgressInterval = setInterval(function () {
|
||||
var player = _V_("videoWindow");
|
||||
|
||||
@ -276,7 +278,8 @@
|
||||
var positionTicks = parseInt(startTime) + Math.floor(10000000 * player.currentTime());
|
||||
|
||||
ApiClient.reportPlaybackProgress(Dashboard.getCurrentUserId(), itemId, positionTicks);
|
||||
}, 30000);
|
||||
|
||||
}, intervalTime);
|
||||
}
|
||||
|
||||
self.canPlay = function (item) {
|
||||
|
@ -17,7 +17,7 @@
|
||||
});
|
||||
|
||||
if ($.browser.msie) {
|
||||
|
||||
|
||||
// This is unfortuantely required due to IE's over-aggressive caching.
|
||||
// https://github.com/MediaBrowser/MediaBrowser/issues/179
|
||||
$.ajaxSetup({
|
||||
@ -734,7 +734,7 @@ var Dashboard = {
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
|
||||
ensureToolsMenu: function (page) {
|
||||
|
||||
if (!page.hasClass('type-interior')) {
|
||||
@ -886,6 +886,53 @@ var Dashboard = {
|
||||
|
||||
Dashboard.showTaskCompletionNotification(msg.Data);
|
||||
}
|
||||
else if (msg.MessageType === "Browse") {
|
||||
|
||||
Dashboard.onBrowseCommand(msg.Data);
|
||||
}
|
||||
else if (msg.MessageType === "Play") {
|
||||
|
||||
|
||||
|
||||
}
|
||||
else if (msg.MessageType === "UpdatePlaystate") {
|
||||
|
||||
// TODO for Craig
|
||||
}
|
||||
},
|
||||
|
||||
onBrowseCommand: function (cmd) {
|
||||
|
||||
var context = cmd.Context || "";
|
||||
|
||||
var url;
|
||||
|
||||
var type = cmd.ItemType.toLowerCase();
|
||||
|
||||
if (type == "genre") {
|
||||
url = "itembynamedetails.html?genre=" + ApiClient.encodeName(cmd.ItemIdentifier) + "&context=" + context;
|
||||
}
|
||||
else if (type == "studio") {
|
||||
url = "itembynamedetails.html?studio=" + ApiClient.encodeName(cmd.ItemIdentifier) + "&context=" + context;
|
||||
}
|
||||
else if (type == "person") {
|
||||
url = "itembynamedetails.html?person=" + ApiClient.encodeName(cmd.ItemIdentifier) + "&context=" + context;
|
||||
}
|
||||
else if (type == "artist") {
|
||||
url = "itembynamedetails.html?artist=" + ApiClient.encodeName(cmd.ItemIdentifier) + "&context=" + (context || "music");
|
||||
}
|
||||
|
||||
if (url) {
|
||||
Dashboard.navigate(url);
|
||||
return;
|
||||
}
|
||||
|
||||
ApiClient.getItem(Dashboard.getCurrentUserId(), cmd.ItemIdentifier).done(function (item) {
|
||||
|
||||
Dashboard.navigate(LibraryBrowser.getHref(item, context));
|
||||
|
||||
});
|
||||
|
||||
},
|
||||
|
||||
showTaskCompletionNotification: function (result) {
|
||||
@ -983,7 +1030,7 @@ var Dashboard = {
|
||||
clearTimeout(Dashboard.newItemTimeout);
|
||||
}
|
||||
|
||||
Dashboard.newItemTimeout = setTimeout(function() {
|
||||
Dashboard.newItemTimeout = setTimeout(function () {
|
||||
|
||||
Dashboard.onNewItemTimerStopped(data);
|
||||
|
||||
@ -993,7 +1040,7 @@ var Dashboard = {
|
||||
onNewItemTimerStopped: function (data) {
|
||||
|
||||
var newItems = data.ItemsAdded;
|
||||
|
||||
|
||||
if (!newItems.length) {
|
||||
return;
|
||||
}
|
||||
@ -1129,7 +1176,7 @@ $(document).on('pageinit', ".page", function () {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}).on('pagebeforeshow', ".page", function () {
|
||||
|
||||
Dashboard.refreshSystemInfoFromServer();
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="MediaBrowser.ApiClient.Javascript" version="3.0.101" targetFramework="net45" />
|
||||
<package id="MediaBrowser.ApiClient.Javascript" version="3.0.104" targetFramework="net45" />
|
||||
<package id="ServiceStack.Common" version="3.9.44" targetFramework="net45" />
|
||||
<package id="ServiceStack.Text" version="3.9.44" targetFramework="net45" />
|
||||
</packages>
|
Loading…
Reference in New Issue
Block a user