mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
update connection manager
This commit is contained in:
parent
6235ee51eb
commit
6cbc470b0e
14 changed files with 209 additions and 47 deletions
59
dashboard-ui/thirdparty/cordova/chromecast.js
vendored
59
dashboard-ui/thirdparty/cordova/chromecast.js
vendored
|
@ -468,11 +468,11 @@
|
|||
currentWebAppSession = session.acquire();
|
||||
|
||||
currentWebAppSession.on('message', handleMessage);
|
||||
currentWebAppSession.on('disconnect', handleSessionDisconnect);
|
||||
|
||||
currentWebAppSession.connect().success(function () {
|
||||
|
||||
console.log('session.connect succeeded');
|
||||
currentWebAppSession.on('disconnect', handleSessionDisconnect);
|
||||
|
||||
MediaController.setActivePlayer(PlayerName, convertDeviceToTarget(device));
|
||||
currentDeviceFriendlyName = device.getFriendlyName();
|
||||
|
@ -507,12 +507,57 @@
|
|||
session.release();
|
||||
}
|
||||
|
||||
if (currentDevice != null) {
|
||||
currentDevice.off("ready");
|
||||
currentDevice.off("disconnect");
|
||||
|
||||
currentDevice.disconnect();
|
||||
}
|
||||
|
||||
currentWebAppSession = null;
|
||||
currentPairedDeviceId = null;
|
||||
currentDeviceFriendlyName = null;
|
||||
currentDevice = null;
|
||||
}
|
||||
|
||||
function tryLaunchWebSession(device) {
|
||||
|
||||
console.log('calling launchWebApp');
|
||||
device.getWebAppLauncher().launchWebApp(ApplicationID).success(function (session) {
|
||||
|
||||
console.log('launchWebApp success. calling onSessionConnected');
|
||||
setupWebAppSession(device, session);
|
||||
|
||||
}).error(function (err1) {
|
||||
|
||||
console.log('launchWebApp error:' + JSON.stringify(err1));
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
function tryJoinWebSession(device, enableRetry) {
|
||||
|
||||
console.log('calling joinWebApp');
|
||||
device.getWebAppLauncher().joinWebApp(ApplicationID).success(function (session) {
|
||||
|
||||
console.log('joinWebApp success. calling onSessionConnected');
|
||||
setupWebAppSession(device, session);
|
||||
|
||||
}).error(function (err) {
|
||||
|
||||
console.log('joinWebApp error: ' + JSON.stringify(err));
|
||||
|
||||
if (enableRetry) {
|
||||
tryJoinWebSession(device, false);
|
||||
return;
|
||||
}
|
||||
|
||||
console.log('calling launchWebApp');
|
||||
tryLaunchWebSession(device);
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
function launchWebApp(device) {
|
||||
|
||||
// First try to join existing session. If it fails, launch a new one
|
||||
|
@ -524,7 +569,7 @@
|
|||
|
||||
}).error(function (err) {
|
||||
|
||||
console.log('joinWebApp error: ' + JSON.stringify(err) + '. calling joinWebApp');
|
||||
console.log('joinWebApp error: ' + JSON.stringify(err) + '. calling launchWebApp');
|
||||
|
||||
device.getWebAppLauncher().launchWebApp(ApplicationID).success(function (session) {
|
||||
|
||||
|
@ -547,13 +592,9 @@
|
|||
return;
|
||||
}
|
||||
|
||||
console.log('calling launchWebApp');
|
||||
console.log('creating webAppSession');
|
||||
|
||||
setTimeout(function () {
|
||||
|
||||
launchWebApp(device);
|
||||
|
||||
}, 0);
|
||||
launchWebApp(device);
|
||||
}
|
||||
|
||||
self.tryPair = function (target) {
|
||||
|
@ -610,7 +651,7 @@
|
|||
if (newTarget.id != currentPairedDeviceId) {
|
||||
if (currentWebAppSession) {
|
||||
console.log('Disconnecting from chromecast');
|
||||
currentWebAppSession.disconnect();
|
||||
cleanupSession();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue