From 6e6b696bd9dc7c71fb83f9dda2c3fa8eda35e31a Mon Sep 17 00:00:00 2001 From: Dmitry Lyzo Date: Sun, 24 Mar 2024 23:23:28 +0300 Subject: [PATCH] Add option to limit maximum supported video resolution --- src/components/apphost.js | 21 +++++++++++++------ .../playbackSettings/playbackSettings.js | 2 ++ .../playbackSettings.template.html | 8 +++++++ src/scripts/settings/appSettings.js | 13 ++++++++++++ src/strings/en-us.json | 2 ++ 5 files changed, 40 insertions(+), 6 deletions(-) diff --git a/src/components/apphost.js b/src/components/apphost.js index 8df5884bb1..742476195d 100644 --- a/src/components/apphost.js +++ b/src/components/apphost.js @@ -45,18 +45,27 @@ function getDeviceProfile(item) { const maxTranscodingVideoWidth = maxVideoWidth < 0 ? appHost.screen()?.maxAllowedWidth : maxVideoWidth; if (maxTranscodingVideoWidth) { + const conditionWidth = { + Condition: 'LessThanEqual', + Property: 'Width', + Value: maxTranscodingVideoWidth.toString(), + IsRequired: false + }; + + if (appSettings.limitSupportedVideoResolution()) { + profile.CodecProfiles.push({ + Type: 'Video', + Conditions: [conditionWidth] + }); + } + profile.TranscodingProfiles.forEach((transcodingProfile) => { if (transcodingProfile.Type === 'Video') { transcodingProfile.Conditions = (transcodingProfile.Conditions || []).filter((condition) => { return condition.Property !== 'Width'; }); - transcodingProfile.Conditions.push({ - Condition: 'LessThanEqual', - Property: 'Width', - Value: maxTranscodingVideoWidth.toString(), - IsRequired: false - }); + transcodingProfile.Conditions.push(conditionWidth); } }); } diff --git a/src/components/playbackSettings/playbackSettings.js b/src/components/playbackSettings/playbackSettings.js index 51e36d13aa..254389a9f6 100644 --- a/src/components/playbackSettings/playbackSettings.js +++ b/src/components/playbackSettings/playbackSettings.js @@ -179,6 +179,7 @@ function loadForm(context, user, userSettings, systemInfo, apiClient) { context.querySelector('.chkRememberAudioSelections').checked = user.Configuration.RememberAudioSelections || false; context.querySelector('.chkRememberSubtitleSelections').checked = user.Configuration.RememberSubtitleSelections || false; context.querySelector('.chkExternalVideoPlayer').checked = appSettings.enableSystemExternalPlayers(); + context.querySelector('.chkLimitSupportedVideoResolution').checked = appSettings.limitSupportedVideoResolution(); setMaxBitrateIntoField(context.querySelector('.selectVideoInNetworkQuality'), true, 'Video'); setMaxBitrateIntoField(context.querySelector('.selectVideoInternetQuality'), false, 'Video'); @@ -213,6 +214,7 @@ function saveUser(context, user, userSettingsInstance, apiClient) { appSettings.maxChromecastBitrate(context.querySelector('.selectChromecastVideoQuality').value); appSettings.maxVideoWidth(context.querySelector('.selectMaxVideoWidth').value); + appSettings.limitSupportedVideoResolution(context.querySelector('.chkLimitSupportedVideoResolution').checked); setMaxBitrateFromField(context.querySelector('.selectVideoInNetworkQuality'), true, 'Video'); setMaxBitrateFromField(context.querySelector('.selectVideoInternetQuality'), false, 'Video'); diff --git a/src/components/playbackSettings/playbackSettings.template.html b/src/components/playbackSettings/playbackSettings.template.html index 4b9c9a0a5f..6dc860260f 100644 --- a/src/components/playbackSettings/playbackSettings.template.html +++ b/src/components/playbackSettings/playbackSettings.template.html @@ -54,6 +54,14 @@ + +
+ +
${LimitSupportedVideoResolutionHelp}
+
diff --git a/src/scripts/settings/appSettings.js b/src/scripts/settings/appSettings.js index df18b0ddff..14688d40f0 100644 --- a/src/scripts/settings/appSettings.js +++ b/src/scripts/settings/appSettings.js @@ -105,6 +105,19 @@ class AppSettings { return parseInt(this.get('maxVideoWidth') || '0', 10) || 0; } + /** + * Get or set 'Limit maximum supported video resolution' state. + * @param {boolean|undefined} val - Flag to enable 'Limit maximum supported video resolution' or undefined. + * @return {boolean} 'Limit maximum supported video resolution' state. + */ + limitSupportedVideoResolution(val) { + if (val !== undefined) { + return this.set('limitSupportedVideoResolution', val.toString()); + } + + return toBoolean(this.get('limitSupportedVideoResolution'), false); + } + set(name, value, userId) { const currentValue = this.get(name, userId); localStorage.setItem(this.#getKey(name, userId), value); diff --git a/src/strings/en-us.json b/src/strings/en-us.json index 13363d303f..01cce2968c 100644 --- a/src/strings/en-us.json +++ b/src/strings/en-us.json @@ -935,6 +935,8 @@ "LearnHowYouCanContribute": "Learn how you can contribute.", "LeaveBlankToNotSetAPassword": "You can leave this field blank to set no password.", "LibraryAccessHelp": "Select the libraries to share with this user. Administrators will be able to edit all folders using the metadata manager.", + "LimitSupportedVideoResolution": "Limit maximum supported video resolution", + "LimitSupportedVideoResolutionHelp": "Use 'Maximum Allowed Video Transcoding Resolution' as maximum supported video resolution.", "List": "List", "ListView": "List View", "ListPaging": "{0}-{1} of {2}",