mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
Merge pull request #4843 from nielsvanvelzen/nvv-cc-from-user-config
Use cast receiver application from user configuration
This commit is contained in:
commit
d7ccd24094
4 changed files with 42 additions and 40 deletions
|
@ -10,6 +10,7 @@ import '../../elements/emby-checkbox/emby-checkbox';
|
||||||
import ServerConnections from '../ServerConnections';
|
import ServerConnections from '../ServerConnections';
|
||||||
import toast from '../toast/toast';
|
import toast from '../toast/toast';
|
||||||
import template from './playbackSettings.template.html';
|
import template from './playbackSettings.template.html';
|
||||||
|
import escapeHTML from 'escape-html';
|
||||||
|
|
||||||
function fillSkipLengths(select) {
|
function fillSkipLengths(select) {
|
||||||
const options = [5, 10, 15, 20, 25, 30];
|
const options = [5, 10, 15, 20, 25, 30];
|
||||||
|
@ -136,7 +137,7 @@ function showHideQualityFields(context, user, apiClient) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadForm(context, user, userSettings, apiClient) {
|
function loadForm(context, user, userSettings, systemInfo, apiClient) {
|
||||||
const loggedInUserId = apiClient.getCurrentUserId();
|
const loggedInUserId = apiClient.getCurrentUserId();
|
||||||
const userId = user.Id;
|
const userId = user.Id;
|
||||||
|
|
||||||
|
@ -186,7 +187,12 @@ function loadForm(context, user, userSettings, apiClient) {
|
||||||
fillChromecastQuality(context.querySelector('.selectChromecastVideoQuality'));
|
fillChromecastQuality(context.querySelector('.selectChromecastVideoQuality'));
|
||||||
|
|
||||||
const selectChromecastVersion = context.querySelector('.selectChromecastVersion');
|
const selectChromecastVersion = context.querySelector('.selectChromecastVersion');
|
||||||
selectChromecastVersion.value = userSettings.chromecastVersion();
|
let ccAppsHtml = '';
|
||||||
|
for (const app of systemInfo.CastReceiverApplications) {
|
||||||
|
ccAppsHtml += `<option value='${escapeHTML(app.Id)}'>${escapeHTML(app.Name)}</option>`;
|
||||||
|
}
|
||||||
|
selectChromecastVersion.innerHTML = ccAppsHtml;
|
||||||
|
selectChromecastVersion.value = user.Configuration.CastReceiverId;
|
||||||
|
|
||||||
const selectLabelMaxVideoWidth = context.querySelector('.selectLabelMaxVideoWidth');
|
const selectLabelMaxVideoWidth = context.querySelector('.selectLabelMaxVideoWidth');
|
||||||
selectLabelMaxVideoWidth.value = appSettings.maxVideoWidth();
|
selectLabelMaxVideoWidth.value = appSettings.maxVideoWidth();
|
||||||
|
@ -222,7 +228,7 @@ function saveUser(context, user, userSettingsInstance, apiClient) {
|
||||||
userSettingsInstance.enableNextVideoInfoOverlay(context.querySelector('.chkEnableNextVideoOverlay').checked);
|
userSettingsInstance.enableNextVideoInfoOverlay(context.querySelector('.chkEnableNextVideoOverlay').checked);
|
||||||
user.Configuration.RememberAudioSelections = context.querySelector('.chkRememberAudioSelections').checked;
|
user.Configuration.RememberAudioSelections = context.querySelector('.chkRememberAudioSelections').checked;
|
||||||
user.Configuration.RememberSubtitleSelections = context.querySelector('.chkRememberSubtitleSelections').checked;
|
user.Configuration.RememberSubtitleSelections = context.querySelector('.chkRememberSubtitleSelections').checked;
|
||||||
userSettingsInstance.chromecastVersion(context.querySelector('.selectChromecastVersion').value);
|
user.Configuration.CastReceiverId = context.querySelector('.selectChromecastVersion').value;
|
||||||
userSettingsInstance.skipForwardLength(context.querySelector('.selectSkipForwardLength').value);
|
userSettingsInstance.skipForwardLength(context.querySelector('.selectSkipForwardLength').value);
|
||||||
userSettingsInstance.skipBackLength(context.querySelector('.selectSkipBackLength').value);
|
userSettingsInstance.skipBackLength(context.querySelector('.selectSkipBackLength').value);
|
||||||
|
|
||||||
|
@ -329,10 +335,12 @@ class PlaybackSettings {
|
||||||
const userSettings = self.options.userSettings;
|
const userSettings = self.options.userSettings;
|
||||||
|
|
||||||
apiClient.getUser(userId).then(user => {
|
apiClient.getUser(userId).then(user => {
|
||||||
userSettings.setUserInfo(userId, apiClient).then(() => {
|
apiClient.getSystemInfo().then(systemInfo => {
|
||||||
self.dataLoaded = true;
|
userSettings.setUserInfo(userId, apiClient).then(() => {
|
||||||
|
self.dataLoaded = true;
|
||||||
|
|
||||||
loadForm(context, user, userSettings, apiClient);
|
loadForm(context, user, userSettings, systemInfo, apiClient);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -139,10 +139,7 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="selectContainer">
|
<div class="selectContainer">
|
||||||
<select is="emby-select" class="selectChromecastVersion" label="${LabelChromecastVersion}">
|
<select is="emby-select" class="selectChromecastVersion" label="${LabelChromecastVersion}"></select>
|
||||||
<option value="stable">${LabelStable}</option>
|
|
||||||
<option value="unstable">${LabelUnstable}</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="selectContainer">
|
<div class="selectContainer">
|
||||||
|
|
|
@ -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() {
|
||||||
|
|
|
@ -338,19 +338,6 @@ export class UserSettings {
|
||||||
return this.get('datetimelocale', false);
|
return this.get('datetimelocale', false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get or set Chromecast version.
|
|
||||||
* @param {string|undefined} val - Chromecast version.
|
|
||||||
* @return {string} Chromecast version.
|
|
||||||
*/
|
|
||||||
chromecastVersion(val) {
|
|
||||||
if (val !== undefined) {
|
|
||||||
return this.set('chromecastVersion', val.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
return this.get('chromecastVersion') || 'stable';
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get or set amount of rewind.
|
* Get or set amount of rewind.
|
||||||
* @param {number|undefined} val - Amount of rewind.
|
* @param {number|undefined} val - Amount of rewind.
|
||||||
|
@ -663,7 +650,6 @@ export const detailsBanner = currentSettings.detailsBanner.bind(currentSettings)
|
||||||
export const useEpisodeImagesInNextUpAndResume = currentSettings.useEpisodeImagesInNextUpAndResume.bind(currentSettings);
|
export const useEpisodeImagesInNextUpAndResume = currentSettings.useEpisodeImagesInNextUpAndResume.bind(currentSettings);
|
||||||
export const language = currentSettings.language.bind(currentSettings);
|
export const language = currentSettings.language.bind(currentSettings);
|
||||||
export const dateTimeLocale = currentSettings.dateTimeLocale.bind(currentSettings);
|
export const dateTimeLocale = currentSettings.dateTimeLocale.bind(currentSettings);
|
||||||
export const chromecastVersion = currentSettings.chromecastVersion.bind(currentSettings);
|
|
||||||
export const skipBackLength = currentSettings.skipBackLength.bind(currentSettings);
|
export const skipBackLength = currentSettings.skipBackLength.bind(currentSettings);
|
||||||
export const skipForwardLength = currentSettings.skipForwardLength.bind(currentSettings);
|
export const skipForwardLength = currentSettings.skipForwardLength.bind(currentSettings);
|
||||||
export const dashboardTheme = currentSettings.dashboardTheme.bind(currentSettings);
|
export const dashboardTheme = currentSettings.dashboardTheme.bind(currentSettings);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue