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

add sharing function

This commit is contained in:
Luke Pulverenti 2015-07-02 01:08:05 -04:00
parent 93ad16971d
commit 54afe9d0c2
22 changed files with 17346 additions and 17048 deletions

View file

@ -27,14 +27,14 @@
$(castPlayer).on("connect", function (e) {
console.log('cc: connect');
Logger.log('cc: connect');
// Reset this so the next query doesn't make it appear like content is playing.
self.lastPlayerData = {};
});
$(castPlayer).on("playbackstart", function (e, data) {
console.log('cc: playbackstart');
Logger.log('cc: playbackstart');
var state = self.getPlayerStateInternal(data);
$(self).trigger("playbackstart", [state]);
@ -42,7 +42,7 @@
$(castPlayer).on("playbackstop", function (e, data) {
console.log('cc: playbackstop');
Logger.log('cc: playbackstop');
var state = self.getPlayerStateInternal(data);
$(self).trigger("playbackstop", [state]);
@ -53,7 +53,7 @@
$(castPlayer).on("playbackprogress", function (e, data) {
console.log('cc: positionchange');
Logger.log('cc: positionchange');
var state = self.getPlayerStateInternal(data);
$(self).trigger("positionchange", [state]);
@ -418,7 +418,7 @@
data = data || self.lastPlayerData;
self.lastPlayerData = data;
console.log(JSON.stringify(data));
Logger.log(JSON.stringify(data));
return data;
};
@ -461,7 +461,7 @@
}
function handleSessionDisconnect() {
console.log("session disconnected");
Logger.log("session disconnected");
cleanupSession();
MediaController.removeActivePlayer(PlayerName);
@ -471,7 +471,7 @@
currentWebAppSession = webAppSession;
console.log('session.connect succeeded');
Logger.log('session.connect succeeded');
webAppSession.setWebAppSessionListener();
MediaController.setActivePlayer(PlayerName, convertDeviceToTarget(device));
@ -510,6 +510,7 @@
}
function handleSessionError() {
Logger.log('chromecast session connect error');
cleanupSession();
}
@ -532,40 +533,46 @@
function tryLaunchWebSession(device) {
console.log('calling launchWebApp');
Logger.log('calling launchWebApp');
device.getWebAppLauncher().launchWebApp(ApplicationID).success(function (session) {
console.log('launchWebApp success. calling onSessionConnected');
setupWebAppSession(device, session, true);
Logger.log('launchWebApp success. calling onSessionConnected');
if ($.browser.android) {
tryJoinWebSession(device, true, false);
} else {
setupWebAppSession(device, session, true);
}
}).error(function (err1) {
console.log('launchWebApp error:' + JSON.stringify(err1));
Logger.log('launchWebApp error:' + JSON.stringify(err1));
});
}
function tryJoinWebSession(device, enableRetry) {
function tryJoinWebSession(device, enableRetry, enableLaunch) {
// First try to join existing session. If it fails, launch a new one
console.log('calling joinWebApp');
Logger.log('calling joinWebApp');
device.getWebAppLauncher().joinWebApp(ApplicationID).success(function (session) {
console.log('joinWebApp success. calling onSessionConnected');
Logger.log('joinWebApp success. calling onSessionConnected');
setupWebAppSession(device, session, false);
}).error(function (err) {
console.log('joinWebApp error: ' + JSON.stringify(err));
Logger.log('joinWebApp error: ' + JSON.stringify(err));
if (enableRetry) {
tryJoinWebSession(device, false);
tryJoinWebSession(device, false, true);
return;
}
console.log('calling launchWebApp');
tryLaunchWebSession(device);
if (enableLaunch) {
Logger.log('calling launchWebApp');
tryLaunchWebSession(device);
}
});
}
@ -576,14 +583,14 @@
cleanupSession();
}
tryJoinWebSession(device, true);
tryJoinWebSession(device, true, true);
}
function onDeviceReady(device) {
device.off("ready");
console.log('creating webAppSession');
Logger.log('creating webAppSession');
launchWebApp(device);
}
@ -610,7 +617,7 @@
self.tryPairWithDevice = function (device, deferred) {
console.log('Will attempt to connect to Chromecast');
Logger.log('Will attempt to connect to Chromecast');
device.on("disconnect", function () {
device.off("ready");
@ -618,18 +625,18 @@
});
if (device.isReady()) {
console.log('Device is already ready, calling onDeviceReady');
Logger.log('Device is already ready, calling onDeviceReady');
onDeviceReady(device);
} else {
console.log('Binding device ready handler');
Logger.log('Binding device ready handler');
device.on("ready", function () {
console.log('device.ready fired');
Logger.log('device.ready fired');
onDeviceReady(device);
});
console.log('Calling device.connect');
Logger.log('Calling device.connect');
device.connect();
}
};