2020-08-14 08:46:34 +02:00
|
|
|
import appSettings from '../../scripts/settings/appSettings';
|
2020-08-16 20:24:45 +02:00
|
|
|
import { appHost } from '../apphost';
|
2020-08-14 08:46:34 +02:00
|
|
|
import focusManager from '../focusManager';
|
|
|
|
import qualityoptions from '../qualityOptions';
|
2024-08-14 13:31:34 -04:00
|
|
|
import globalize from '../../lib/globalize';
|
2020-08-14 08:46:34 +02:00
|
|
|
import loading from '../loading/loading';
|
2022-10-14 10:53:16 -04:00
|
|
|
import Events from '../../utils/events.ts';
|
2020-08-14 08:46:34 +02:00
|
|
|
import '../../elements/emby-select/emby-select';
|
|
|
|
import '../../elements/emby-checkbox/emby-checkbox';
|
2020-10-17 19:08:56 +01:00
|
|
|
import ServerConnections from '../ServerConnections';
|
2020-10-18 15:18:15 +01:00
|
|
|
import toast from '../toast/toast';
|
2020-11-25 00:17:24 -05:00
|
|
|
import template from './playbackSettings.template.html';
|
2023-10-15 11:36:35 +02:00
|
|
|
import escapeHTML from 'escape-html';
|
2020-06-21 04:56:48 +03:00
|
|
|
|
2023-04-19 01:56:05 -04:00
|
|
|
function fillSkipLengths(select) {
|
|
|
|
const options = [5, 10, 15, 20, 25, 30];
|
2018-10-23 01:05:09 +03:00
|
|
|
|
2023-04-19 01:56:05 -04:00
|
|
|
select.innerHTML = options.map(option => {
|
|
|
|
return {
|
|
|
|
name: globalize.translate('ValueSeconds', option),
|
|
|
|
value: option * 1000
|
|
|
|
};
|
|
|
|
}).map(o => {
|
|
|
|
return `<option value="${o.value}">${o.name}</option>`;
|
|
|
|
}).join('');
|
|
|
|
}
|
2019-01-10 15:39:37 +03:00
|
|
|
|
2023-04-19 01:56:05 -04:00
|
|
|
function populateLanguages(select, languages) {
|
|
|
|
let html = '';
|
2019-01-10 15:39:37 +03:00
|
|
|
|
2023-04-19 01:56:05 -04:00
|
|
|
html += `<option value=''>${globalize.translate('AnyLanguage')}</option>`;
|
2019-01-10 15:39:37 +03:00
|
|
|
|
2023-04-19 01:56:05 -04:00
|
|
|
for (let i = 0, length = languages.length; i < length; i++) {
|
|
|
|
const culture = languages[i];
|
2019-01-10 15:39:37 +03:00
|
|
|
|
2023-04-19 01:56:05 -04:00
|
|
|
html += `<option value='${culture.ThreeLetterISOLanguageName}'>${culture.DisplayName}</option>`;
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
|
|
|
|
2023-04-19 01:56:05 -04:00
|
|
|
select.innerHTML = html;
|
|
|
|
}
|
2019-01-10 15:39:37 +03:00
|
|
|
|
2023-04-19 01:56:05 -04:00
|
|
|
function fillQuality(select, isInNetwork, mediatype, maxVideoWidth) {
|
|
|
|
const options = mediatype === 'Audio' ? qualityoptions.getAudioQualityOptions({
|
2019-01-10 15:39:37 +03:00
|
|
|
|
2023-04-19 01:56:05 -04:00
|
|
|
currentMaxBitrate: appSettings.maxStreamingBitrate(isInNetwork, mediatype),
|
|
|
|
isAutomaticBitrateEnabled: appSettings.enableAutomaticBitrateDetection(isInNetwork, mediatype),
|
|
|
|
enableAuto: true
|
2019-01-10 15:39:37 +03:00
|
|
|
|
2023-04-19 01:56:05 -04:00
|
|
|
}) : qualityoptions.getVideoQualityOptions({
|
2022-06-20 10:01:01 -04:00
|
|
|
|
2023-04-19 01:56:05 -04:00
|
|
|
currentMaxBitrate: appSettings.maxStreamingBitrate(isInNetwork, mediatype),
|
|
|
|
isAutomaticBitrateEnabled: appSettings.enableAutomaticBitrateDetection(isInNetwork, mediatype),
|
|
|
|
enableAuto: true,
|
|
|
|
maxVideoWidth
|
2019-01-10 15:39:37 +03:00
|
|
|
|
2023-04-19 01:56:05 -04:00
|
|
|
});
|
2018-10-23 01:05:09 +03:00
|
|
|
|
2023-04-19 01:56:05 -04:00
|
|
|
select.innerHTML = options.map(i => {
|
|
|
|
// render empty string instead of 0 for the auto option
|
|
|
|
return `<option value="${i.bitrate || ''}">${i.name}</option>`;
|
|
|
|
}).join('');
|
|
|
|
}
|
2019-01-10 15:39:37 +03:00
|
|
|
|
2023-04-19 01:56:05 -04:00
|
|
|
function setMaxBitrateIntoField(select, isInNetwork, mediatype) {
|
|
|
|
fillQuality(select, isInNetwork, mediatype);
|
2019-01-10 15:39:37 +03:00
|
|
|
|
2023-04-19 01:56:05 -04:00
|
|
|
if (appSettings.enableAutomaticBitrateDetection(isInNetwork, mediatype)) {
|
|
|
|
select.value = '';
|
|
|
|
} else {
|
|
|
|
select.value = appSettings.maxStreamingBitrate(isInNetwork, mediatype);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function fillChromecastQuality(select, maxVideoWidth) {
|
|
|
|
const options = qualityoptions.getVideoQualityOptions({
|
|
|
|
|
|
|
|
currentMaxBitrate: appSettings.maxChromecastBitrate(),
|
|
|
|
isAutomaticBitrateEnabled: !appSettings.maxChromecastBitrate(),
|
|
|
|
enableAuto: true,
|
|
|
|
maxVideoWidth
|
|
|
|
});
|
|
|
|
|
|
|
|
select.innerHTML = options.map(i => {
|
|
|
|
// render empty string instead of 0 for the auto option
|
|
|
|
return `<option value="${i.bitrate || ''}">${i.name}</option>`;
|
|
|
|
}).join('');
|
|
|
|
|
|
|
|
select.value = appSettings.maxChromecastBitrate() || '';
|
|
|
|
}
|
|
|
|
|
|
|
|
function setMaxBitrateFromField(select, isInNetwork, mediatype) {
|
|
|
|
if (select.value) {
|
|
|
|
appSettings.maxStreamingBitrate(isInNetwork, mediatype, select.value);
|
|
|
|
appSettings.enableAutomaticBitrateDetection(isInNetwork, mediatype, false);
|
|
|
|
} else {
|
|
|
|
appSettings.enableAutomaticBitrateDetection(isInNetwork, mediatype, true);
|
|
|
|
}
|
|
|
|
}
|
2019-01-10 15:39:37 +03:00
|
|
|
|
2023-04-19 01:56:05 -04:00
|
|
|
function showHideQualityFields(context, user, apiClient) {
|
|
|
|
if (user.Policy.EnableVideoPlaybackTranscoding) {
|
|
|
|
context.querySelector('.videoQualitySection').classList.remove('hide');
|
|
|
|
} else {
|
|
|
|
context.querySelector('.videoQualitySection').classList.add('hide');
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
|
|
|
|
2023-04-19 01:56:05 -04:00
|
|
|
if (appHost.supports('multiserver')) {
|
|
|
|
context.querySelector('.fldVideoInNetworkQuality').classList.remove('hide');
|
|
|
|
context.querySelector('.fldVideoInternetQuality').classList.remove('hide');
|
|
|
|
|
|
|
|
if (user.Policy.EnableAudioPlaybackTranscoding) {
|
|
|
|
context.querySelector('.musicQualitySection').classList.remove('hide');
|
2019-01-10 15:39:37 +03:00
|
|
|
} else {
|
2023-04-19 01:56:05 -04:00
|
|
|
context.querySelector('.musicQualitySection').classList.add('hide');
|
2019-01-10 15:39:37 +03:00
|
|
|
}
|
2023-04-19 01:56:05 -04:00
|
|
|
|
|
|
|
return;
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
|
|
|
|
2023-04-19 01:56:05 -04:00
|
|
|
apiClient.getEndpointInfo().then(endpointInfo => {
|
|
|
|
if (endpointInfo.IsInNetwork) {
|
|
|
|
context.querySelector('.fldVideoInNetworkQuality').classList.remove('hide');
|
|
|
|
|
|
|
|
context.querySelector('.fldVideoInternetQuality').classList.add('hide');
|
|
|
|
context.querySelector('.musicQualitySection').classList.add('hide');
|
2019-01-10 15:39:37 +03:00
|
|
|
} else {
|
2023-04-19 01:56:05 -04:00
|
|
|
context.querySelector('.fldVideoInNetworkQuality').classList.add('hide');
|
2019-01-10 15:39:37 +03:00
|
|
|
|
|
|
|
context.querySelector('.fldVideoInternetQuality').classList.remove('hide');
|
|
|
|
|
|
|
|
if (user.Policy.EnableAudioPlaybackTranscoding) {
|
|
|
|
context.querySelector('.musicQualitySection').classList.remove('hide');
|
|
|
|
} else {
|
|
|
|
context.querySelector('.musicQualitySection').classList.add('hide');
|
|
|
|
}
|
|
|
|
}
|
2023-04-19 01:56:05 -04:00
|
|
|
});
|
|
|
|
}
|
2019-01-10 15:39:37 +03:00
|
|
|
|
2023-10-15 11:36:35 +02:00
|
|
|
function loadForm(context, user, userSettings, systemInfo, apiClient) {
|
2023-04-19 01:56:05 -04:00
|
|
|
const loggedInUserId = apiClient.getCurrentUserId();
|
|
|
|
const userId = user.Id;
|
2018-10-23 01:05:09 +03:00
|
|
|
|
2023-04-19 01:56:05 -04:00
|
|
|
showHideQualityFields(context, user, apiClient);
|
2019-01-10 15:39:37 +03:00
|
|
|
|
2023-04-19 01:56:05 -04:00
|
|
|
context.querySelector('#selectAllowedAudioChannels').value = userSettings.allowedAudioChannels();
|
2019-01-10 15:39:37 +03:00
|
|
|
|
2023-04-19 01:56:05 -04:00
|
|
|
apiClient.getCultures().then(allCultures => {
|
|
|
|
populateLanguages(context.querySelector('#selectAudioLanguage'), allCultures);
|
2020-11-12 20:03:38 +08:00
|
|
|
|
2023-04-19 01:56:05 -04:00
|
|
|
context.querySelector('#selectAudioLanguage', context).value = user.Configuration.AudioLanguagePreference || '';
|
|
|
|
context.querySelector('.chkEpisodeAutoPlay').checked = user.Configuration.EnableNextEpisodeAutoPlay || false;
|
|
|
|
});
|
2019-01-10 15:39:37 +03:00
|
|
|
|
2023-04-19 01:56:05 -04:00
|
|
|
if (appHost.supports('externalplayerintent') && userId === loggedInUserId) {
|
|
|
|
context.querySelector('.fldExternalPlayer').classList.remove('hide');
|
|
|
|
} else {
|
|
|
|
context.querySelector('.fldExternalPlayer').classList.add('hide');
|
|
|
|
}
|
2019-01-10 15:39:37 +03:00
|
|
|
|
2023-04-19 01:56:05 -04:00
|
|
|
if (userId === loggedInUserId && (user.Policy.EnableVideoPlaybackTranscoding || user.Policy.EnableAudioPlaybackTranscoding)) {
|
|
|
|
context.querySelector('.qualitySections').classList.remove('hide');
|
2019-01-10 15:39:37 +03:00
|
|
|
|
2023-04-19 01:56:05 -04:00
|
|
|
if (appHost.supports('chromecast') && user.Policy.EnableVideoPlaybackTranscoding) {
|
|
|
|
context.querySelector('.fldChromecastQuality').classList.remove('hide');
|
2019-01-10 15:39:37 +03:00
|
|
|
} else {
|
|
|
|
context.querySelector('.fldChromecastQuality').classList.add('hide');
|
|
|
|
}
|
2023-04-19 01:56:05 -04:00
|
|
|
} else {
|
|
|
|
context.querySelector('.qualitySections').classList.add('hide');
|
|
|
|
context.querySelector('.fldChromecastQuality').classList.add('hide');
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
|
|
|
|
2023-04-19 01:56:05 -04:00
|
|
|
context.querySelector('.chkPlayDefaultAudioTrack').checked = user.Configuration.PlayDefaultAudioTrack || false;
|
|
|
|
context.querySelector('.chkPreferFmp4HlsContainer').checked = userSettings.preferFmp4HlsContainer();
|
2024-04-15 20:26:12 +03:00
|
|
|
context.querySelector('.chkEnableDts').checked = appSettings.enableDts();
|
2024-04-15 22:20:47 +03:00
|
|
|
context.querySelector('.chkEnableTrueHd').checked = appSettings.enableTrueHd();
|
2023-04-19 01:56:05 -04:00
|
|
|
context.querySelector('.chkEnableCinemaMode').checked = userSettings.enableCinemaMode();
|
2023-08-04 18:20:09 +01:00
|
|
|
context.querySelector('#selectAudioNormalization').value = userSettings.selectAudioNormalization();
|
2023-04-19 01:56:05 -04:00
|
|
|
context.querySelector('.chkEnableNextVideoOverlay').checked = userSettings.enableNextVideoInfoOverlay();
|
|
|
|
context.querySelector('.chkRememberAudioSelections').checked = user.Configuration.RememberAudioSelections || false;
|
|
|
|
context.querySelector('.chkRememberSubtitleSelections').checked = user.Configuration.RememberSubtitleSelections || false;
|
|
|
|
context.querySelector('.chkExternalVideoPlayer').checked = appSettings.enableSystemExternalPlayers();
|
2024-03-24 23:23:28 +03:00
|
|
|
context.querySelector('.chkLimitSupportedVideoResolution').checked = appSettings.limitSupportedVideoResolution();
|
2024-05-29 12:14:19 +02:00
|
|
|
context.querySelector('#selectPreferredTranscodeVideoCodec').value = appSettings.preferredTranscodeVideoCodec();
|
2024-05-18 13:19:56 +08:00
|
|
|
context.querySelector('#selectPreferredTranscodeVideoAudioCodec').value = appSettings.preferredTranscodeVideoAudioCodec();
|
2019-01-10 15:39:37 +03:00
|
|
|
|
2023-04-19 01:56:05 -04:00
|
|
|
setMaxBitrateIntoField(context.querySelector('.selectVideoInNetworkQuality'), true, 'Video');
|
|
|
|
setMaxBitrateIntoField(context.querySelector('.selectVideoInternetQuality'), false, 'Video');
|
|
|
|
setMaxBitrateIntoField(context.querySelector('.selectMusicInternetQuality'), false, 'Audio');
|
2019-01-10 15:39:37 +03:00
|
|
|
|
2023-04-19 01:56:05 -04:00
|
|
|
fillChromecastQuality(context.querySelector('.selectChromecastVideoQuality'));
|
2019-01-10 15:39:37 +03:00
|
|
|
|
2023-04-19 01:56:05 -04:00
|
|
|
const selectChromecastVersion = context.querySelector('.selectChromecastVersion');
|
2023-10-15 11:36:35 +02:00
|
|
|
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;
|
2020-05-17 00:36:10 +09:00
|
|
|
|
2024-03-24 23:02:18 +03:00
|
|
|
const selectMaxVideoWidth = context.querySelector('.selectMaxVideoWidth');
|
|
|
|
selectMaxVideoWidth.value = appSettings.maxVideoWidth();
|
2022-06-20 10:01:01 -04:00
|
|
|
|
2023-04-19 01:56:05 -04:00
|
|
|
const selectSkipForwardLength = context.querySelector('.selectSkipForwardLength');
|
|
|
|
fillSkipLengths(selectSkipForwardLength);
|
|
|
|
selectSkipForwardLength.value = userSettings.skipForwardLength();
|
2019-01-10 15:39:37 +03:00
|
|
|
|
2023-04-19 01:56:05 -04:00
|
|
|
const selectSkipBackLength = context.querySelector('.selectSkipBackLength');
|
|
|
|
fillSkipLengths(selectSkipBackLength);
|
|
|
|
selectSkipBackLength.value = userSettings.skipBackLength();
|
2019-01-10 15:39:37 +03:00
|
|
|
|
2023-04-19 01:56:05 -04:00
|
|
|
loading.hide();
|
|
|
|
}
|
2018-10-23 01:05:09 +03:00
|
|
|
|
2023-04-19 01:56:05 -04:00
|
|
|
function saveUser(context, user, userSettingsInstance, apiClient) {
|
|
|
|
appSettings.enableSystemExternalPlayers(context.querySelector('.chkExternalVideoPlayer').checked);
|
2019-01-10 15:39:37 +03:00
|
|
|
|
2023-04-19 01:56:05 -04:00
|
|
|
appSettings.maxChromecastBitrate(context.querySelector('.selectChromecastVideoQuality').value);
|
2024-03-24 23:02:18 +03:00
|
|
|
appSettings.maxVideoWidth(context.querySelector('.selectMaxVideoWidth').value);
|
2024-03-24 23:23:28 +03:00
|
|
|
appSettings.limitSupportedVideoResolution(context.querySelector('.chkLimitSupportedVideoResolution').checked);
|
2024-05-29 12:14:19 +02:00
|
|
|
appSettings.preferredTranscodeVideoCodec(context.querySelector('#selectPreferredTranscodeVideoCodec').value);
|
2024-05-18 13:19:56 +08:00
|
|
|
appSettings.preferredTranscodeVideoAudioCodec(context.querySelector('#selectPreferredTranscodeVideoAudioCodec').value);
|
2019-01-10 15:39:37 +03:00
|
|
|
|
2024-04-15 20:26:12 +03:00
|
|
|
appSettings.enableDts(context.querySelector('.chkEnableDts').checked);
|
2024-04-15 22:20:47 +03:00
|
|
|
appSettings.enableTrueHd(context.querySelector('.chkEnableTrueHd').checked);
|
2024-04-15 20:26:12 +03:00
|
|
|
|
2023-04-19 01:56:05 -04:00
|
|
|
setMaxBitrateFromField(context.querySelector('.selectVideoInNetworkQuality'), true, 'Video');
|
|
|
|
setMaxBitrateFromField(context.querySelector('.selectVideoInternetQuality'), false, 'Video');
|
|
|
|
setMaxBitrateFromField(context.querySelector('.selectMusicInternetQuality'), false, 'Audio');
|
2019-01-10 15:39:37 +03:00
|
|
|
|
2023-04-19 01:56:05 -04:00
|
|
|
userSettingsInstance.allowedAudioChannels(context.querySelector('#selectAllowedAudioChannels').value);
|
|
|
|
user.Configuration.AudioLanguagePreference = context.querySelector('#selectAudioLanguage').value;
|
|
|
|
user.Configuration.PlayDefaultAudioTrack = context.querySelector('.chkPlayDefaultAudioTrack').checked;
|
|
|
|
user.Configuration.EnableNextEpisodeAutoPlay = context.querySelector('.chkEpisodeAutoPlay').checked;
|
|
|
|
userSettingsInstance.preferFmp4HlsContainer(context.querySelector('.chkPreferFmp4HlsContainer').checked);
|
|
|
|
userSettingsInstance.enableCinemaMode(context.querySelector('.chkEnableCinemaMode').checked);
|
2023-08-04 18:20:09 +01:00
|
|
|
userSettingsInstance.selectAudioNormalization(context.querySelector('#selectAudioNormalization').value);
|
2023-04-19 01:56:05 -04:00
|
|
|
userSettingsInstance.enableNextVideoInfoOverlay(context.querySelector('.chkEnableNextVideoOverlay').checked);
|
|
|
|
user.Configuration.RememberAudioSelections = context.querySelector('.chkRememberAudioSelections').checked;
|
|
|
|
user.Configuration.RememberSubtitleSelections = context.querySelector('.chkRememberSubtitleSelections').checked;
|
2023-10-15 11:36:35 +02:00
|
|
|
user.Configuration.CastReceiverId = context.querySelector('.selectChromecastVersion').value;
|
2023-04-19 01:56:05 -04:00
|
|
|
userSettingsInstance.skipForwardLength(context.querySelector('.selectSkipForwardLength').value);
|
|
|
|
userSettingsInstance.skipBackLength(context.querySelector('.selectSkipBackLength').value);
|
2019-01-10 15:39:37 +03:00
|
|
|
|
2023-04-19 01:56:05 -04:00
|
|
|
return apiClient.updateUserConfiguration(user.Id, user.Configuration);
|
|
|
|
}
|
2018-10-23 01:05:09 +03:00
|
|
|
|
2023-04-19 01:56:05 -04:00
|
|
|
function save(instance, context, userId, userSettings, apiClient, enableSaveConfirmation) {
|
|
|
|
loading.show();
|
2019-01-10 15:39:37 +03:00
|
|
|
|
2023-04-19 01:56:05 -04:00
|
|
|
apiClient.getUser(userId).then(user => {
|
|
|
|
saveUser(context, user, userSettings, apiClient).then(() => {
|
|
|
|
loading.hide();
|
|
|
|
if (enableSaveConfirmation) {
|
|
|
|
toast(globalize.translate('SettingsSaved'));
|
|
|
|
}
|
2019-01-10 15:39:37 +03:00
|
|
|
|
2023-04-19 01:56:05 -04:00
|
|
|
Events.trigger(instance, 'saved');
|
|
|
|
}, () => {
|
|
|
|
loading.hide();
|
2019-01-10 15:39:37 +03:00
|
|
|
});
|
2023-04-19 01:56:05 -04:00
|
|
|
});
|
|
|
|
}
|
2018-10-23 01:05:09 +03:00
|
|
|
|
2023-04-19 01:56:05 -04:00
|
|
|
function setSelectValue(select, value, defaultValue) {
|
|
|
|
select.value = value;
|
2022-06-20 10:01:01 -04:00
|
|
|
|
2023-04-19 01:56:05 -04:00
|
|
|
if (select.selectedIndex < 0) {
|
|
|
|
select.value = defaultValue;
|
2022-06-20 10:01:01 -04:00
|
|
|
}
|
2023-04-19 01:56:05 -04:00
|
|
|
}
|
2022-06-20 10:01:01 -04:00
|
|
|
|
2023-04-19 01:56:05 -04:00
|
|
|
function onMaxVideoWidthChange(e) {
|
|
|
|
const context = this.options.element;
|
2022-06-20 10:01:01 -04:00
|
|
|
|
2023-04-19 01:56:05 -04:00
|
|
|
const selectVideoInNetworkQuality = context.querySelector('.selectVideoInNetworkQuality');
|
|
|
|
const selectVideoInternetQuality = context.querySelector('.selectVideoInternetQuality');
|
|
|
|
const selectChromecastVideoQuality = context.querySelector('.selectChromecastVideoQuality');
|
2022-06-20 10:01:01 -04:00
|
|
|
|
2023-04-19 01:56:05 -04:00
|
|
|
const selectVideoInNetworkQualityValue = selectVideoInNetworkQuality.value;
|
|
|
|
const selectVideoInternetQualityValue = selectVideoInternetQuality.value;
|
|
|
|
const selectChromecastVideoQualityValue = selectChromecastVideoQuality.value;
|
2022-06-20 10:01:01 -04:00
|
|
|
|
2023-04-19 01:56:05 -04:00
|
|
|
const maxVideoWidth = parseInt(e.target.value || '0', 10) || 0;
|
2022-06-20 10:01:01 -04:00
|
|
|
|
2023-04-19 01:56:05 -04:00
|
|
|
fillQuality(selectVideoInNetworkQuality, true, 'Video', maxVideoWidth);
|
|
|
|
fillQuality(selectVideoInternetQuality, false, 'Video', maxVideoWidth);
|
|
|
|
fillChromecastQuality(selectChromecastVideoQuality, maxVideoWidth);
|
2022-06-20 10:01:01 -04:00
|
|
|
|
2023-04-19 01:56:05 -04:00
|
|
|
setSelectValue(selectVideoInNetworkQuality, selectVideoInNetworkQualityValue, '');
|
|
|
|
setSelectValue(selectVideoInternetQuality, selectVideoInternetQualityValue, '');
|
|
|
|
setSelectValue(selectChromecastVideoQuality, selectChromecastVideoQualityValue, '');
|
|
|
|
}
|
2022-06-20 10:01:01 -04:00
|
|
|
|
2023-04-19 01:56:05 -04:00
|
|
|
function onSubmit(e) {
|
|
|
|
const self = this;
|
|
|
|
const apiClient = ServerConnections.getApiClient(self.options.serverId);
|
|
|
|
const userId = self.options.userId;
|
|
|
|
const userSettings = self.options.userSettings;
|
2019-01-10 15:39:37 +03:00
|
|
|
|
2023-04-19 01:56:05 -04:00
|
|
|
userSettings.setUserInfo(userId, apiClient).then(() => {
|
|
|
|
const enableSaveConfirmation = self.options.enableSaveConfirmation;
|
|
|
|
save(self, self.options.element, userId, userSettings, apiClient, enableSaveConfirmation);
|
|
|
|
});
|
2019-01-10 15:39:37 +03:00
|
|
|
|
2023-04-19 01:56:05 -04:00
|
|
|
// Disable default form submission
|
|
|
|
if (e) {
|
|
|
|
e.preventDefault();
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
2023-04-19 01:56:05 -04:00
|
|
|
return false;
|
|
|
|
}
|
2018-10-23 01:05:09 +03:00
|
|
|
|
2023-04-19 01:56:05 -04:00
|
|
|
function embed(options, self) {
|
|
|
|
options.element.innerHTML = globalize.translateHtml(template, 'core');
|
2019-01-10 15:39:37 +03:00
|
|
|
|
2023-04-19 01:56:05 -04:00
|
|
|
options.element.querySelector('form').addEventListener('submit', onSubmit.bind(self));
|
2019-01-10 15:39:37 +03:00
|
|
|
|
2023-04-19 01:56:05 -04:00
|
|
|
if (options.enableSaveButton) {
|
|
|
|
options.element.querySelector('.btnSave').classList.remove('hide');
|
|
|
|
}
|
2019-01-10 15:39:37 +03:00
|
|
|
|
2024-03-24 23:02:18 +03:00
|
|
|
options.element.querySelector('.selectMaxVideoWidth').addEventListener('change', onMaxVideoWidthChange.bind(self));
|
2022-06-20 10:01:01 -04:00
|
|
|
|
2023-04-19 01:56:05 -04:00
|
|
|
self.loadData();
|
2019-01-10 15:39:37 +03:00
|
|
|
|
2023-04-19 01:56:05 -04:00
|
|
|
if (options.autoFocus) {
|
|
|
|
focusManager.autoFocus(options.element);
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
2023-04-19 01:56:05 -04:00
|
|
|
}
|
2018-10-23 01:05:09 +03:00
|
|
|
|
2023-04-19 01:56:05 -04:00
|
|
|
class PlaybackSettings {
|
|
|
|
constructor(options) {
|
|
|
|
this.options = options;
|
|
|
|
embed(options, this);
|
|
|
|
}
|
2019-01-10 15:39:37 +03:00
|
|
|
|
2023-04-19 01:56:05 -04:00
|
|
|
loadData() {
|
|
|
|
const self = this;
|
|
|
|
const context = self.options.element;
|
2019-01-10 15:39:37 +03:00
|
|
|
|
2023-04-19 01:56:05 -04:00
|
|
|
loading.show();
|
2019-01-10 15:39:37 +03:00
|
|
|
|
2023-04-19 01:56:05 -04:00
|
|
|
const userId = self.options.userId;
|
|
|
|
const apiClient = ServerConnections.getApiClient(self.options.serverId);
|
|
|
|
const userSettings = self.options.userSettings;
|
2019-01-10 15:39:37 +03:00
|
|
|
|
2023-04-19 01:56:05 -04:00
|
|
|
apiClient.getUser(userId).then(user => {
|
2023-10-15 11:36:35 +02:00
|
|
|
apiClient.getSystemInfo().then(systemInfo => {
|
|
|
|
userSettings.setUserInfo(userId, apiClient).then(() => {
|
|
|
|
self.dataLoaded = true;
|
2019-01-10 15:39:37 +03:00
|
|
|
|
2023-10-15 11:36:35 +02:00
|
|
|
loadForm(context, user, userSettings, systemInfo, apiClient);
|
|
|
|
});
|
2019-01-10 15:39:37 +03:00
|
|
|
});
|
2023-04-19 01:56:05 -04:00
|
|
|
});
|
|
|
|
}
|
2019-01-10 15:39:37 +03:00
|
|
|
|
2023-04-19 01:56:05 -04:00
|
|
|
submit() {
|
|
|
|
onSubmit.call(this);
|
|
|
|
}
|
2019-01-10 15:39:37 +03:00
|
|
|
|
2023-04-19 01:56:05 -04:00
|
|
|
destroy() {
|
|
|
|
this.options = null;
|
2020-06-21 04:56:48 +03:00
|
|
|
}
|
2023-04-19 01:56:05 -04:00
|
|
|
}
|
2019-01-10 15:39:37 +03:00
|
|
|
|
2020-06-21 04:56:48 +03:00
|
|
|
export default PlaybackSettings;
|