mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
hls updates
This commit is contained in:
parent
bbdbdf346e
commit
9fc4c86111
19 changed files with 255 additions and 246 deletions
64
dashboard-ui/thirdparty/apiclient/apiclient.js
vendored
64
dashboard-ui/thirdparty/apiclient/apiclient.js
vendored
|
@ -7,7 +7,7 @@
|
|||
/**
|
||||
* Creates a new api client instance
|
||||
* @param {String} serverAddress
|
||||
* @param {String} clientName
|
||||
* @param {String} clientName s
|
||||
* @param {String} applicationVersion
|
||||
*/
|
||||
globalScope.MediaBrowser.ApiClient = function (logger, serverAddress, clientName, applicationVersion, deviceName, deviceId) {
|
||||
|
@ -23,10 +23,8 @@
|
|||
logger.log('ApiClient deviceId: ' + deviceId);
|
||||
|
||||
var self = this;
|
||||
var currentUserId;
|
||||
var accessToken;
|
||||
var webSocket;
|
||||
var serverInfo;
|
||||
var serverInfo = {};
|
||||
|
||||
self.enableAppStorePolicy = false;
|
||||
|
||||
|
@ -37,6 +35,10 @@
|
|||
|
||||
if (val != null) {
|
||||
|
||||
if (val.toLowerCase().indexOf('http') != 0) {
|
||||
throw new Error('Invalid url: ' + val);
|
||||
}
|
||||
|
||||
var changed = val != serverAddress;
|
||||
|
||||
serverAddress = val;
|
||||
|
@ -81,18 +83,11 @@
|
|||
*/
|
||||
self.getCurrentUserId = function () {
|
||||
|
||||
return currentUserId;
|
||||
return serverInfo.UserId;
|
||||
};
|
||||
|
||||
self.accessToken = function () {
|
||||
return accessToken;
|
||||
};
|
||||
|
||||
self.setCurrentUserId = function (userId, token) {
|
||||
|
||||
currentUserId = userId;
|
||||
currentUserPromise = null;
|
||||
accessToken = token;
|
||||
return serverInfo.AccessToken;
|
||||
};
|
||||
|
||||
self.deviceName = function () {
|
||||
|
@ -104,13 +99,14 @@
|
|||
};
|
||||
|
||||
self.clearAuthenticationInfo = function () {
|
||||
accessToken = null;
|
||||
currentUserId = null;
|
||||
self.setAuthenticationInfo(null, null);
|
||||
};
|
||||
|
||||
self.setAuthenticationInfo = function (accessKey, userId) {
|
||||
accessToken = accessKey;
|
||||
currentUserId = userId;
|
||||
currentUserPromise = null;
|
||||
|
||||
serverInfo.AccessToken = accessKey;
|
||||
serverInfo.UserId = userId;
|
||||
};
|
||||
|
||||
self.encodeName = function (name) {
|
||||
|
@ -156,8 +152,10 @@
|
|||
|
||||
var auth = 'MediaBrowser Client="' + clientName + '", Device="' + deviceName + '", DeviceId="' + deviceId + '", Version="' + applicationVersion + '"';
|
||||
|
||||
if (currentUserId) {
|
||||
auth += ', UserId="' + currentUserId + '"';
|
||||
var userId = serverInfo.UserId;
|
||||
|
||||
if (userId) {
|
||||
auth += ', UserId="' + userId + '"';
|
||||
}
|
||||
|
||||
request.headers = {
|
||||
|
@ -165,12 +163,14 @@
|
|||
};
|
||||
}
|
||||
|
||||
var accessToken = serverInfo.AccessToken;
|
||||
|
||||
if (accessToken) {
|
||||
request.headers['X-MediaBrowser-Token'] = accessToken;
|
||||
}
|
||||
}
|
||||
|
||||
if (!self.enableAutomaticNetwork || !self.serverInfo() || self.connectionMode == null) {
|
||||
if (!self.enableAutomaticNetwork || self.connectionMode == null) {
|
||||
logger.log('Requesting url without automatic networking: ' + request.url);
|
||||
return AjaxApi.ajax(request).fail(onRequestFail);
|
||||
}
|
||||
|
@ -332,6 +332,10 @@
|
|||
|
||||
var url = serverAddress;
|
||||
|
||||
if (!url) {
|
||||
throw new Error("serverAddress is yet not set");
|
||||
}
|
||||
|
||||
if (name.charAt(0) != '/') {
|
||||
url += '/';
|
||||
}
|
||||
|
@ -347,6 +351,18 @@
|
|||
|
||||
self.enableAutomaticNetworking = function (server, connectionMode, serverUrl) {
|
||||
|
||||
if (server == null) {
|
||||
throw new Error('server cannot be null');
|
||||
}
|
||||
|
||||
if (connectionMode == null) {
|
||||
throw new Error('connectionMode cannot be null');
|
||||
}
|
||||
|
||||
if (!serverUrl) {
|
||||
throw new Error('serverUrl cannot be null or empty');
|
||||
}
|
||||
|
||||
logger.log('Begin enableAutomaticNetworking');
|
||||
|
||||
self.serverInfo(server);
|
||||
|
@ -363,6 +379,8 @@
|
|||
|
||||
self.openWebSocket = function () {
|
||||
|
||||
var accessToken = serverInfo.AccessToken;
|
||||
|
||||
if (!accessToken) {
|
||||
throw new Error("Cannot open web socket without access token.");
|
||||
}
|
||||
|
@ -405,7 +423,7 @@
|
|||
};
|
||||
|
||||
function onWebSocketMessage(msg) {
|
||||
|
||||
|
||||
if (msg.MessageType === "UserDeleted") {
|
||||
currentUserPromise = null;
|
||||
}
|
||||
|
@ -557,10 +575,10 @@
|
|||
self.closeWebSocket();
|
||||
|
||||
var done = function () {
|
||||
self.setCurrentUserId(null, null);
|
||||
self.setAuthenticationInfo(null, null);
|
||||
};
|
||||
|
||||
if (accessToken) {
|
||||
if (serverInfo.AccessToken) {
|
||||
var url = self.getUrl("Sessions/Logout");
|
||||
|
||||
return self.ajax({
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
|
||||
var self = this;
|
||||
var apiClients = [];
|
||||
var defaultTimeout = 15000;
|
||||
|
||||
function mergeServers(list1, list2) {
|
||||
|
||||
|
@ -73,7 +74,7 @@
|
|||
url: url,
|
||||
dataType: "json",
|
||||
|
||||
timeout: timeout || 15000
|
||||
timeout: timeout || defaultTimeout
|
||||
|
||||
});
|
||||
}
|
||||
|
@ -100,10 +101,33 @@
|
|||
return credentialProvider.credentials().ConnectAccessToken;
|
||||
};
|
||||
|
||||
self.addApiClient = function (apiClient, enableAutomaticNetworking) {
|
||||
self.getLastUsedApiClient = function() {
|
||||
|
||||
var servers = credentialProvider.credentials().servers;
|
||||
|
||||
servers.sort(function (a, b) {
|
||||
return b.DateLastAccessed - a.DateLastAccessed;
|
||||
});
|
||||
|
||||
if (!servers.length) {
|
||||
return null;
|
||||
}
|
||||
|
||||
var server = servers[0];
|
||||
|
||||
return getOrAddApiClient(server, server.LastConnectionMode);
|
||||
};
|
||||
|
||||
self.addApiClient = function (apiClient) {
|
||||
|
||||
apiClients.push(apiClient);
|
||||
|
||||
Events.on(apiClient, 'authenticated', function (e, result) {
|
||||
onAuthenticated(this, result, {}, true);
|
||||
});
|
||||
|
||||
Events.trigger(self, 'apiclientcreated', [apiClient]);
|
||||
|
||||
return apiClient.getPublicSystemInfo().done(function (systemInfo) {
|
||||
|
||||
var server = credentialProvider.credentials().servers.filter(function (s) {
|
||||
|
@ -115,13 +139,7 @@
|
|||
updateServerInfo(server, systemInfo);
|
||||
|
||||
apiClient.serverInfo(server);
|
||||
Events.trigger(self, 'apiclientcreated', [apiClient]);
|
||||
|
||||
if (enableAutomaticNetworking) {
|
||||
self.connectToServer(server);
|
||||
}
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
function onConnectUserSignIn(user) {
|
||||
|
@ -151,7 +169,7 @@
|
|||
Events.trigger(self, 'apiclientcreated', [apiClient]);
|
||||
}
|
||||
|
||||
if (server.AccessToken) {
|
||||
if (server.AccessToken && server.UserId) {
|
||||
|
||||
apiClient.setAuthenticationInfo(server.AccessToken, server.UserId);
|
||||
}
|
||||
|
@ -799,7 +817,7 @@
|
|||
var address = self.getServerAddress(server, mode);
|
||||
var enableRetry = false;
|
||||
var skipTest = false;
|
||||
var timeout = 15000;
|
||||
var timeout = defaultTimeout;
|
||||
|
||||
if (mode == MediaBrowser.ConnectionMode.Local) {
|
||||
|
||||
|
@ -807,7 +825,7 @@
|
|||
skipTest = true;
|
||||
}
|
||||
enableRetry = true;
|
||||
timeout = 5000;
|
||||
timeout = 7000;
|
||||
}
|
||||
|
||||
else if (mode == MediaBrowser.ConnectionMode.Manual) {
|
||||
|
@ -924,7 +942,7 @@
|
|||
case MediaBrowser.ConnectionMode.Remote:
|
||||
return server.RemoteAddress;
|
||||
default:
|
||||
throw new Error("Unexpected ConnectionMode");
|
||||
return server.ManualAddress || server.LocalAddress || server.RemoteAddress;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -934,6 +952,10 @@
|
|||
address = "http://" + address;
|
||||
}
|
||||
|
||||
// Seeing failures in iOS when protocol isn't lowercase
|
||||
address = address.replace('Http:', 'http:');
|
||||
address = address.replace('Https:', 'https:');
|
||||
|
||||
return address;
|
||||
}
|
||||
|
||||
|
@ -953,7 +975,7 @@
|
|||
resolveWithFailure(deferred);
|
||||
}
|
||||
|
||||
tryConnect(address, 15000).done(function (publicInfo) {
|
||||
tryConnect(address, defaultTimeout).done(function (publicInfo) {
|
||||
|
||||
logger.log('connectToAddress ' + address + ' succeeded');
|
||||
|
||||
|
|
11
dashboard-ui/thirdparty/cordova/chromecast.js
vendored
11
dashboard-ui/thirdparty/cordova/chromecast.js
vendored
|
@ -580,10 +580,13 @@
|
|||
|
||||
$(MediaController).on('playerchange', function (e, newPlayer, newTarget) {
|
||||
|
||||
if (newPlayer.name != PlayerName || newTarget.id != currentPairedDeviceId) {
|
||||
if (currentWebAppSession) {
|
||||
currentWebAppSession.disconnect();
|
||||
onDisconnected();
|
||||
if (currentPairedDeviceId) {
|
||||
if (newTarget.id != currentPairedDeviceId) {
|
||||
if (currentWebAppSession) {
|
||||
console.log('Disconnecting from chromecast');
|
||||
currentWebAppSession.disconnect();
|
||||
onDisconnected();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
15
dashboard-ui/thirdparty/cordova/connectsdk.js
vendored
15
dashboard-ui/thirdparty/cordova/connectsdk.js
vendored
|
@ -1,16 +1,5 @@
|
|||
(function () {
|
||||
|
||||
|
||||
function onDeviceFound(e) {
|
||||
|
||||
console.log('device found');
|
||||
}
|
||||
|
||||
function onDeviceLost(e) {
|
||||
|
||||
console.log('device lost');
|
||||
}
|
||||
|
||||
function initSdk() {
|
||||
|
||||
var manager = ConnectSDK.discoveryManager;
|
||||
|
@ -23,9 +12,6 @@
|
|||
// new ConnectSDK.CapabilityFilter(["MediaPlayer.Display.Video", "MediaControl.Pause"])
|
||||
//]);
|
||||
|
||||
manager.addListener('devicefound', onDeviceFound);
|
||||
manager.addListener('devicelost', onDeviceLost);
|
||||
|
||||
manager.startDiscovery();
|
||||
|
||||
requirejs(['thirdparty/cordova/chromecast', 'thirdparty/cordova/generaldevice']);
|
||||
|
@ -33,5 +19,4 @@
|
|||
|
||||
Dashboard.ready(initSdk);
|
||||
|
||||
|
||||
})();
|
|
@ -481,6 +481,7 @@
|
|||
function onDisconnected(device) {
|
||||
|
||||
if (currentDevice && device.getId() == currentDevice.getId()) {
|
||||
currentDevice = null;
|
||||
MediaController.removeActiveTarget(device.getId());
|
||||
}
|
||||
}
|
||||
|
@ -552,6 +553,7 @@
|
|||
|
||||
if (currentDevice && newTarget.id != currentDevice.getId()) {
|
||||
MediaController.removeActiveTarget(currentDevice.getId());
|
||||
currentDevice = null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue