1 line
12 KiB
JavaScript
1 line
12 KiB
JavaScript
|
|
import browser from"./browser.js";import appSettings from"./common/appsettings.js";import events from"./emby-apiclient/events.js";let appMode=globalThis.appMode,isNativeTizen="tizen"===appMode,isNativeLG="webos"===appMode;function generateRandomUUID(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(c){var r=16*Math.random()|0;return("x"===c?r:3&r|8).toString(16)})}function getDeviceId(){if("undefined"!=typeof Windows&&Windows.System){try{var sysIdInfo=Windows.System.Profile.SystemIdentification.getSystemIdForPublisher();if(0<sysIdInfo.id.length){let sysIdString=Windows.Security.Cryptography.CryptographicBuffer.encodeToBase64String(sysIdInfo.id);return sysIdString=(sysIdString=(sysIdString=sysIdString.replaceAll("+","")).replaceAll("/","")).replaceAll("=",""),Promise.resolve(sysIdString)}}catch(ex){}sysIdInfo=new Windows.Security.ExchangeActiveSyncProvisioning.EasClientDeviceInformation;return Promise.resolve(sysIdInfo.id)}sysIdInfo="_deviceId2";let deviceId=appSettings.get(sysIdInfo);return deviceId||(deviceId=globalThis.crypto&&crypto.randomUUID?crypto.randomUUID():generateRandomUUID(),appSettings.set(sysIdInfo,deviceId)),Promise.resolve(deviceId)}function getWindowsDeviceName(){try{var currentDeviceInfo=new Windows.Security.ExchangeActiveSyncProvisioning.EasClientDeviceInformation;if(currentDeviceInfo.friendlyName&¤tDeviceInfo.friendlyName.length)return currentDeviceInfo.friendlyName}catch(err){}return"Windows.Xbox"!==Windows.System.Profile.AnalyticsInfo.versionInfo.deviceFamily?"Windows":"Xbox One"}function containsGreaseChar(value){return value.includes("\\")||value.includes("/")||value.includes(";")||value.includes('"')||value.toLowerCase().includes("brand")}function isGenericBrand(value){return!!(value=value.toLowerCase()).includes("chromium")}function compareBrands(a,b){a=a.brand||"",b=b.brand||"";return containsGreaseChar(a)&&!containsGreaseChar(b)?1:!containsGreaseChar(a)&&containsGreaseChar(b)?-1:isGenericBrand(a)&&!isGenericBrand(b)?1:!isGenericBrand(a)&&isGenericBrand(b)||a<b?-1:b<a?1:0}function map(i){return i}function getDeviceName(){if(browser.tizen){let deviceName="Samsung Smart TV";return deviceName+=globalThis.webapis&&globalThis.webapis.productinfo?" ("+globalThis.webapis.productinfo.getRealModel()+")":"",Promise.resolve(deviceName)}if(isNativeLG){let deviceName="LG Smart TV";var modelName=browser.modelName;return deviceName+=0<modelName.length?" ("+modelName+")":"",Promise.resolve(deviceName)}if("undefined"!=typeof Windows)return Promise.resolve(getWindowsDeviceName());if(browser.operaTv)return Promise.resolve("Opera TV");let deviceName;modelName=Array.prototype.map.call(navigator.userAgentData?.brands||[],map).sort(compareBrands);return deviceName=(deviceName=modelName.length?modelName[0].brand:deviceName)||"Web Browser",navigator.userAgentData.getHighEntropyValues(["platform"]).then(function(values){return values.platform&&(deviceName+=" "+values.platform),Promise.resolve(deviceName)})}function isXboxUWP(){return!("undefined"==typeof Windows||!Windows.System)&&"Windows.Xbox"===Windows.System.Profile.AnalyticsInfo.versionInfo.deviceFamily}function supportsFullscreen(){var element;return!browser.tv&&!("undefined"==typeof document||!((element=document.documentElement).requestFullscreen||element.mozRequestFullScreen||element.webkitRequestFullscreen||element.msRequestFullscreen)&&!document.createElement("video").webkitEnterFullscreen)}function supportsSoundEffects(){return!(browser.tizen||browser.edge||browser.operaTv||isNativeLG||browser.netcast||(navigator.hardwareConcurrency||4)<4||(navigator.deviceMemory||2)<2||!globalThis.AudioContext)&&document.createElement("audio").canPlayType("audio/mp3").replace(/no/,"")}function supportInAppConnectSignup(){return"winjs"===appMode||"embyclient"===appMode||!!(browser.operaTv||isNativeTizen||isNativeLG)||globalThis.location.href.toLowerCase().startsWith("https")}function getSyncProfile(){return Emby.importModule("./modules/browserdeviceprofile.js").then(function(profileBuilder){return profileBuilder({maxStaticMusicBitrate:appSettings.
|