mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
fixes #898 - Google Cast Ready
This commit is contained in:
parent
9af2992260
commit
2a800129cb
4 changed files with 106 additions and 18 deletions
|
@ -1,6 +1,31 @@
|
|||
(function (window, chrome, console) {
|
||||
|
||||
// Based on https://github.com/googlecast/CastVideos-chrome/blob/master/CastVideos.js
|
||||
var currentResolve;
|
||||
var currentReject;
|
||||
|
||||
var PlayerName = 'Chromecast';
|
||||
|
||||
function sendConnectionResult(isOk) {
|
||||
|
||||
var resolve = currentResolve;
|
||||
var reject = currentReject;
|
||||
|
||||
currentResolve = null;
|
||||
currentReject = null;
|
||||
|
||||
if (isOk) {
|
||||
if (resolve) {
|
||||
resolve();
|
||||
}
|
||||
} else {
|
||||
if (reject) {
|
||||
reject();
|
||||
} else {
|
||||
MediaController.removeActivePlayer(PlayerName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Constants of states for Chromecast device
|
||||
|
@ -26,8 +51,6 @@
|
|||
'ERROR': 'ERROR'
|
||||
};
|
||||
|
||||
var PlayerName = 'Chromecast';
|
||||
|
||||
var applicationID = "2D4B1DA3";
|
||||
var messageNamespace = 'urn:x-cast:com.connectsdk';
|
||||
|
||||
|
@ -191,7 +214,7 @@
|
|||
console.log('sessionUpdateListener: setting currentMediaSession to null');
|
||||
this.currentMediaSession = null;
|
||||
|
||||
MediaController.removeActivePlayer(PlayerName);
|
||||
sendConnectionResult(false);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -257,7 +280,7 @@
|
|||
|
||||
//});
|
||||
|
||||
MediaController.removeActivePlayer(PlayerName);
|
||||
sendConnectionResult(false);
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -485,7 +508,11 @@
|
|||
|
||||
Events.on(castPlayer, "connect", function (e) {
|
||||
|
||||
MediaController.setActivePlayer(PlayerName, self.getCurrentTargetInfo());
|
||||
if (currentResolve) {
|
||||
sendConnectionResult(true);
|
||||
} else {
|
||||
MediaController.setActivePlayer(PlayerName, self.getCurrentTargetInfo());
|
||||
}
|
||||
|
||||
console.log('cc: connect');
|
||||
// Reset this so the next query doesn't make it appear like content is playing.
|
||||
|
@ -832,7 +859,19 @@
|
|||
self.tryPair = function (target) {
|
||||
|
||||
return new Promise(function (resolve, reject) {
|
||||
resolve();
|
||||
if (castPlayer.deviceState != DEVICE_STATE.ACTIVE && castPlayer.isInitialized) {
|
||||
|
||||
currentResolve = resolve;
|
||||
currentReject = reject;
|
||||
|
||||
castPlayer.launchApp();
|
||||
} else {
|
||||
|
||||
currentResolve = null;
|
||||
currentReject = null;
|
||||
|
||||
reject();
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
|
@ -842,14 +881,6 @@
|
|||
castPlayer = new CastPlayer();
|
||||
|
||||
MediaController.registerPlayer(new chromecastPlayer());
|
||||
|
||||
Events.on(MediaController, 'playerchange', function (e, newPlayer, newTarget) {
|
||||
if (newPlayer.name == PlayerName) {
|
||||
if (castPlayer.deviceState != DEVICE_STATE.ACTIVE && castPlayer.isInitialized) {
|
||||
castPlayer.launchApp();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
requirejs(["https://www.gstatic.com/cv/js/sender/v1/cast_sender.js"], initializeChromecast);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue