mirror of
https://github.com/jellyfin/jellyfin-tizen.git
synced 2024-11-30 09:30:49 +00:00
152 lines
4.4 KiB
JavaScript
152 lines
4.4 KiB
JavaScript
(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',
|
|
'multiserver',
|
|
'subtitleappearancesettings',
|
|
'subtitleburnsettings'
|
|
];
|
|
|
|
function postMessage() {
|
|
console.log.apply(console, arguments);
|
|
}
|
|
|
|
window.NativeShell = {
|
|
AppHost: {
|
|
init: function () {
|
|
postMessage('AppHost.init', AppInfo);
|
|
return Promise.resolve(AppInfo);
|
|
},
|
|
|
|
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');
|
|
return profileBuilder({ enableMkvProgressive: false, enableSsaRender: true });
|
|
},
|
|
|
|
getSyncProfile: function (profileBuilder) {
|
|
postMessage('AppHost.getSyncProfile');
|
|
return profileBuilder({ enableMkvProgressive: false });
|
|
},
|
|
|
|
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');
|
|
});
|
|
})();
|