1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00
jellyfin-web/dashboard-ui/bower_components/emby-webcomponents/playback/playersettingsmenu.js

1 line
5.9 KiB
JavaScript
Raw Normal View History

2018-09-12 19:26:21 +02:00
define(["connectionManager","actionsheet","datetime","playbackManager","globalize","appSettings","qualityoptions"],function(connectionManager,actionsheet,datetime,playbackManager,globalize,appSettings,qualityoptions){"use strict";function showQualityMenu(player,btn){var videoStream=playbackManager.currentMediaSource(player).MediaStreams.filter(function(stream){return"Video"===stream.Type})[0],videoWidth=videoStream?videoStream.Width:null,options=qualityoptions.getVideoQualityOptions({currentMaxBitrate:playbackManager.getMaxStreamingBitrate(player),isAutomaticBitrateEnabled:playbackManager.enableAutomaticBitrateDetection(player),videoWidth:videoWidth,enableAuto:!0}),menuItems=options.map(function(o){var opt={name:o.name,id:o.bitrate,asideText:o.secondaryText};return o.selected&&(opt.selected=!0),opt}),selectedId=options.filter(function(o){return o.selected});return selectedId=selectedId.length?selectedId[0].bitrate:null,actionsheet.show({items:menuItems,positionTo:btn}).then(function(id){var bitrate=parseInt(id);bitrate!==selectedId&&playbackManager.setMaxStreamingBitrate({enableAutomaticBitrateDetection:!bitrate,maxBitrate:bitrate},player)})}function showRepeatModeMenu(player,btn){var menuItems=[],currentValue=playbackManager.getRepeatMode(player);return menuItems.push({name:globalize.translate("sharedcomponents#RepeatAll"),id:"RepeatAll",selected:"RepeatAll"===currentValue}),menuItems.push({name:globalize.translate("sharedcomponents#RepeatOne"),id:"RepeatOne",selected:"RepeatOne"===currentValue}),menuItems.push({name:globalize.translate("sharedcomponents#None"),id:"RepeatNone",selected:"RepeatNone"===currentValue}),actionsheet.show({items:menuItems,positionTo:btn}).then(function(mode){mode&&playbackManager.setRepeatMode(mode,player)})}function getQualitySecondaryText(player){var state=playbackManager.getPlayerState(player),videoStream=(playbackManager.enableAutomaticBitrateDetection(player),playbackManager.getMaxStreamingBitrate(player),playbackManager.currentMediaSource(player).MediaStreams.filter(function(stream){return"Video"===stream.Type})[0]),videoWidth=videoStream?videoStream.Width:null,options=qualityoptions.getVideoQualityOptions({currentMaxBitrate:playbackManager.getMaxStreamingBitrate(player),isAutomaticBitrateEnabled:playbackManager.enableAutomaticBitrateDetection(player),videoWidth:videoWidth,enableAuto:!0}),selectedOption=(options.map(function(o){var opt={name:o.name,id:o.bitrate,asideText:o.secondaryText};return o.selected&&(opt.selected=!0),opt}),options.filter(function(o){return o.selected}));if(!selectedOption.length)return null;selectedOption=selectedOption[0];var text=selectedOption.name;return selectedOption.autoText&&(state.PlayState&&"Transcode"!==state.PlayState.PlayMethod?text+=" - Direct":text+=" "+selectedOption.autoText),text}function showAspectRatioMenu(player,btn){var currentId=playbackManager.getAspectRatio(player),menuItems=playbackManager.getSupportedAspectRatios(player).map(function(i){return{id:i.id,name:i.name,selected:i.id===currentId}});return actionsheet.show({items:menuItems,positionTo:btn}).then(function(id){return id?(playbackManager.setAspectRatio(id,player),Promise.resolve()):Promise.reject()})}function showWithUser(options,player,user){var supportedCommands=playbackManager.getSupportedCommands(player),menuItems=(options.mediaType,[]);if(-1!==supportedCommands.indexOf("SetAspectRatio")){var currentAspectRatioId=playbackManager.getAspectRatio(player),currentAspectRatio=playbackManager.getSupportedAspectRatios(player).filter(function(i){return i.id===currentAspectRatioId})[0];menuItems.push({name:globalize.translate("sharedcomponents#AspectRatio"),id:"aspectratio",asideText:currentAspectRatio?currentAspectRatio.name:null})}if(menuItems.push({name:globalize.translate("sharedcomponents#PlaybackSettings"),id:"playbacksettings"}),user&&user.Policy.EnableVideoPlaybackTranscoding){var secondaryQualityText=getQualitySecondaryText(player);menuItems.push({name:globalize.translate("sharedcomponents#Quality"),id:"quality",asideText:secondaryQualityText})}var repeatMode=playbackManager.get