Add AppHost.screen function

This commit is contained in:
Dmitry Lyzo 2022-03-23 21:00:42 +03:00
parent 0f3ca9b2ba
commit e6e113f54a
3 changed files with 47 additions and 1 deletions

View File

@ -8,6 +8,7 @@
<feature name="http://tizen.org/feature/screen.size.all"/>
<icon src="icon.png"/>
<name>Jellyfin</name>
<tizen:privilege name="http://developer.samsung.com/privilege/productinfo"/>
<tizen:privilege name="http://tizen.org/privilege/tv.inputdevice"/>
<tizen:profile name="tv"/>
<tizen:setting screen-orientation="auto-rotation" context-menu="enable" background-support="disable" encryption="disable" install-location="auto" hwkey-event="enable"/>

View File

@ -91,6 +91,11 @@ function modifyIndex() {
const injectTarget = apploader.parentNode;
// inject webapis.js
const webapis = this.createElement('script');
webapis.setAttribute('src', '$WEBAPIS/webapis/webapis.js');
injectTarget.insertBefore(webapis, apploader);
// inject appMode script
var appMode = this.createElement('script');
appMode.text = 'window.appMode=\'cordova\';';

View File

@ -45,6 +45,37 @@
'subtitleburnsettings'
];
var systeminfo;
function getSystemInfo() {
if (systeminfo) {
return Promise.resolve(systeminfo);
}
return new Promise(function (resolve) {
tizen.systeminfo.getPropertyValue('DISPLAY', function (result) {
let devicePixelRatio = 1;
if (typeof webapis.productinfo.is8KPanelSupported === 'function' && webapis.productinfo.is8KPanelSupported()){
console.log("8K UHD is supported");
devicePixelRatio = 4;
} else if (typeof webapis.productinfo.isUdPanelSupported === 'function' && webapis.productinfo.isUdPanelSupported()){
console.log("4K UHD is supported");
devicePixelRatio = 2;
} else {
console.log("UHD is not supported");
}
systeminfo = Object.assign({}, result, {
resolutionWidth: Math.floor(result.resolutionWidth * devicePixelRatio),
resolutionHeight: Math.floor(result.resolutionHeight * devicePixelRatio)
});
resolve(systeminfo)
});
});
}
function postMessage() {
console.log.apply(console, arguments);
}
@ -53,7 +84,9 @@
AppHost: {
init: function () {
postMessage('AppHost.init', AppInfo);
return Promise.resolve(AppInfo);
return getSystemInfo().then(function () {
return Promise.resolve(AppInfo);
});
},
appName: function () {
@ -96,6 +129,13 @@
return profileBuilder({ enableMkvProgressive: false });
},
screen: function () {
return systeminfo ? {
width: systeminfo.resolutionWidth,
height: systeminfo.resolutionHeight
} : null;
},
supports: function (command) {
var isSupported = command && SupportedFeatures.indexOf(command.toLowerCase()) != -1;
postMessage('AppHost.supports', {