jellyfin-web/dashboard-ui/components/apphost.js

1 line
8.1 KiB
JavaScript
Raw Normal View History

2017-11-08 13:21:52 -07:00
define(["appSettings","browser","events","htmlMediaHelper"],function(appSettings,browser,events,htmlMediaHelper){"use strict";function getBaseProfileOptions(item){var disableHlsVideoAudioCodecs=[];return item&&htmlMediaHelper.enableHlsJsPlayer(item.RunTimeTicks,item.MediaType)&&((browser.edge||browser.msie)&&disableHlsVideoAudioCodecs.push("mp3"),disableHlsVideoAudioCodecs.push("ac3"),disableHlsVideoAudioCodecs.push("eac3")),{enableMkvProgressive:!1,disableHlsVideoAudioCodecs:disableHlsVideoAudioCodecs}}function getDeviceProfileForWindowsUwp(item){return new Promise(function(resolve,reject){require(["browserdeviceprofile","environments/windows-uwp/mediacaps"],function(profileBuilder,uwpMediaCaps){var profileOptions=getBaseProfileOptions(item);profileOptions.supportsDts=uwpMediaCaps.supportsDTS(),profileOptions.supportsTrueHd=uwpMediaCaps.supportsDolby(),profileOptions.audioChannels=uwpMediaCaps.getAudioChannels(),resolve(profileBuilder(profileOptions))})})}function getDeviceProfile(item,options){return options=options||{},self.Windows?getDeviceProfileForWindowsUwp(item):new Promise(function(resolve,reject){require(["browserdeviceprofile"],function(profileBuilder){var profile=profileBuilder(getBaseProfileOptions(item));item&&!options.isRetry&&"allcomplexformats"!==appSettings.get("subtitleburnin")&&(browser.orsay||browser.tizen||(profile.SubtitleProfiles.push({Format:"ass",Method:"External"}),profile.SubtitleProfiles.push({Format:"ssa",Method:"External"}))),resolve(profile)})})}function getCapabilities(){return getDeviceProfile().then(function(profile){var supportsPersistentIdentifier=!!browser.edgeUwp,caps={PlayableMediaTypes:["Audio","Video"],SupportsPersistentIdentifier:supportsPersistentIdentifier,DeviceProfile:profile};return caps})}function generateDeviceId(){return new Promise(function(resolve,reject){require(["cryptojs-sha1"],function(){var keys=[];keys.push(navigator.userAgent),keys.push((new Date).getTime()),resolve(CryptoJS.SHA1(keys.join("|")).toString())})})}function getDeviceId(){var key="_deviceId2",deviceId=appSettings.get(key);return deviceId?Promise.resolve(deviceId):generateDeviceId().then(function(deviceId){return appSettings.set(key,deviceId),deviceId})}function getDeviceName(){var deviceName;return deviceName=browser.tizen?"Samsung Smart TV":browser.web0s?"LG Smart TV":browser.operaTv?"Opera TV":browser.xboxOne?"Xbox One":browser.ps4?"Sony PS4":browser.chrome?"Chrome":browser.edge?"Edge":browser.firefox?"Firefox":browser.msie?"Internet Explorer":"Web Browser",browser.ipad?deviceName+=" Ipad":browser.iphone?deviceName+=" Iphone":browser.android&&(deviceName+=" Android"),deviceName}function supportsVoiceInput(){return!browser.tv&&(window.SpeechRecognition||window.webkitSpeechRecognition||window.mozSpeechRecognition||window.oSpeechRecognition||window.msSpeechRecognition)}function supportsFullscreen(){if(browser.tv)return!1;var element=document.documentElement;return!!(element.requestFullscreen||element.mozRequestFullScreen||element.webkitRequestFullscreen||element.msRequestFullscreen)||!!document.createElement("video").webkitEnterFullscreen}function getSyncProfile(){return new Promise(function(resolve,reject){require(["browserdeviceprofile","appSettings"],function(profileBuilder,appSettings){var profile=profileBuilder();profile.MaxStaticMusicBitrate=appSettings.maxStaticMusicBitrate(),resolve(profile)})})}function getDefaultLayout(){return"desktop"}function supportsHtmlMediaAutoplay(){if(browser.edgeUwp||browser.tizen||browser.web0s||browser.orsay||browser.operaTv||browser.ps4||browser.xboxOne)return!0;if(browser.mobile)return!1;var savedResult=appSettings.get(htmlMediaAutoplayAppStorageKey);return"true"===savedResult||"false"!==savedResult&&null}function isXboxUWP(){return!1}function cueSupported(){try{var video=document.createElement("video"),style=document.createElement("style");style.textContent="video::cue {background: inherit}",document.body.appendChild(style),document.body.appendChild(video);var cue=window.getComputedStyle(video,"::cue").background;return document.body.removeChild(style),documen