mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
Use cast receiver application from user configuration
This commit is contained in:
parent
ae48e2a007
commit
7c9c38d682
1 changed files with 27 additions and 16 deletions
|
@ -58,11 +58,6 @@ const PLAYER_STATE = {
|
||||||
'ERROR': 'ERROR'
|
'ERROR': 'ERROR'
|
||||||
};
|
};
|
||||||
|
|
||||||
// production version registered with google
|
|
||||||
// replace this value if you want to test changes on another instance
|
|
||||||
const applicationStable = 'F007D354';
|
|
||||||
const applicationUnstable = '6F511C87';
|
|
||||||
|
|
||||||
const messageNamespace = 'urn:x-cast:com.connectsdk';
|
const messageNamespace = 'urn:x-cast:com.connectsdk';
|
||||||
|
|
||||||
class CastPlayer {
|
class CastPlayer {
|
||||||
|
@ -98,6 +93,7 @@ class CastPlayer {
|
||||||
initializeCastPlayer() {
|
initializeCastPlayer() {
|
||||||
const chrome = window.chrome;
|
const chrome = window.chrome;
|
||||||
if (!chrome) {
|
if (!chrome) {
|
||||||
|
console.warn('Not initializing chromecast: chrome object is missing');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,18 +102,25 @@ class CastPlayer {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let applicationID = userSettings.chromecastVersion();
|
const apiClient = ServerConnections.currentApiClient();
|
||||||
if (applicationID === 'stable') applicationID = applicationStable;
|
const userId = apiClient.getCurrentUserId();
|
||||||
if (applicationID === 'unstable') applicationID = applicationUnstable;
|
|
||||||
|
|
||||||
// request session
|
apiClient.getUser(userId).then(user => {
|
||||||
const sessionRequest = new chrome.cast.SessionRequest(applicationID);
|
const applicationID = user.Configuration.CastReceiverId;
|
||||||
const apiConfig = new chrome.cast.ApiConfig(sessionRequest,
|
if (!applicationID) {
|
||||||
this.sessionListener.bind(this),
|
console.warn(`Not initializing chromecast: CastReceiverId is ${applicationID}`);
|
||||||
this.receiverListener.bind(this));
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
console.debug(`chromecast.initialize (applicationId=${applicationID})`);
|
// request session
|
||||||
chrome.cast.initialize(apiConfig, this.onInitSuccess.bind(this), this.errorHandler);
|
const sessionRequest = new chrome.cast.SessionRequest(applicationID);
|
||||||
|
const apiConfig = new chrome.cast.ApiConfig(sessionRequest,
|
||||||
|
this.sessionListener.bind(this),
|
||||||
|
this.receiverListener.bind(this));
|
||||||
|
|
||||||
|
console.debug(`chromecast.initialize (applicationId=${applicationID})`);
|
||||||
|
chrome.cast.initialize(apiConfig, this.onInitSuccess.bind(this), this.errorHandler);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -584,7 +587,15 @@ class ChromecastPlayer {
|
||||||
this.isLocalPlayer = false;
|
this.isLocalPlayer = false;
|
||||||
this.lastPlayerData = {};
|
this.lastPlayerData = {};
|
||||||
|
|
||||||
new CastSenderApi().load().then(initializeChromecast.bind(this));
|
new CastSenderApi().load().then(() => {
|
||||||
|
Events.on(ServerConnections, 'localusersignedin', () => {
|
||||||
|
initializeChromecast.call(this);
|
||||||
|
});
|
||||||
|
|
||||||
|
if (ServerConnections.currentUserId) {
|
||||||
|
initializeChromecast.call(this);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
tryPair() {
|
tryPair() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue