diff --git a/dashboard-ui/bower_components/emby-webcomponents/htmlvideoplayer/plugin.js b/dashboard-ui/bower_components/emby-webcomponents/htmlvideoplayer/plugin.js index 91e41d1a16..a863a14972 100644 --- a/dashboard-ui/bower_components/emby-webcomponents/htmlvideoplayer/plugin.js +++ b/dashboard-ui/bower_components/emby-webcomponents/htmlvideoplayer/plugin.js @@ -1 +1 @@ -define(["browser","require","events","apphost","loading","dom","playbackManager","appRouter","appSettings","connectionManager","./htmlmediahelper","itemHelper"],function(browser,require,events,appHost,loading,dom,playbackManager,appRouter,appSettings,connectionManager,htmlMediaHelper,itemHelper){"use strict";function tryRemoveElement(elem){var parentNode=elem.parentNode;if(parentNode)try{parentNode.removeChild(elem)}catch(err){console.log("Error removing dialog element: "+err)}}function enableNativeTrackSupport(currentSrc,track){if(browser.firefox&&(currentSrc||"").toLowerCase().indexOf(".m3u8")!==-1)return!1;if(browser.chromecast&&(currentSrc||"").toLowerCase().indexOf(".m3u8")!==-1)return!1;if(browser.ps4)return!1;if(browser.edge)return!1;if(browser.iOS){var userAgent=navigator.userAgent.toLowerCase();if((userAgent.indexOf("os 9")!==-1||userAgent.indexOf("os 8")!==-1)&&userAgent.indexOf("safari")===-1)return!1}if(track){var format=(track.Codec||"").toLowerCase();if("ssa"===format||"ass"===format)return!1}return!0}function requireHlsPlayer(callback){require(["hlsjs"],function(hls){window.Hls=hls,callback()})}function getMediaStreamAudioTracks(mediaSource){return mediaSource.MediaStreams.filter(function(s){return"Audio"===s.Type})}function getMediaStreamTextTracks(mediaSource){return mediaSource.MediaStreams.filter(function(s){return"Subtitle"===s.Type&&"External"===s.DeliveryMethod})}function zoomIn(elem){return new Promise(function(resolve,reject){var duration=240;elem.style.animation="htmlvideoplayer-zoomin "+duration+"ms ease-in normal",dom.addEventListener(elem,dom.whichAnimationEvent(),resolve,{once:!0})})}function normalizeTrackEventText(text){return text.replace(/\\N/gi,"\n")}function setTracks(elem,tracks,item,mediaSource){elem.innerHTML=getTracksHtml(tracks,item,mediaSource)}function getTextTrackUrl(track,item,format){if(itemHelper.isLocalItem(item)&&track.Path)return track.Path;var url=playbackManager.getSubtitleUrl(track,item.ServerId);return format&&(url=url.replace(".vtt",format)),url}function getTracksHtml(tracks,item,mediaSource){return tracks.map(function(t){var defaultAttribute=mediaSource.DefaultSubtitleStreamIndex===t.Index?" default":"",language=t.Language||"und",label=t.Language||"und";return'"}).join("")}function getDefaultProfile(){return new Promise(function(resolve,reject){require(["browserdeviceprofile"],function(profileBuilder){resolve(profileBuilder({}))})})}function HtmlVideoPlayer(){function updateVideoUrl(streamInfo){var isHls=streamInfo.url.toLowerCase().indexOf(".m3u8")!==-1,mediaSource=streamInfo.mediaSource,item=streamInfo.item;if(mediaSource&&item&&!mediaSource.RunTimeTicks&&isHls&&"Transcode"===streamInfo.playMethod&&(browser.iOS||browser.osx)){var hlsPlaylistUrl=streamInfo.url.replace("master.m3u8","live.m3u8");return loading.show(),console.log("prefetching hls playlist: "+hlsPlaylistUrl),connectionManager.getApiClient(item.ServerId).ajax({type:"GET",url:hlsPlaylistUrl}).then(function(){return console.log("completed prefetching hls playlist: "+hlsPlaylistUrl),loading.hide(),streamInfo.url=hlsPlaylistUrl,Promise.resolve()},function(){return console.log("error prefetching hls playlist: "+hlsPlaylistUrl),loading.hide(),Promise.resolve()})}return Promise.resolve()}function setSrcWithFlvJs(instance,elem,options,url){return new Promise(function(resolve,reject){require(["flvjs"],function(flvjs){var flvPlayer=flvjs.createPlayer({type:"flv",url:url},{seekType:"range",lazyLoad:!1});flvPlayer.attachMediaElement(elem),flvPlayer.load(),flvPlayer.play().then(resolve,reject),instance._flvPlayer=flvPlayer,self._currentSrc=url})})}function setSrcWithHlsJs(instance,elem,options,url){return new Promise(function(resolve,reject){requireHlsPlayer(function(){var hls=new Hls({manifestLoadingTimeOut:2e4});hls.loadSource(url),hls.attachMedia(elem),htmlMediaHelper.bindEventsToHlsPlayer(self,hls,elem,onError,resolve,reject),self._hlsPlayer=hls,self._currentSrc=url})})}function setCurrentSrcChromecast(instance,elem,options,url){elem.autoplay=!0;var lrd=new cast.receiver.MediaManager.LoadRequestData;lrd.currentTime=(options.playerStartPositionTicks||0)/1e7,lrd.autoplay=!0,lrd.media=new cast.receiver.media.MediaInformation,lrd.media.contentId=url,lrd.media.contentType=options.mimeType,lrd.media.streamType=cast.receiver.media.StreamType.OTHER,lrd.media.customData=options,console.log("loading media url into mediaManager");try{return mediaManager.load(lrd),self._currentSrc=url,Promise.resolve()}catch(err){return console.log("mediaManager error: "+err),Promise.reject()}}function onMediaManagerLoadMedia(event){self._castPlayer&&self._castPlayer.unload(),self._castPlayer=null;var protocol,data=event.data,media=event.data.media||{},url=media.contentId,contentType=media.contentType.toLowerCase(),ext=(media.customData,"m3u8"),mediaElement=self._mediaElement,host=new cast.player.api.Host({url:url,mediaElement:mediaElement});"m3u8"===ext||"application/x-mpegurl"===contentType||"application/vnd.apple.mpegurl"===contentType?protocol=cast.player.api.CreateHlsStreamingProtocol(host):"mpd"===ext||"application/dash+xml"===contentType?protocol=cast.player.api.CreateDashStreamingProtocol(host):(url.indexOf(".ism")>-1||"application/vnd.ms-sstr+xml"===contentType)&&(protocol=cast.player.api.CreateSmoothStreamingProtocol(host)),console.log("loading playback url: "+url),console.log("contentType: "+contentType),host.onError=function(errorCode){console.log("Fatal Error - "+errorCode)},mediaElement.autoplay=!1,self._castPlayer=new cast.player.api.Player(host),self._castPlayer.load(protocol,data.currentTime||0),self._castPlayer.playWhenHaveEnoughData()}function initMediaManager(){mediaManager.defaultOnLoad=mediaManager.onLoad.bind(mediaManager),mediaManager.onLoad=onMediaManagerLoadMedia.bind(self),mediaManager.defaultOnStop=mediaManager.onStop.bind(mediaManager),mediaManager.onStop=function(event){playbackManager.stop(),mediaManager.defaultOnStop(event)}}function setCurrentSrc(elem,options){elem.removeEventListener("error",onError);var val=options.url;console.log("playing url: "+val);var seconds=(options.playerStartPositionTicks||0)/1e7;seconds&&(val+="#t="+seconds),htmlMediaHelper.destroyHlsPlayer(self),htmlMediaHelper.destroyFlvPlayer(self),htmlMediaHelper.destroyCastPlayer(self);for(var tracks=getMediaStreamTextTracks(options.mediaSource),currentTrackIndex=-1,i=0,length=tracks.length;i'+getTracksHtml(tracks,options.item,options.mediaSource),elem.addEventListener("loadedmetadata",onLoadedMetadata),self._currentSrc=val,htmlMediaHelper.playWithPromise(elem,onError)):htmlMediaHelper.applySrc(elem,val,options).then(function(){return setTracks(elem,tracks,options.item,options.mediaSource),self._currentSrc=val,htmlMediaHelper.playWithPromise(elem,onError)})}function onEnded(){destroyCustomTrack(this),htmlMediaHelper.onEndedInternal(self,this,onError)}function onTimeUpdate(e){var time=this.currentTime;time&&!self._timeUpdated&&(self._timeUpdated=!0,ensureValidVideo(this)),self._currentTime=time;var currentPlayOptions=self._currentPlayOptions;if(currentPlayOptions){var timeMs=1e3*time;timeMs+=(currentPlayOptions.transcodingOffsetTicks||0)/1e4,updateSubtitleText(timeMs)}events.trigger(self,"timeupdate")}function onVolumeChange(){htmlMediaHelper.saveVolume(this.volume),events.trigger(self,"volumechange")}function onNavigatedToOsd(){var dlg=videoDialog;dlg&&(dlg.classList.remove("videoPlayerContainer-withBackdrop"),dlg.classList.remove("videoPlayerContainer-onTop"),onStartedAndNavigatedToOsd())}function onStartedAndNavigatedToOsd(){setCurrentTrackElement(subtitleTrackIndexToSetOnPlaying)}function onPlaying(e){self._started||(self._started=!0,this.removeAttribute("controls"),self._currentPlayOptions.title?(self.originalDocumentTitle=document.title,document.title=self._currentPlayOptions.title):self.originalDocumentTitle=null,loading.hide(),htmlMediaHelper.seekOnPlaybackStart(self,e.target,self._currentPlayOptions.playerStartPositionTicks),self._currentPlayOptions.fullscreen?appRouter.showVideoOsd().then(onNavigatedToOsd):(appRouter.setTransparency("backdrop"),videoDialog.classList.remove("videoPlayerContainer-withBackdrop"),videoDialog.classList.remove("videoPlayerContainer-onTop"),onStartedAndNavigatedToOsd())),events.trigger(self,"playing")}function onPlay(e){events.trigger(self,"unpause")}function ensureValidVideo(elem){if(elem===self._mediaElement&&0===elem.videoWidth&&0===elem.videoHeight){var mediaSource=(self._currentPlayOptions||{}).mediaSource;if(!mediaSource||mediaSource.RunTimeTicks)return void htmlMediaHelper.onErrorInternal(self,"mediadecodeerror")}}function onClick(){events.trigger(self,"click")}function onDblClick(){events.trigger(self,"dblclick")}function onPause(){events.trigger(self,"pause")}function onError(){var errorCode=this.error?this.error.code||0:0,errorMessage=this.error?this.error.message||"":"";console.log("Media element error: "+errorCode.toString()+" "+errorMessage);var type;switch(errorCode){case 1:return;case 2:type="network";break;case 3:if(self._hlsPlayer)return void htmlMediaHelper.handleHlsJsMediaError(self);type="mediadecodeerror";break;case 4:type="medianotsupported";break;default:return}htmlMediaHelper.onErrorInternal(self,type)}function onLoadedMetadata(e){var mediaElem=e.target;if(mediaElem.removeEventListener("loadedmetadata",onLoadedMetadata),!self._hlsPlayer&&!self._shakaPlayer&&!self._flvPlayer)try{mediaElem.play()}catch(err){console.log("error calling mediaElement.play: "+err)}}function destroyCustomTrack(videoElement){if(self._resizeObserver&&(self._resizeObserver.disconnect(),self._resizeObserver=null),window.removeEventListener("orientationchange",onVideoResize),videoSubtitlesElem){var subtitlesContainer=videoSubtitlesElem.parentNode;subtitlesContainer&&tryRemoveElement(subtitlesContainer),videoSubtitlesElem=null}if(currentTrackEvents=null,videoElement)for(var allTracks=videoElement.textTracks||[],i=0;i',videoSubtitlesElem=subtitlesContainer.querySelector(".videoSubtitlesInner"),setSubtitleAppearance(subtitlesContainer,videoSubtitlesElem),videoElement.parentNode.appendChild(subtitlesContainer),currentTrackEvents=data.TrackEvents}})}function setSubtitleAppearance(elem,innerElem){require(["userSettings","subtitleAppearanceHelper"],function(userSettings,subtitleAppearanceHelper){subtitleAppearanceHelper.applyStyles({text:innerElem,window:elem},userSettings.getSubtitleAppearanceSettings())})}function getCueCss(appearance,selector){var html=selector+"::cue {";return html+=appearance.text.map(function(s){return s.name+":"+s.value+"!important;"}).join(""),html+="}"}function setCueAppearance(){require(["userSettings","subtitleAppearanceHelper"],function(userSettings,subtitleAppearanceHelper){var elementId=self.id+"-cuestyle",styleElem=document.querySelector("#"+elementId);styleElem||(styleElem=document.createElement("style"),styleElem.id=elementId,styleElem.type="text/css",document.getElementsByTagName("head")[0].appendChild(styleElem)),styleElem.innerHTML=getCueCss(subtitleAppearanceHelper.getStyles(userSettings.getSubtitleAppearanceSettings(),!0),".htmlvideoplayer")})}function renderTracksEvents(videoElement,track,item){if(!itemHelper.isLocalItem(item)||track.IsExternal){var format=(track.Codec||"").toLowerCase();if("ssa"===format||"ass"===format)return void renderWithLibjass(videoElement,track,item);if(requiresCustomSubtitlesElement())return void renderSubtitlesWithCustomElement(videoElement,track,item)}for(var trackElement=null,expectedId="manualTrack"+track.Index,allTracks=videoElement.textTracks,i=0;i=ticks){selectedTrackEvent=currentTrackEvent;break}}selectedTrackEvent&&selectedTrackEvent.Text?(subtitleTextElement.innerHTML=normalizeTrackEventText(selectedTrackEvent.Text),subtitleTextElement.classList.remove("hide")):subtitleTextElement.classList.add("hide")}}}function setCurrentTrackElement(streamIndex){console.log("Setting new text track index to: "+streamIndex);var mediaStreamTextTracks=getMediaStreamTextTracks(self._currentPlayOptions.mediaSource),track=streamIndex===-1?null:mediaStreamTextTracks.filter(function(t){return t.Index===streamIndex})[0];enableNativeTrackSupport(self._currentSrc,track)?(setTrackForCustomDisplay(self._mediaElement,null),streamIndex!==-1&&setCueAppearance()):(setTrackForCustomDisplay(self._mediaElement,track),streamIndex=-1,track=null);for(var expectedId="textTrack"+streamIndex,trackIndex=streamIndex!==-1&&track?mediaStreamTextTracks.indexOf(track):-1,modes=["disabled","showing","hidden"],allTracks=self._mediaElement.textTracks,i=0;i':'",dlg.innerHTML=html;var videoElement=dlg.querySelector("video");videoElement.volume=htmlMediaHelper.getSavedVolume(),videoElement.addEventListener("timeupdate",onTimeUpdate),videoElement.addEventListener("ended",onEnded),videoElement.addEventListener("volumechange",onVolumeChange),videoElement.addEventListener("pause",onPause),videoElement.addEventListener("playing",onPlaying),videoElement.addEventListener("play",onPlay),videoElement.addEventListener("click",onClick),videoElement.addEventListener("dblclick",onDblClick),document.body.insertBefore(dlg,document.body.firstChild),videoDialog=dlg,self._mediaElement=videoElement,mediaManager&&(mediaManager.embyInit||(initMediaManager(),mediaManager.embyInit=!0),mediaManager.setMediaElement(videoElement)),options.fullscreen&&browser.supportsCssAnimation()&&!browser.slow?zoomIn(dlg).then(function(){resolve(videoElement)}):resolve(videoElement)})})}browser.edgeUwp?this.name="Windows Video Player":this.name="Html Video Player",this.type="mediaplayer",this.id="htmlvideoplayer",this.priority=1;var videoDialog,subtitleTrackIndexToSetOnPlaying,currentClock,currentAssRenderer,videoSubtitlesElem,currentTrackEvents,lastCustomTrackMs=0,customTrackIndex=-1,self=this;self.currentSrc=function(){return self._currentSrc},self.play=function(options){return browser.msie&&"Transcode"===options.playMethod&&!window.MediaSource?(alert("Playback of this content is not supported in Internet Explorer. For a better experience, try a modern browser such as Microsoft Edge, Google Chrome, Firefox or Opera."),Promise.reject()):(self._started=!1,self._timeUpdated=!1,self._currentTime=null,createMediaElement(options).then(function(elem){return updateVideoUrl(options,options.mediaSource).then(function(){return setCurrentSrc(elem,options)})}))},self.setSubtitleStreamIndex=function(index){setCurrentTrackElement(index)},self.setAudioStreamIndex=function(index){var i,length,audioStreams=getMediaStreamAudioTracks(self._currentPlayOptions.mediaSource),audioTrackOffset=-1;for(i=0,length=audioStreams.length;i=100?"none":rawValue/100;elem.style["-webkit-filter"]="brightness("+cssValue+");",elem.style.filter="brightness("+cssValue+")",elem.brightnessValue=val,events.trigger(this,"brightnesschange")}},HtmlVideoPlayer.prototype.getBrightness=function(){var elem=this._mediaElement;if(elem){var val=elem.brightnessValue;return null==val?100:val}},HtmlVideoPlayer.prototype.seekable=function(){var mediaElement=this._mediaElement;if(mediaElement){var seekable=mediaElement.seekable;if(seekable&&seekable.length){var start=seekable.start(0),end=seekable.end(0);return htmlMediaHelper.isValidDuration(start)||(start=0),htmlMediaHelper.isValidDuration(end)||(end=0),end-start>0}return!1}},HtmlVideoPlayer.prototype.pause=function(){var mediaElement=this._mediaElement;mediaElement&&mediaElement.pause()},HtmlVideoPlayer.prototype.resume=function(){var mediaElement=this._mediaElement;mediaElement&&mediaElement.play()},HtmlVideoPlayer.prototype.unpause=function(){var mediaElement=this._mediaElement;mediaElement&&mediaElement.play()},HtmlVideoPlayer.prototype.paused=function(){var mediaElement=this._mediaElement;return!!mediaElement&&mediaElement.paused},HtmlVideoPlayer.prototype.setVolume=function(val){var mediaElement=this._mediaElement;mediaElement&&(mediaElement.volume=val/100)},HtmlVideoPlayer.prototype.getVolume=function(){var mediaElement=this._mediaElement;if(mediaElement)return 100*mediaElement.volume},HtmlVideoPlayer.prototype.volumeUp=function(){this.setVolume(Math.min(this.getVolume()+2,100))},HtmlVideoPlayer.prototype.volumeDown=function(){this.setVolume(Math.max(this.getVolume()-2,0))},HtmlVideoPlayer.prototype.setMute=function(mute){var mediaElement=this._mediaElement;mediaElement&&(mediaElement.muted=mute)},HtmlVideoPlayer.prototype.isMuted=function(){var mediaElement=this._mediaElement;return!!mediaElement&&mediaElement.muted},HtmlVideoPlayer.prototype.setAspectRatio=function(val){},HtmlVideoPlayer.prototype.getAspectRatio=function(){return this._currentAspectRatio},HtmlVideoPlayer.prototype.getSupportedAspectRatios=function(){return[]},HtmlVideoPlayer.prototype.togglePictureInPicture=function(){return this.setPictureInPictureEnabled(!this.isPictureInPictureEnabled())},HtmlVideoPlayer.prototype.getBufferedRanges=function(){var mediaElement=this._mediaElement;return mediaElement?htmlMediaHelper.getBufferedRanges(this,mediaElement):[]},HtmlVideoPlayer.prototype.getStats=function(){var mediaElement=this._mediaElement,playOptions=this._currentPlayOptions||[],categories=[];if(!mediaElement)return Promise.resolve({categories:categories});var mediaCategory={stats:[],type:"media"};if(categories.push(mediaCategory),playOptions.url){var link=document.createElement("a");link.setAttribute("href",playOptions.url);var protocol=(link.protocol||"").replace(":","");protocol&&mediaCategory.stats.push({label:"Protocol:",value:protocol}),link=null}this._hlsPlayer||this._shakaPlayer?mediaCategory.stats.push({label:"Stream type:",value:"HLS"}):mediaCategory.stats.push({label:"Stream type:",value:"Video"});var videoCategory={stats:[],type:"video"};categories.push(videoCategory);var rect=mediaElement.getBoundingClientRect?mediaElement.getBoundingClientRect():{},height=rect.height,width=rect.width;if(width&&height&&videoCategory.stats.push({label:"Player dimensions:",value:width+"x"+height}),height=mediaElement.videoHeight,width=mediaElement.videoWidth,width&&height&&videoCategory.stats.push({label:"Video resolution:",value:width+"x"+height}),mediaElement.getVideoPlaybackQuality){var playbackQuality=mediaElement.getVideoPlaybackQuality(),droppedVideoFrames=playbackQuality.droppedVideoFrames||0;videoCategory.stats.push({label:"Dropped frames:",value:droppedVideoFrames});var corruptedVideoFrames=playbackQuality.corruptedVideoFrames||0;videoCategory.stats.push({label:"Corrupted frames:",value:corruptedVideoFrames})}var audioCategory={stats:[],type:"audio"};categories.push(audioCategory);var sinkId=mediaElement.sinkId;return sinkId&&audioCategory.stats.push({label:"Sink Id:",value:sinkId}),Promise.resolve({categories:categories})},browser.chromecast&&(mediaManager=new cast.receiver.MediaManager(document.createElement("video"))),HtmlVideoPlayer}); \ No newline at end of file +define(["browser","require","events","apphost","loading","dom","playbackManager","appRouter","appSettings","connectionManager","./htmlmediahelper","itemHelper"],function(browser,require,events,appHost,loading,dom,playbackManager,appRouter,appSettings,connectionManager,htmlMediaHelper,itemHelper){"use strict";function tryRemoveElement(elem){var parentNode=elem.parentNode;if(parentNode)try{parentNode.removeChild(elem)}catch(err){console.log("Error removing dialog element: "+err)}}function enableNativeTrackSupport(currentSrc,track){if(browser.firefox&&(currentSrc||"").toLowerCase().indexOf(".m3u8")!==-1)return!1;if(browser.chromecast&&(currentSrc||"").toLowerCase().indexOf(".m3u8")!==-1)return!1;if(browser.ps4)return!1;if(browser.edge)return!1;if(browser.iOS){var userAgent=navigator.userAgent.toLowerCase();if((userAgent.indexOf("os 9")!==-1||userAgent.indexOf("os 8")!==-1)&&userAgent.indexOf("safari")===-1)return!1}if(track){var format=(track.Codec||"").toLowerCase();if("ssa"===format||"ass"===format)return!1}return!0}function requireHlsPlayer(callback){require(["hlsjs"],function(hls){window.Hls=hls,callback()})}function getMediaStreamAudioTracks(mediaSource){return mediaSource.MediaStreams.filter(function(s){return"Audio"===s.Type})}function getMediaStreamTextTracks(mediaSource){return mediaSource.MediaStreams.filter(function(s){return"Subtitle"===s.Type&&"External"===s.DeliveryMethod})}function zoomIn(elem){return new Promise(function(resolve,reject){var duration=240;elem.style.animation="htmlvideoplayer-zoomin "+duration+"ms ease-in normal",dom.addEventListener(elem,dom.whichAnimationEvent(),resolve,{once:!0})})}function normalizeTrackEventText(text){return text.replace(/\\N/gi,"\n")}function setTracks(elem,tracks,item,mediaSource){elem.innerHTML=getTracksHtml(tracks,item,mediaSource)}function getTextTrackUrl(track,item,format){if(itemHelper.isLocalItem(item)&&track.Path)return track.Path;var url=playbackManager.getSubtitleUrl(track,item.ServerId);return format&&(url=url.replace(".vtt",format)),url}function getTracksHtml(tracks,item,mediaSource){return tracks.map(function(t){var defaultAttribute=mediaSource.DefaultSubtitleStreamIndex===t.Index?" default":"",language=t.Language||"und",label=t.Language||"und";return'"}).join("")}function getDefaultProfile(){return new Promise(function(resolve,reject){require(["browserdeviceprofile"],function(profileBuilder){resolve(profileBuilder({}))})})}function HtmlVideoPlayer(){function updateVideoUrl(streamInfo){var isHls=streamInfo.url.toLowerCase().indexOf(".m3u8")!==-1,mediaSource=streamInfo.mediaSource,item=streamInfo.item;if(mediaSource&&item&&!mediaSource.RunTimeTicks&&isHls&&"Transcode"===streamInfo.playMethod&&(browser.iOS||browser.osx)){var hlsPlaylistUrl=streamInfo.url.replace("master.m3u8","live.m3u8");return loading.show(),console.log("prefetching hls playlist: "+hlsPlaylistUrl),connectionManager.getApiClient(item.ServerId).ajax({type:"GET",url:hlsPlaylistUrl}).then(function(){return console.log("completed prefetching hls playlist: "+hlsPlaylistUrl),loading.hide(),streamInfo.url=hlsPlaylistUrl,Promise.resolve()},function(){return console.log("error prefetching hls playlist: "+hlsPlaylistUrl),loading.hide(),Promise.resolve()})}return Promise.resolve()}function setSrcWithFlvJs(instance,elem,options,url){return new Promise(function(resolve,reject){require(["flvjs"],function(flvjs){var flvPlayer=flvjs.createPlayer({type:"flv",url:url},{seekType:"range",lazyLoad:!1});flvPlayer.attachMediaElement(elem),flvPlayer.load(),flvPlayer.play().then(resolve,reject),instance._flvPlayer=flvPlayer,self._currentSrc=url})})}function setSrcWithHlsJs(instance,elem,options,url){return new Promise(function(resolve,reject){requireHlsPlayer(function(){var hls=new Hls({manifestLoadingTimeOut:2e4});hls.loadSource(url),hls.attachMedia(elem),htmlMediaHelper.bindEventsToHlsPlayer(self,hls,elem,onError,resolve,reject),self._hlsPlayer=hls,self._currentSrc=url})})}function setCurrentSrcChromecast(instance,elem,options,url){elem.autoplay=!0;var lrd=new cast.receiver.MediaManager.LoadRequestData;lrd.currentTime=(options.playerStartPositionTicks||0)/1e7,lrd.autoplay=!0,lrd.media=new cast.receiver.media.MediaInformation,lrd.media.contentId=url,lrd.media.contentType=options.mimeType,lrd.media.streamType=cast.receiver.media.StreamType.OTHER,lrd.media.customData=options,console.log("loading media url into mediaManager");try{return mediaManager.load(lrd),self._currentSrc=url,Promise.resolve()}catch(err){return console.log("mediaManager error: "+err),Promise.reject()}}function onMediaManagerLoadMedia(event){self._castPlayer&&self._castPlayer.unload(),self._castPlayer=null;var protocol,data=event.data,media=event.data.media||{},url=media.contentId,contentType=media.contentType.toLowerCase(),ext=(media.customData,"m3u8"),mediaElement=self._mediaElement,host=new cast.player.api.Host({url:url,mediaElement:mediaElement});"m3u8"===ext||"application/x-mpegurl"===contentType||"application/vnd.apple.mpegurl"===contentType?protocol=cast.player.api.CreateHlsStreamingProtocol(host):"mpd"===ext||"application/dash+xml"===contentType?protocol=cast.player.api.CreateDashStreamingProtocol(host):(url.indexOf(".ism")>-1||"application/vnd.ms-sstr+xml"===contentType)&&(protocol=cast.player.api.CreateSmoothStreamingProtocol(host)),console.log("loading playback url: "+url),console.log("contentType: "+contentType),host.onError=function(errorCode){console.log("Fatal Error - "+errorCode)},mediaElement.autoplay=!1,self._castPlayer=new cast.player.api.Player(host),self._castPlayer.load(protocol,data.currentTime||0),self._castPlayer.playWhenHaveEnoughData()}function initMediaManager(){mediaManager.defaultOnLoad=mediaManager.onLoad.bind(mediaManager),mediaManager.onLoad=onMediaManagerLoadMedia.bind(self),mediaManager.defaultOnStop=mediaManager.onStop.bind(mediaManager),mediaManager.onStop=function(event){playbackManager.stop(),mediaManager.defaultOnStop(event)}}function setCurrentSrc(elem,options){elem.removeEventListener("error",onError);var val=options.url;console.log("playing url: "+val);var seconds=(options.playerStartPositionTicks||0)/1e7;seconds&&(val+="#t="+seconds),htmlMediaHelper.destroyHlsPlayer(self),htmlMediaHelper.destroyFlvPlayer(self),htmlMediaHelper.destroyCastPlayer(self);for(var tracks=getMediaStreamTextTracks(options.mediaSource),currentTrackIndex=-1,i=0,length=tracks.length;i'+getTracksHtml(tracks,options.item,options.mediaSource),elem.addEventListener("loadedmetadata",onLoadedMetadata),self._currentSrc=val,htmlMediaHelper.playWithPromise(elem,onError)):htmlMediaHelper.applySrc(elem,val,options).then(function(){return setTracks(elem,tracks,options.item,options.mediaSource),self._currentSrc=val,htmlMediaHelper.playWithPromise(elem,onError)})}function onEnded(){destroyCustomTrack(this),htmlMediaHelper.onEndedInternal(self,this,onError)}function onTimeUpdate(e){var time=this.currentTime;time&&!self._timeUpdated&&(self._timeUpdated=!0,ensureValidVideo(this)),self._currentTime=time;var currentPlayOptions=self._currentPlayOptions;if(currentPlayOptions){var timeMs=1e3*time;timeMs+=(currentPlayOptions.transcodingOffsetTicks||0)/1e4,updateSubtitleText(timeMs)}events.trigger(self,"timeupdate")}function onVolumeChange(){htmlMediaHelper.saveVolume(this.volume),events.trigger(self,"volumechange")}function onNavigatedToOsd(){var dlg=videoDialog;dlg&&(dlg.classList.remove("videoPlayerContainer-withBackdrop"),dlg.classList.remove("videoPlayerContainer-onTop"),onStartedAndNavigatedToOsd())}function onStartedAndNavigatedToOsd(){setCurrentTrackElement(subtitleTrackIndexToSetOnPlaying)}function onPlaying(e){self._started||(self._started=!0,this.removeAttribute("controls"),self._currentPlayOptions.title?(self.originalDocumentTitle=document.title,document.title=self._currentPlayOptions.title):self.originalDocumentTitle=null,loading.hide(),htmlMediaHelper.seekOnPlaybackStart(self,e.target,self._currentPlayOptions.playerStartPositionTicks),self._currentPlayOptions.fullscreen?appRouter.showVideoOsd().then(onNavigatedToOsd):(appRouter.setTransparency("backdrop"),videoDialog.classList.remove("videoPlayerContainer-withBackdrop"),videoDialog.classList.remove("videoPlayerContainer-onTop"),onStartedAndNavigatedToOsd())),events.trigger(self,"playing")}function onPlay(e){events.trigger(self,"unpause")}function ensureValidVideo(elem){if(elem===self._mediaElement&&0===elem.videoWidth&&0===elem.videoHeight){var mediaSource=(self._currentPlayOptions||{}).mediaSource;if(!mediaSource||mediaSource.RunTimeTicks)return void htmlMediaHelper.onErrorInternal(self,"mediadecodeerror")}}function onClick(){events.trigger(self,"click")}function onDblClick(){events.trigger(self,"dblclick")}function onPause(){events.trigger(self,"pause")}function onError(){var errorCode=this.error?this.error.code||0:0,errorMessage=this.error?this.error.message||"":"";console.log("Media element error: "+errorCode.toString()+" "+errorMessage);var type;switch(errorCode){case 1:return;case 2:type="network";break;case 3:if(self._hlsPlayer)return void htmlMediaHelper.handleHlsJsMediaError(self);type="mediadecodeerror";break;case 4:type="medianotsupported";break;default:return}htmlMediaHelper.onErrorInternal(self,type)}function onLoadedMetadata(e){var mediaElem=e.target;if(mediaElem.removeEventListener("loadedmetadata",onLoadedMetadata),!self._hlsPlayer&&!self._shakaPlayer&&!self._flvPlayer)try{mediaElem.play()}catch(err){console.log("error calling mediaElement.play: "+err)}}function destroyCustomTrack(videoElement){if(self._resizeObserver&&(self._resizeObserver.disconnect(),self._resizeObserver=null),window.removeEventListener("orientationchange",onVideoResize),videoSubtitlesElem){var subtitlesContainer=videoSubtitlesElem.parentNode;subtitlesContainer&&tryRemoveElement(subtitlesContainer),videoSubtitlesElem=null}if(currentTrackEvents=null,videoElement)for(var allTracks=videoElement.textTracks||[],i=0;i',videoSubtitlesElem=subtitlesContainer.querySelector(".videoSubtitlesInner"),setSubtitleAppearance(subtitlesContainer,videoSubtitlesElem),videoElement.parentNode.appendChild(subtitlesContainer),currentTrackEvents=data.TrackEvents}})}function setSubtitleAppearance(elem,innerElem){require(["userSettings","subtitleAppearanceHelper"],function(userSettings,subtitleAppearanceHelper){subtitleAppearanceHelper.applyStyles({text:innerElem,window:elem},userSettings.getSubtitleAppearanceSettings())})}function getCueCss(appearance,selector){var html=selector+"::cue {";return html+=appearance.text.map(function(s){return s.name+":"+s.value+"!important;"}).join(""),html+="}"}function setCueAppearance(){require(["userSettings","subtitleAppearanceHelper"],function(userSettings,subtitleAppearanceHelper){var elementId=self.id+"-cuestyle",styleElem=document.querySelector("#"+elementId);styleElem||(styleElem=document.createElement("style"),styleElem.id=elementId,styleElem.type="text/css",document.getElementsByTagName("head")[0].appendChild(styleElem)),styleElem.innerHTML=getCueCss(subtitleAppearanceHelper.getStyles(userSettings.getSubtitleAppearanceSettings(),!0),".htmlvideoplayer")})}function renderTracksEvents(videoElement,track,item){if(!itemHelper.isLocalItem(item)||track.IsExternal){var format=(track.Codec||"").toLowerCase();if("ssa"===format||"ass"===format)return void renderWithLibjass(videoElement,track,item);if(requiresCustomSubtitlesElement())return void renderSubtitlesWithCustomElement(videoElement,track,item)}for(var trackElement=null,expectedId="manualTrack"+track.Index,allTracks=videoElement.textTracks,i=0;i=ticks){selectedTrackEvent=currentTrackEvent;break}}selectedTrackEvent&&selectedTrackEvent.Text?(subtitleTextElement.innerHTML=normalizeTrackEventText(selectedTrackEvent.Text),subtitleTextElement.classList.remove("hide")):subtitleTextElement.classList.add("hide")}}}function setCurrentTrackElement(streamIndex){console.log("Setting new text track index to: "+streamIndex);var mediaStreamTextTracks=getMediaStreamTextTracks(self._currentPlayOptions.mediaSource),track=streamIndex===-1?null:mediaStreamTextTracks.filter(function(t){return t.Index===streamIndex})[0];enableNativeTrackSupport(self._currentSrc,track)?(setTrackForCustomDisplay(self._mediaElement,null),streamIndex!==-1&&setCueAppearance()):(setTrackForCustomDisplay(self._mediaElement,track),streamIndex=-1,track=null);for(var expectedId="textTrack"+streamIndex,trackIndex=streamIndex!==-1&&track?mediaStreamTextTracks.indexOf(track):-1,modes=["disabled","showing","hidden"],allTracks=self._mediaElement.textTracks,i=0;i':'",dlg.innerHTML=html;var videoElement=dlg.querySelector("video");videoElement.volume=htmlMediaHelper.getSavedVolume(),videoElement.addEventListener("timeupdate",onTimeUpdate),videoElement.addEventListener("ended",onEnded),videoElement.addEventListener("volumechange",onVolumeChange),videoElement.addEventListener("pause",onPause),videoElement.addEventListener("playing",onPlaying),videoElement.addEventListener("play",onPlay),videoElement.addEventListener("click",onClick),videoElement.addEventListener("dblclick",onDblClick),document.body.insertBefore(dlg,document.body.firstChild),videoDialog=dlg,self._mediaElement=videoElement,mediaManager&&(mediaManager.embyInit||(initMediaManager(),mediaManager.embyInit=!0),mediaManager.setMediaElement(videoElement)),options.fullscreen&&browser.supportsCssAnimation()&&!browser.slow?zoomIn(dlg).then(function(){resolve(videoElement)}):resolve(videoElement)})})}browser.edgeUwp?this.name="Windows Video Player":this.name="Html Video Player",this.type="mediaplayer",this.id="htmlvideoplayer",this.priority=1;var videoDialog,subtitleTrackIndexToSetOnPlaying,currentClock,currentAssRenderer,videoSubtitlesElem,currentTrackEvents,lastCustomTrackMs=0,customTrackIndex=-1,self=this;self.currentSrc=function(){return self._currentSrc},self.play=function(options){return browser.msie&&"Transcode"===options.playMethod&&!window.MediaSource?(alert("Playback of this content is not supported in Internet Explorer. For a better experience, try a modern browser such as Microsoft Edge, Google Chrome, Firefox or Opera."),Promise.reject()):(self._started=!1,self._timeUpdated=!1,self._currentTime=null,createMediaElement(options).then(function(elem){return updateVideoUrl(options,options.mediaSource).then(function(){return setCurrentSrc(elem,options)})}))},self.setSubtitleStreamIndex=function(index){setCurrentTrackElement(index)},self.setAudioStreamIndex=function(index){var i,length,audioStreams=getMediaStreamAudioTracks(self._currentPlayOptions.mediaSource),audioTrackOffset=-1;for(i=0,length=audioStreams.length;i=100?"none":rawValue/100;elem.style["-webkit-filter"]="brightness("+cssValue+");",elem.style.filter="brightness("+cssValue+")",elem.brightnessValue=val,events.trigger(this,"brightnesschange")}},HtmlVideoPlayer.prototype.getBrightness=function(){var elem=this._mediaElement;if(elem){var val=elem.brightnessValue;return null==val?100:val}},HtmlVideoPlayer.prototype.seekable=function(){var mediaElement=this._mediaElement;if(mediaElement){var seekable=mediaElement.seekable;if(seekable&&seekable.length){var start=seekable.start(0),end=seekable.end(0);return htmlMediaHelper.isValidDuration(start)||(start=0),htmlMediaHelper.isValidDuration(end)||(end=0),end-start>0}return!1}},HtmlVideoPlayer.prototype.pause=function(){var mediaElement=this._mediaElement;mediaElement&&mediaElement.pause()},HtmlVideoPlayer.prototype.resume=function(){var mediaElement=this._mediaElement;mediaElement&&mediaElement.play()},HtmlVideoPlayer.prototype.unpause=function(){var mediaElement=this._mediaElement;mediaElement&&mediaElement.play()},HtmlVideoPlayer.prototype.paused=function(){var mediaElement=this._mediaElement;return!!mediaElement&&mediaElement.paused},HtmlVideoPlayer.prototype.setVolume=function(val){var mediaElement=this._mediaElement;mediaElement&&(mediaElement.volume=val/100)},HtmlVideoPlayer.prototype.getVolume=function(){var mediaElement=this._mediaElement;if(mediaElement)return 100*mediaElement.volume},HtmlVideoPlayer.prototype.volumeUp=function(){this.setVolume(Math.min(this.getVolume()+2,100))},HtmlVideoPlayer.prototype.volumeDown=function(){this.setVolume(Math.max(this.getVolume()-2,0))},HtmlVideoPlayer.prototype.setMute=function(mute){var mediaElement=this._mediaElement;mediaElement&&(mediaElement.muted=mute)},HtmlVideoPlayer.prototype.isMuted=function(){var mediaElement=this._mediaElement;return!!mediaElement&&mediaElement.muted},HtmlVideoPlayer.prototype.setAspectRatio=function(val){},HtmlVideoPlayer.prototype.getAspectRatio=function(){return this._currentAspectRatio},HtmlVideoPlayer.prototype.getSupportedAspectRatios=function(){return[]},HtmlVideoPlayer.prototype.togglePictureInPicture=function(){return this.setPictureInPictureEnabled(!this.isPictureInPictureEnabled())},HtmlVideoPlayer.prototype.getBufferedRanges=function(){var mediaElement=this._mediaElement;return mediaElement?htmlMediaHelper.getBufferedRanges(this,mediaElement):[]},HtmlVideoPlayer.prototype.getStats=function(){var mediaElement=this._mediaElement,playOptions=this._currentPlayOptions||[],categories=[];if(!mediaElement)return Promise.resolve({categories:categories});var mediaCategory={stats:[],type:"media"};if(categories.push(mediaCategory),playOptions.url){var link=document.createElement("a");link.setAttribute("href",playOptions.url);var protocol=(link.protocol||"").replace(":","");protocol&&mediaCategory.stats.push({label:"Protocol:",value:protocol}),link=null}this._hlsPlayer||this._shakaPlayer?mediaCategory.stats.push({label:"Stream type:",value:"HLS"}):mediaCategory.stats.push({label:"Stream type:",value:"Video"});var videoCategory={stats:[],type:"video"};categories.push(videoCategory);var rect=mediaElement.getBoundingClientRect?mediaElement.getBoundingClientRect():{},height=rect.height,width=rect.width;if(width&&height&&videoCategory.stats.push({label:"Player dimensions:",value:width+"x"+height}),height=mediaElement.videoHeight,width=mediaElement.videoWidth,width&&height&&videoCategory.stats.push({label:"Video resolution:",value:width+"x"+height}),mediaElement.getVideoPlaybackQuality){var playbackQuality=mediaElement.getVideoPlaybackQuality(),droppedVideoFrames=playbackQuality.droppedVideoFrames||0;videoCategory.stats.push({label:"Dropped frames:",value:droppedVideoFrames});var corruptedVideoFrames=playbackQuality.corruptedVideoFrames||0;videoCategory.stats.push({label:"Corrupted frames:",value:corruptedVideoFrames})}var audioCategory={stats:[],type:"audio"};categories.push(audioCategory);var sinkId=mediaElement.sinkId;return sinkId&&audioCategory.stats.push({label:"Sink Id:",value:sinkId}),Promise.resolve({categories:categories})},browser.chromecast&&(mediaManager=new cast.receiver.MediaManager(document.createElement("video"))),HtmlVideoPlayer}); \ No newline at end of file diff --git a/dashboard-ui/bower_components/emby-webcomponents/itemhelper.js b/dashboard-ui/bower_components/emby-webcomponents/itemhelper.js index 97a552fd8a..7f4804682f 100644 --- a/dashboard-ui/bower_components/emby-webcomponents/itemhelper.js +++ b/dashboard-ui/bower_components/emby-webcomponents/itemhelper.js @@ -1 +1 @@ -define(["apphost","globalize"],function(appHost,globalize){"use strict";function getDisplayName(item,options){if(!item)throw new Error("null item passed into getDisplayName");options=options||{},"Timer"===item.Type&&(item=item.ProgramInfo||item);var name=("Program"!==item.Type&&"Recording"!==item.Type||!item.IsSeries&&!item.EpisodeTitle?item.Name:item.EpisodeTitle)||"";if("TvChannel"===item.Type)return item.ChannelNumber?item.ChannelNumber+" "+name:name;if("Episode"===item.Type&&0===item.ParentIndexNumber)name=globalize.translate("sharedcomponents#ValueSpecialEpisodeName",name);else if(("Episode"===item.Type||"Program"===item.Type)&&null!=item.IndexNumber&&null!=item.ParentIndexNumber&&options.includeIndexNumber!==!1){var displayIndexNumber=item.IndexNumber,number=displayIndexNumber,nameSeparator=" - ";options.includeParentInfo!==!1?number="S"+item.ParentIndexNumber+":E"+number:nameSeparator=". ",item.IndexNumberEnd&&(displayIndexNumber=item.IndexNumberEnd,number+="-"+displayIndexNumber),number&&(name=name?number+nameSeparator+name:number)}return name}function supportsAddingToCollection(item){var invalidTypes=["Person","Genre","MusicGenre","Studio","GameGenre","BoxSet","Playlist","UserView","CollectionFolder","Audio","TvChannel","Channel","Program","MusicAlbum","Timer","SeriesTimer"];return("Recording"!==item.Type||"Completed"===item.Status)&&(!item.CollectionType&&invalidTypes.indexOf(item.Type)===-1&&"Photo"!==item.MediaType)}function supportsAddingToPlaylist(item){return"Program"!==item.Type&&("TvChannel"!==item.Type&&("Timer"!==item.Type&&("SeriesTimer"!==item.Type&&("Photo"!==item.MediaType&&(("Recording"!==item.Type||"Completed"===item.Status)&&(item.MediaType||item.IsFolder||"Genre"===item.Type||"MusicGenre"===item.Type||"MusicArtist"===item.Type))))))}function canEdit(user,item){var itemType=item.Type;return"UserRootFolder"!==itemType&&"UserView"!==itemType&&("Program"!==itemType&&(("Recording"!==item.Type||"Completed"===item.Status)&&user.Policy.IsAdministrator))}function isLocalItem(item){return!(!item||!item.Id||0!==item.Id.indexOf("local"))}return{getDisplayName:getDisplayName,supportsAddingToCollection:supportsAddingToCollection,supportsAddingToPlaylist:supportsAddingToPlaylist,isLocalItem:isLocalItem,canIdentify:function(user,itemType){return!("Movie"!==itemType&&"Trailer"!==itemType&&"Series"!==itemType&&"Game"!==itemType&&"BoxSet"!==itemType&&"Person"!==itemType&&"Book"!==itemType&&"MusicAlbum"!==itemType&&"MusicArtist"!==itemType||!user.Policy.IsAdministrator)},canEdit:canEdit,canEditImages:function(user,item){var itemType=item.Type;return"Photo"!==item.MediaType&&("UserView"===itemType?!!user.Policy.IsAdministrator:("Recording"!==item.Type||"Completed"===item.Status)&&("Timer"!==itemType&&"SeriesTimer"!==itemType&&canEdit(user,item)))},canSync:function(user,item){return!(user&&!user.Policy.EnableContentDownloading)&&item.SupportsSync},canShare:function(item,user){return"Program"!==item.Type&&("TvChannel"!==item.Type&&("Timer"!==item.Type&&("SeriesTimer"!==item.Type&&(("Recording"!==item.Type||"Completed"===item.Status)&&(user.Policy.EnablePublicSharing&&appHost.supports("sharing"))))))},enableDateAddedDisplay:function(item){return!item.IsFolder&&item.MediaType&&"Program"!==item.Type&&"TvChannel"!==item.Type&&"Trailer"!==item.Type},canMarkPlayed:function(item){if("Program"===item.Type)return!1;if("Video"===item.MediaType){if("TvChannel"!==item.Type)return!0}else if("Audio"===item.MediaType){if("AudioPodcast"===item.Type)return!0;if("AudioBook"===item.Type)return!0}return"Series"===item.Type||"Season"===item.Type||"BoxSet"===item.Type||"Game"===item.MediaType||"Book"===item.MediaType||"Recording"===item.MediaType},canRate:function(item){return"Program"!==item.Type&&"Timer"!==item.Type&&"SeriesTimer"!==item.Type}}}); \ No newline at end of file +define(["apphost","globalize"],function(appHost,globalize){"use strict";function getDisplayName(item,options){if(!item)throw new Error("null item passed into getDisplayName");options=options||{},"Timer"===item.Type&&(item=item.ProgramInfo||item);var name=("Program"!==item.Type&&"Recording"!==item.Type||!item.IsSeries&&!item.EpisodeTitle?item.Name:item.EpisodeTitle)||"";if("TvChannel"===item.Type)return item.ChannelNumber?item.ChannelNumber+" "+name:name;if("Episode"===item.Type&&0===item.ParentIndexNumber)name=globalize.translate("sharedcomponents#ValueSpecialEpisodeName",name);else if(("Episode"===item.Type||"Program"===item.Type)&&null!=item.IndexNumber&&null!=item.ParentIndexNumber&&options.includeIndexNumber!==!1){var displayIndexNumber=item.IndexNumber,number=displayIndexNumber,nameSeparator=" - ";options.includeParentInfo!==!1?number="S"+item.ParentIndexNumber+":E"+number:nameSeparator=". ",item.IndexNumberEnd&&(displayIndexNumber=item.IndexNumberEnd,number+="-"+displayIndexNumber),number&&(name=name?number+nameSeparator+name:number)}return name}function supportsAddingToCollection(item){var invalidTypes=["Person","Genre","MusicGenre","Studio","GameGenre","BoxSet","Playlist","UserView","CollectionFolder","Audio","Program","Timer","SeriesTimer"];return("Recording"!==item.Type||"Completed"===item.Status)&&(!item.CollectionType&&invalidTypes.indexOf(item.Type)===-1&&"Photo"!==item.MediaType)}function supportsAddingToPlaylist(item){return"Program"!==item.Type&&("TvChannel"!==item.Type&&("Timer"!==item.Type&&("SeriesTimer"!==item.Type&&("Photo"!==item.MediaType&&(("Recording"!==item.Type||"Completed"===item.Status)&&(item.MediaType||item.IsFolder||"Genre"===item.Type||"MusicGenre"===item.Type||"MusicArtist"===item.Type))))))}function canEdit(user,item){var itemType=item.Type;return"UserRootFolder"!==itemType&&"UserView"!==itemType&&("Program"!==itemType&&(("Recording"!==item.Type||"Completed"===item.Status)&&user.Policy.IsAdministrator))}function isLocalItem(item){return!(!item||!item.Id||0!==item.Id.indexOf("local"))}return{getDisplayName:getDisplayName,supportsAddingToCollection:supportsAddingToCollection,supportsAddingToPlaylist:supportsAddingToPlaylist,isLocalItem:isLocalItem,canIdentify:function(user,itemType){return!("Movie"!==itemType&&"Trailer"!==itemType&&"Series"!==itemType&&"Game"!==itemType&&"BoxSet"!==itemType&&"Person"!==itemType&&"Book"!==itemType&&"MusicAlbum"!==itemType&&"MusicArtist"!==itemType||!user.Policy.IsAdministrator)},canEdit:canEdit,canEditImages:function(user,item){var itemType=item.Type;return"Photo"!==item.MediaType&&("UserView"===itemType?!!user.Policy.IsAdministrator:("Recording"!==item.Type||"Completed"===item.Status)&&("Timer"!==itemType&&"SeriesTimer"!==itemType&&canEdit(user,item)))},canSync:function(user,item){return!(user&&!user.Policy.EnableContentDownloading)&&item.SupportsSync},canShare:function(item,user){return"Program"!==item.Type&&("TvChannel"!==item.Type&&("Timer"!==item.Type&&("SeriesTimer"!==item.Type&&(("Recording"!==item.Type||"Completed"===item.Status)&&(user.Policy.EnablePublicSharing&&appHost.supports("sharing"))))))},enableDateAddedDisplay:function(item){return!item.IsFolder&&item.MediaType&&"Program"!==item.Type&&"TvChannel"!==item.Type&&"Trailer"!==item.Type},canMarkPlayed:function(item){if("Program"===item.Type)return!1;if("Video"===item.MediaType){if("TvChannel"!==item.Type)return!0}else if("Audio"===item.MediaType){if("AudioPodcast"===item.Type)return!0;if("AudioBook"===item.Type)return!0}return"Series"===item.Type||"Season"===item.Type||"BoxSet"===item.Type||"Game"===item.MediaType||"Book"===item.MediaType||"Recording"===item.MediaType},canRate:function(item){return"Program"!==item.Type&&"Timer"!==item.Type&&"SeriesTimer"!==item.Type}}}); \ No newline at end of file diff --git a/dashboard-ui/dashboard/dashboardhosting.js b/dashboard-ui/dashboard/dashboardhosting.js index 22f028f9b5..a880bb1ae7 100644 --- a/dashboard-ui/dashboard/dashboardhosting.js +++ b/dashboard-ui/dashboard/dashboardhosting.js @@ -1 +1 @@ -define(["loading","libraryMenu","globalize","emby-checkbox"],function(loading,libraryMenu,globalize){"use strict";function onSubmit(e){var form=this,localAddress=form.querySelector("#txtLocalAddress").value,enableUpnp=form.querySelector("#chkEnableUpnp").checked;confirmSelections(localAddress,enableUpnp,function(){var enableHttps=form.querySelector("#chkEnableHttps").checked,certPath=form.querySelector("#txtCertificatePath").value||null,validationResult=getValidationAlert(form);return validationResult?void alertText(validationResult):void validateHttps(enableHttps,certPath).then(function(){loading.show(),ApiClient.getServerConfiguration().then(function(config){config.HttpServerPortNumber=form.querySelector("#txtPortNumber").value,config.PublicPort=form.querySelector("#txtPublicPort").value,config.PublicHttpsPort=form.querySelector("#txtPublicHttpsPort").value,config.EnableHttps=enableHttps,config.HttpsPortNumber=form.querySelector("#txtHttpsPort").value,config.EnableUPnP=enableUpnp,config.WanDdns=form.querySelector("#txtDdns").value,config.CertificatePath=certPath,config.CertificatePassword=form.querySelector("#txtCertPassword").value||null,config.LocalNetworkAddresses=localAddress?[localAddress]:[],ApiClient.updateServerConfiguration(config).then(Dashboard.processServerConfigurationUpdateResult,Dashboard.processErrorResponse)})})}),e.preventDefault()}function getValidationAlert(form){return form.querySelector("#txtPublicPort").value===form.querySelector("#txtPublicHttpsPort").value?"The public http and https ports must be different.":form.querySelector("#txtPortNumber").value===form.querySelector("#txtHttpsPort").value?"The http and https ports must be different.":null}function validateHttps(enableHttps,certPath){return!enableHttps||certPath?Promise.resolve():new Promise(function(resolve,reject){return alertText({title:globalize.translate("TitleHostingSettings"),text:globalize.translate("HttpsRequiresCert")}).then(reject,reject)})}function alertText(options){return new Promise(function(resolve,reject){require(["alert"],function(alert){alert(options).then(resolve,reject)})})}function confirmSelections(localAddress,enableUpnp,callback){localAddress||!enableUpnp?alertText({title:globalize.translate("TitleHostingSettings"),text:globalize.translate("SettingsWarning")}).then(callback):callback()}function getTabs(){return[{href:"dashboardhosting.html",name:globalize.translate("TabHosting")},{href:"serversecurity.html",name:globalize.translate("TabSecurity")}]}return function(view,params){function loadPage(page,config){page.querySelector("#txtPortNumber").value=config.HttpServerPortNumber,page.querySelector("#txtPublicPort").value=config.PublicPort,page.querySelector("#txtPublicHttpsPort").value=config.PublicHttpsPort,page.querySelector("#txtLocalAddress").value=config.LocalNetworkAddresses[0]||"";var chkEnableHttps=page.querySelector("#chkEnableHttps");chkEnableHttps.checked=config.EnableHttps,page.querySelector("#txtHttpsPort").value=config.HttpsPortNumber,page.querySelector("#txtDdns").value=config.WanDdns||"";var txtCertificatePath=page.querySelector("#txtCertificatePath");txtCertificatePath.value=config.CertificatePath||"",page.querySelector("#txtCertPassword").value=config.CertificatePassword||"",page.querySelector("#chkEnableUpnp").checked=config.EnableUPnP,onCertPathChange.call(txtCertificatePath),loading.hide()}function onCertPathChange(){this.value?view.querySelector("#txtDdns").setAttribute("required","required"):view.querySelector("#txtDdns").removeAttribute("required")}view.querySelector("#btnSelectCertPath").addEventListener("click",function(){require(["directorybrowser"],function(directoryBrowser){var picker=new directoryBrowser;picker.show({includeFiles:!0,includeDirectories:!0,callback:function(path){path&&(view.querySelector("#txtCertificatePath").value=path),picker.close()},header:globalize.translate("HeaderSelectCertificatePath")})})}),view.querySelector(".dashboardHostingForm").addEventListener("submit",onSubmit),view.querySelector("#txtCertificatePath").addEventListener("change",onCertPathChange),view.addEventListener("viewshow",function(e){libraryMenu.setTabs("adminadvanced",0,getTabs),loading.show(),ApiClient.getServerConfiguration().then(function(config){loadPage(view,config)})})}}); \ No newline at end of file +define(["loading","libraryMenu","globalize","emby-checkbox"],function(loading,libraryMenu,globalize){"use strict";function onSubmit(e){var form=this,localAddress=form.querySelector("#txtLocalAddress").value,enableUpnp=form.querySelector("#chkEnableUpnp").checked;confirmSelections(localAddress,enableUpnp,function(){var enableHttps=form.querySelector("#chkEnableHttps").checked,certPath=form.querySelector("#txtCertificatePath").value||null,validationResult=getValidationAlert(form);return validationResult?void alertText(validationResult):void validateHttps(enableHttps,certPath).then(function(){loading.show(),ApiClient.getServerConfiguration().then(function(config){config.HttpServerPortNumber=form.querySelector("#txtPortNumber").value,config.PublicPort=form.querySelector("#txtPublicPort").value,config.PublicHttpsPort=form.querySelector("#txtPublicHttpsPort").value,config.EnableHttps=enableHttps,config.RequireHttps=enableHttps,config.HttpsPortNumber=form.querySelector("#txtHttpsPort").value,config.EnableUPnP=enableUpnp,config.WanDdns=form.querySelector("#txtDdns").value,config.CertificatePath=certPath,config.CertificatePassword=form.querySelector("#txtCertPassword").value||null,config.LocalNetworkAddresses=localAddress?[localAddress]:[],ApiClient.updateServerConfiguration(config).then(Dashboard.processServerConfigurationUpdateResult,Dashboard.processErrorResponse)})})}),e.preventDefault()}function getValidationAlert(form){return form.querySelector("#txtPublicPort").value===form.querySelector("#txtPublicHttpsPort").value?"The public http and https ports must be different.":form.querySelector("#txtPortNumber").value===form.querySelector("#txtHttpsPort").value?"The http and https ports must be different.":null}function validateHttps(enableHttps,certPath){return!enableHttps||certPath?Promise.resolve():new Promise(function(resolve,reject){return alertText({title:globalize.translate("TitleHostingSettings"),text:globalize.translate("HttpsRequiresCert")}).then(reject,reject)})}function alertText(options){return new Promise(function(resolve,reject){require(["alert"],function(alert){alert(options).then(resolve,reject)})})}function confirmSelections(localAddress,enableUpnp,callback){localAddress||!enableUpnp?alertText({title:globalize.translate("TitleHostingSettings"),text:globalize.translate("SettingsWarning")}).then(callback):callback()}function getTabs(){return[{href:"dashboardhosting.html",name:globalize.translate("TabHosting")},{href:"serversecurity.html",name:globalize.translate("TabSecurity")}]}return function(view,params){function loadPage(page,config){page.querySelector("#txtPortNumber").value=config.HttpServerPortNumber,page.querySelector("#txtPublicPort").value=config.PublicPort,page.querySelector("#txtPublicHttpsPort").value=config.PublicHttpsPort,page.querySelector("#txtLocalAddress").value=config.LocalNetworkAddresses[0]||"";var chkEnableHttps=page.querySelector("#chkEnableHttps");chkEnableHttps.checked=null==config.RequireHttps?config.EnableHttps:config.RequireHttps,page.querySelector("#txtHttpsPort").value=config.HttpsPortNumber,page.querySelector("#txtDdns").value=config.WanDdns||"";var txtCertificatePath=page.querySelector("#txtCertificatePath");txtCertificatePath.value=config.CertificatePath||"",page.querySelector("#txtCertPassword").value=config.CertificatePassword||"",page.querySelector("#chkEnableUpnp").checked=config.EnableUPnP,onCertPathChange.call(txtCertificatePath),loading.hide()}function onCertPathChange(){this.value?view.querySelector("#txtDdns").setAttribute("required","required"):view.querySelector("#txtDdns").removeAttribute("required")}view.querySelector("#btnSelectCertPath").addEventListener("click",function(){require(["directorybrowser"],function(directoryBrowser){var picker=new directoryBrowser;picker.show({includeFiles:!0,includeDirectories:!0,callback:function(path){path&&(view.querySelector("#txtCertificatePath").value=path),picker.close()},header:globalize.translate("HeaderSelectCertificatePath")})})}),view.querySelector(".dashboardHostingForm").addEventListener("submit",onSubmit),view.querySelector("#txtCertificatePath").addEventListener("change",onCertPathChange),view.addEventListener("viewshow",function(e){libraryMenu.setTabs("adminadvanced",0,getTabs),loading.show(),ApiClient.getServerConfiguration().then(function(config){loadPage(view,config)})})}}); \ No newline at end of file diff --git a/dashboard-ui/dashboardhosting.html b/dashboard-ui/dashboardhosting.html index 8784f4dae6..6e9fae8dfd 100644 --- a/dashboard-ui/dashboardhosting.html +++ b/dashboard-ui/dashboardhosting.html @@ -26,6 +26,11 @@
${LabelPublicHttpsPortHelp}
+
+ +
${LabelExternalDDNSHelp}
+
+
@@ -41,17 +46,12 @@
${LabelCertificatePasswordHelp}
-
- -
${LabelExternalDDNSHelp}
-
-
-
${LabelEnableHttpsHelp}
+
${RequireHttpsHelp}