diff --git a/src/components/apphost.js b/src/components/apphost.js index e468ce161d..eeef967eb7 100644 --- a/src/components/apphost.js +++ b/src/components/apphost.js @@ -39,6 +39,25 @@ function getDeviceProfile(item) { profile = profileBuilder(builderOpts); } + const maxTranscodingVideoWidth = appHost.screen()?.maxAllowedWidth; + + if (maxTranscodingVideoWidth) { + 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 + }); + } + }); + } + resolve(profile); }); } @@ -382,6 +401,27 @@ export const appHost = { const att = scalable ? 'width=device-width, initial-scale=1, minimum-scale=1, user-scalable=yes' : 'width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no'; document.querySelector('meta[name=viewport]').setAttribute('content', att); } + }, + screen: () => { + let hostScreen = null; + + const appHostImpl = window.NativeShell?.AppHost; + + if (appHostImpl?.screen) { + hostScreen = appHostImpl.screen(); + } else if (window.screen && !browser.tv) { + hostScreen = { + width: Math.floor(window.screen.width * window.devicePixelRatio), + height: Math.floor(window.screen.height * window.devicePixelRatio) + }; + } + + if (hostScreen) { + // Use larger dimension to account for screen orientation changes + hostScreen.maxAllowedWidth = Math.max(hostScreen.width, hostScreen.height); + } + + return hostScreen; } };