2020-02-02 14:51:13 +00:00
|
|
|
(function () {
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
console.log('Tizen adapter');
|
|
|
|
|
|
|
|
// Similar to jellyfin-web
|
|
|
|
function generateDeviceId() {
|
|
|
|
return btoa([navigator.userAgent, new Date().getTime()].join('|')).replace(/=/g, '1');
|
|
|
|
}
|
|
|
|
|
|
|
|
function getDeviceId() {
|
|
|
|
// Use variable '_deviceId2' to mimic jellyfin-web
|
|
|
|
|
|
|
|
var deviceId = localStorage.getItem('_deviceId2');
|
|
|
|
|
|
|
|
if (!deviceId) {
|
|
|
|
deviceId = generateDeviceId();
|
|
|
|
localStorage.setItem('_deviceId2', deviceId);
|
|
|
|
}
|
|
|
|
|
|
|
|
return deviceId;
|
|
|
|
}
|
|
|
|
|
|
|
|
var AppInfo = {
|
|
|
|
deviceId: getDeviceId(),
|
|
|
|
deviceName: 'Samsung Smart TV',
|
|
|
|
appName: 'Jellyfin for Tizen',
|
|
|
|
appVersion: tizen.application.getCurrentApplication().appInfo.version
|
|
|
|
};
|
|
|
|
|
|
|
|
// List of supported features
|
|
|
|
var SupportedFeatures = [
|
|
|
|
'exit',
|
|
|
|
'exitmenu',
|
|
|
|
'externallinkdisplay',
|
|
|
|
'htmlaudioautoplay',
|
|
|
|
'htmlvideoautoplay',
|
|
|
|
'physicalvolumecontrol',
|
|
|
|
'displaylanguage',
|
|
|
|
'otherapppromotions',
|
|
|
|
'targetblank',
|
|
|
|
'screensaver',
|
2020-03-27 18:33:29 +00:00
|
|
|
'multiserver',
|
|
|
|
'subtitleappearancesettings',
|
|
|
|
'subtitleburnsettings'
|
2020-02-02 14:51:13 +00:00
|
|
|
];
|
|
|
|
|
2022-03-23 18:00:42 +00:00
|
|
|
var systeminfo;
|
|
|
|
|
|
|
|
function getSystemInfo() {
|
|
|
|
if (systeminfo) {
|
|
|
|
return Promise.resolve(systeminfo);
|
|
|
|
}
|
|
|
|
|
|
|
|
return new Promise(function (resolve) {
|
|
|
|
tizen.systeminfo.getPropertyValue('DISPLAY', function (result) {
|
2022-06-17 19:51:46 +00:00
|
|
|
var devicePixelRatio = 1;
|
2022-03-23 18:00:42 +00:00
|
|
|
|
|
|
|
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)
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2020-02-02 14:51:13 +00:00
|
|
|
function postMessage() {
|
|
|
|
console.log.apply(console, arguments);
|
|
|
|
}
|
|
|
|
|
|
|
|
window.NativeShell = {
|
|
|
|
AppHost: {
|
|
|
|
init: function () {
|
|
|
|
postMessage('AppHost.init', AppInfo);
|
2022-03-23 18:00:42 +00:00
|
|
|
return getSystemInfo().then(function () {
|
|
|
|
return Promise.resolve(AppInfo);
|
|
|
|
});
|
2020-02-02 14:51:13 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
appName: function () {
|
|
|
|
postMessage('AppHost.appName', AppInfo.appName);
|
|
|
|
return AppInfo.appName;
|
|
|
|
},
|
|
|
|
|
|
|
|
appVersion: function () {
|
|
|
|
postMessage('AppHost.appVersion', AppInfo.appVersion);
|
|
|
|
return AppInfo.appVersion;
|
|
|
|
},
|
|
|
|
|
|
|
|
deviceId: function () {
|
|
|
|
postMessage('AppHost.deviceId', AppInfo.deviceId);
|
|
|
|
return AppInfo.deviceId;
|
|
|
|
},
|
|
|
|
|
|
|
|
deviceName: function () {
|
|
|
|
postMessage('AppHost.deviceName', AppInfo.deviceName);
|
|
|
|
return AppInfo.deviceName;
|
|
|
|
},
|
|
|
|
|
|
|
|
exit: function () {
|
|
|
|
postMessage('AppHost.exit');
|
|
|
|
tizen.application.getCurrentApplication().exit();
|
|
|
|
},
|
|
|
|
|
|
|
|
getDefaultLayout: function () {
|
|
|
|
postMessage('AppHost.getDefaultLayout', 'tv');
|
|
|
|
return 'tv';
|
|
|
|
},
|
|
|
|
|
|
|
|
getDeviceProfile: function (profileBuilder) {
|
|
|
|
postMessage('AppHost.getDeviceProfile');
|
2020-06-13 19:54:23 +00:00
|
|
|
return profileBuilder({ enableMkvProgressive: false, enableSsaRender: true });
|
2020-02-02 14:51:13 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
getSyncProfile: function (profileBuilder) {
|
|
|
|
postMessage('AppHost.getSyncProfile');
|
|
|
|
return profileBuilder({ enableMkvProgressive: false });
|
|
|
|
},
|
|
|
|
|
2022-03-23 18:00:42 +00:00
|
|
|
screen: function () {
|
|
|
|
return systeminfo ? {
|
|
|
|
width: systeminfo.resolutionWidth,
|
|
|
|
height: systeminfo.resolutionHeight
|
|
|
|
} : null;
|
|
|
|
},
|
|
|
|
|
2020-02-02 14:51:13 +00:00
|
|
|
supports: function (command) {
|
|
|
|
var isSupported = command && SupportedFeatures.indexOf(command.toLowerCase()) != -1;
|
|
|
|
postMessage('AppHost.supports', {
|
|
|
|
command: command,
|
|
|
|
isSupported: isSupported
|
|
|
|
});
|
|
|
|
return isSupported;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
downloadFile: function (url) {
|
|
|
|
postMessage('downloadFile', { url: url });
|
|
|
|
},
|
|
|
|
|
|
|
|
enableFullscreen: function () {
|
|
|
|
postMessage('enableFullscreen');
|
|
|
|
},
|
|
|
|
|
|
|
|
disableFullscreen: function () {
|
|
|
|
postMessage('disableFullscreen');
|
|
|
|
},
|
|
|
|
|
|
|
|
getPlugins: function () {
|
|
|
|
postMessage('getPlugins');
|
|
|
|
return [];
|
|
|
|
},
|
|
|
|
|
|
|
|
openUrl: function (url, target) {
|
|
|
|
postMessage('openUrl', {
|
|
|
|
url: url,
|
|
|
|
target: target
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
updateMediaSession: function (mediaInfo) {
|
|
|
|
postMessage('updateMediaSession', { mediaInfo: mediaInfo });
|
|
|
|
},
|
|
|
|
|
|
|
|
hideMediaSession: function () {
|
|
|
|
postMessage('hideMediaSession');
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
window.addEventListener('load', function () {
|
|
|
|
tizen.tvinputdevice.registerKey('MediaPlay');
|
|
|
|
tizen.tvinputdevice.registerKey('MediaPause');
|
|
|
|
tizen.tvinputdevice.registerKey('MediaStop');
|
|
|
|
tizen.tvinputdevice.registerKey('MediaTrackPrevious');
|
|
|
|
tizen.tvinputdevice.registerKey('MediaTrackNext');
|
|
|
|
tizen.tvinputdevice.registerKey('MediaRewind');
|
|
|
|
tizen.tvinputdevice.registerKey('MediaFastForward');
|
|
|
|
});
|
2023-02-18 21:15:20 +00:00
|
|
|
|
|
|
|
function updateKeys() {
|
|
|
|
if (location.hash.indexOf('/queue') !== -1 || location.hash.indexOf('/video') !== -1) {
|
|
|
|
// Disable on-screen playback control, if available on the page
|
|
|
|
tizen.tvinputdevice.registerKey('MediaPlayPause');
|
|
|
|
} else {
|
|
|
|
tizen.tvinputdevice.unregisterKey('MediaPlayPause');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
window.addEventListener('viewshow', updateKeys);
|
2020-02-02 14:51:13 +00:00
|
|
|
})();
|