text: var TcHmi;!function(TcHmi){let Controls;!function(Controls){let Beckhoff;!function(Beckhoff){class TcHmiVideo extends TcHmi.Controls.System.TcHmiControl{constructor(element,pcElement,attrs){super(element,pcElement,attrs),this.__duration=0,this.__currentTime=0,this.__runtimeWidthNeededForHeight=!1,this.__runtimeHeightNeededForWidth=!1,this.__onResizedEventDestroyEvent=null,this.__onError=evt=>{evt.currentTarget instanceof HTMLElement&&(evt.currentTarget instanceof HTMLSourceElement&&evt.currentTarget.nextElementSibling&&evt.currentTarget.nextElementSibling instanceof HTMLSourceElement||(TCHMI_CONSOLE_LOG_LEVEL>=1&&TcHmi.Log.error("[Source=Control, Module=TcHmi.Controls.Beckhoff.TcHmiVideo, Id="+this.getId()+"] Could not load or play any requested video files. Perhaps the file format is not supported on this device."),this.getIsEnabled()&&("Content"===this.getHeightMode()&&this.__processHeight(),"Content"===this.getWidthMode()&&this.__processWidth(),TcHmi.EventProvider.raise(this.__id+".onError",evt),TcHmi.EventProvider.raise(this.__id+".onPropertyChanged",{propertyName:"OriginalWidth"}),TcHmi.EventProvider.raise(this.__id+".onPropertyChanged",{propertyName:"OriginalHeight"}),TcHmi.EventProvider.raise(this.__id+".onPropertyChanged",{propertyName:"CurrentTime"}),TcHmi.EventProvider.raise(this.__id+".onPropertyChanged",{propertyName:"IsPlaying"}))))},this.__onPlayingChange=e=>{TcHmi.EventProvider.raise(this.__id+".onPropertyChanged",{propertyName:"CurrentTime"}),TcHmi.EventProvider.raise(this.__id+".onPropertyChanged",{propertyName:"IsPlaying"}),TcHmi.EventProvider.raise(this.__id+".onIsPlayingChange",!this.__elemVideo.paused)},this.__onResolverForSrcListWatchCallback=data=>{!1===this.__isAttached&&this.__suspendObjectResolver("srcList"),data.error===TcHmi.Errors.NONE?tchmi_equal(data.value,this.__srcList)||(this.__srcList=data.value,TcHmi.EventProvider.raise(this.__id+".onPropertyChanged",{propertyName:"SrcList"}),this.__processSrcList()):TCHMI_CONSOLE_LOG_LEVEL>=1&&TcHmi.Log.error("[Source=Control, Module=TcHmi.Controls.Beckhoff.TcHmiVideo, Id="+this.getId()+", Attribute=SrcList] Resolving symbols from object failed with error: "+TcHmi.Log.buildMessage(data.details))},this.__loadeddataHandler=this.__onLoadedData(),this.__volumechangeHandler=this.__onVolumeChange(),this.__ratechangeHandler=this.__onRateChange(),this.__durationchangeHandler=this.__onDurationChange(),this.__timeupdateHandler=this.__onTimeUpdate(),this.__endedHandler=this.__onEnded()}__previnit(){this.__elementTemplateRoot=this.__element.find(".TcHmi_Controls_Beckhoff_TcHmiVideo-template"),0===this.__elementTemplateRoot.length&&(this.__elementTemplateRoot=this.__element.find(".tchmi-video-template")),this.__elementBorder=this.__elementTemplateRoot.find(".TcHmi_Controls_Beckhoff_TcHmiVideo-template-border"),0===this.__elementBorder.length&&(this.__elementBorder=this.__elementTemplateRoot.find(".tchmi-video-template-border")),this.__elementFocusBorder=this.__elementTemplateRoot.find(".TcHmi_Controls_Beckhoff_TcHmiVideo-template-focus-border"),0===this.__elementFocusBorder.length&&(this.__elementFocusBorder=this.__elementTemplateRoot.find(".tchmi-video-template-focus-border"));let elemVideo=this.__elementTemplateRoot.find(".TcHmi_Controls_Beckhoff_TcHmiVideo-template-content");if(0===elemVideo.length&&(elemVideo=this.__elementTemplateRoot.find(".tchmi-video-template-content")),0===this.__elementTemplateRoot.length||0===this.__elementBorder.length||0===this.__elementFocusBorder.length||0===elemVideo.length)throw new Error("Invalid Template.html");this.__elemVideo=elemVideo[0],super.__previnit()}__init(){super.__init();const passiveEventOptions={passive:!0,capture:!1};this.__elemVideo.addEventListener("loadeddata",this.__loadeddataHandler,!!TCHMI_EVENT_OPTION_OBJECT_SUPPORTED&&passiveEventOptions),this.__elemVideo.addEventListener("error",this.__onError,!!TCHMI_EVENT_OPTION_OBJECT_SUPPORTED&&passiveEventOptions),this.__elemVideo.addEventListener("volumechange",this.__volumechangeHandler,!!TCHMI_EVENT_OPTION_OBJECT_SUPPORTED&&passiveEventOptions),this.__elemVideo.addEventListener("ratechange",this.__ratechangeHandler,!!TCHMI_EVENT_OPTION_OBJECT_SUPPORTED&&passiveEventOptions),this.__elemVideo.addEventListener("durationchange",this.__durationchangeHandler,!!TCHMI_EVENT_OPTION_OBJECT_SUPPORTED&&passiveEventOptions),this.__elemVideo.addEventListener("timeupdate",this.__timeupdateHandler,!!TCHMI_EVENT_OPTION_OBJECT_SUPPORTED&&passiveEventOptions),this.__elemVideo.addEventListener("ended",this.__endedHandler,!!TCHMI_EVENT_OPTION_OBJECT_SUPPORTED&&passiveEventOptions),this.__elemVideo.addEventListener("playing",this.__onPlayingChange,!!TCHMI_EVENT_OPTION_OBJECT_SUPPORTED&&passiveEventOptions),this.__elemVideo.addEventListener("pause",this.__onPlayingChange,!!TCHMI_EVENT_OPTION_OBJECT_SUPPORTED&&passiveEventOptions)}__attach(){super.__attach(),this.__processControls(),TcHmi.Access.checkAccess(this,"observe")&&this.getIsEnabled()&&this.__elemVideo.load()}__detach(){super.__detach(),null!==this.__onResizedEventDestroyEvent&&(this.__onResizedEventDestroyEvent(),this.__onResizedEventDestroyEvent=null)}destroy(){if(this.__keepAlive)return;const passiveEventOptions={passive:!0,capture:!1};this.__elemVideo.removeEventListener("loadeddata",this.__loadeddataHandler,!!TCHMI_EVENT_OPTION_OBJECT_SUPPORTED&&passiveEventOptions),this.__elemVideo.removeEventListener("error",this.__onError,!!TCHMI_EVENT_OPTION_OBJECT_SUPPORTED&&passiveEventOptions),this.__elemVideo.removeEventListener("volumechange",this.__volumechangeHandler,!!TCHMI_EVENT_OPTION_OBJECT_SUPPORTED&&passiveEventOptions),this.__elemVideo.removeEventListener("ratechange",this.__ratechangeHandler,!!TCHMI_EVENT_OPTION_OBJECT_SUPPORTED&&passiveEventOptions),this.__elemVideo.removeEventListener("durationchange",this.__durationchangeHandler,!!TCHMI_EVENT_OPTION_OBJECT_SUPPORTED&&passiveEventOptions),this.__elemVideo.removeEventListener("timeupdate",this.__timeupdateHandler,!!TCHMI_EVENT_OPTION_OBJECT_SUPPORTED&&passiveEventOptions),this.__elemVideo.removeEventListener("ended",this.__endedHandler,!!TCHMI_EVENT_OPTION_OBJECT_SUPPORTED&&passiveEventOptions),this.__elemVideo.removeEventListener("playing",this.__onPlayingChange,!!TCHMI_EVENT_OPTION_OBJECT_SUPPORTED&&passiveEventOptions),this.__elemVideo.removeEventListener("pause",this.__onPlayingChange,!!TCHMI_EVENT_OPTION_OBJECT_SUPPORTED&&passiveEventOptions),super.destroy()}__onResized(){return(evt,ctrl)=>{!0===this.__runtimeHeightNeededForWidth?this.__processWidth():!0===this.__runtimeWidthNeededForHeight&&this.__processHeight()}}__processWidth(){if("Content"===this.getWidthMode()){let newWidthStr="";const contentPixelSize=this.__getContentWidth();null!==contentPixelSize&&(newWidthStr=contentPixelSize+"px"),TcHmi.StyleProvider.setSimpleElementStyle(this.__element,"width",newWidthStr)}super.__processWidth(),"Content"===this.getHeightMode()&&"Content"!==this.getWidthMode()&&this.__processHeight()}__processHeight(){if("Content"===this.getHeightMode()){this.__intHeight=null;const contentPixelSize=this.__getContentHeight();null!==contentPixelSize&&(this.__intHeight=contentPixelSize+"px")}super.__processHeight(),"Content"===this.getWidthMode()&&"Content"!==this.getHeightMode()&&this.__processWidth()}setWidthMode(valueNew){let convertedValue=TcHmi.ValueConverter.toSizeModeWithContent(valueNew);null===convertedValue&&(convertedValue=this.getAttributeDefaultValueInternal("WidthMode")),convertedValue!==this.__widthMode&&(this.__widthMode=convertedValue,TcHmi.EventProvider.raise(this.__id+".onPropertyChanged",{propertyName:"WidthMode"}),this.__processWidthMode(),"Content"===convertedValue&&"Content"===this.getHeightMode()&&this.__processHeightMode())}setHeightMode(valueNew){let convertedValue=TcHmi.ValueConverter.toSizeModeWithContent(valueNew);null===convertedValue&&(convertedValue=this.getAttributeDefaultValueInternal("HeightMode")),convertedValue!==this.__heightMode&&(this.__heightMode=convertedValue,TcHmi.EventProvider.raise(this.__id+".onPropertyChanged",{propertyName:"HeightMode"}),this.__processHeightMode(),"Content"===convertedValue&&"Content"===this.getHeightMode()&&this.__processWidthMode())}__getContentWidth(){this.__runtimeHeightNeededForWidth=!1;return"Content"!==this.getWidthMode()?super.__getContentWidth():this.__srcList?"px"!==this.__widthUnit?null:TCHMI_DESIGNER?320:0===this.__elemVideo.videoHeight||0===this.__elemVideo.videoWidth?null:"Content"===this.getHeightMode()?this.__elemVideo.videoWidth:null!==this.__height&&void 0!==this.__height&&"Value"===this.getHeightMode()?this.__height*this.__elemVideo.videoWidth/this.__elemVideo.videoHeight:(this.__runtimeHeightNeededForWidth=!0,null===this.__onResizedEventDestroyEvent&&(this.__onResizedEventDestroyEvent=TcHmi.EventProvider.register(this.__id+".onResized",this.__onResized())),!1===this.__isAttached?null:this.__element.height()*this.__elemVideo.videoWidth/this.__elemVideo.videoHeight):null}__getContentHeight(){this.__runtimeWidthNeededForHeight=!1;return"Content"!==this.getHeightMode()?super.__getContentHeight():this.__srcList?"px"!==this.__heightUnit?null:TCHMI_DESIGNER?240:0===this.__elemVideo.videoHeight||0===this.__elemVideo.videoWidth?null:"Content"===this.getWidthMode()?this.__elemVideo.videoHeight:null!==this.__width&&void 0!==this.__width&&"Value"===this.getWidthMode()?this.__width*this.__elemVideo.videoHeight/this.__elemVideo.videoWidth:(this.__runtimeWidthNeededForHeight=!0,null===this.__onResizedEventDestroyEvent&&(this.__onResizedEventDestroyEvent=TcHmi.EventProvider.register(this.__id+".onResized",this.__onResized())),!1===this.__isAttached?null:this.__element.width()*this.__elemVideo.videoHeight/this.__elemVideo.videoWidth):null}__processAccessConfig(){super.__processAccessConfig(),this.__processSrcList(),this.__processPoster()}__processIsEnabled(){super.__processIsEnabled(),this.__processSrcList(),this.__processPoster()}__onLoadedData(){return e=>{void 0!==this.__playbackrate&&null!==this.__playbackrate&&this.__processPlaybackrate(),"Content"===this.getHeightMode()&&this.__processHeight(),"Content"===this.getWidthMode()&&this.__processWidth(),TcHmi.EventProvider.raise(this.__id+".onLoadedData"),TcHmi.EventProvider.raise(this.__id+".onPropertyChanged",{propertyName:"OriginalWidth"}),TcHmi.EventProvider.raise(this.__id+".onPropertyChanged",{propertyName:"OriginalHeight"}),TcHmi.EventProvider.raise(this.__id+".onPropertyChanged",{propertyName:"CurrentTime"}),TcHmi.EventProvider.raise(this.__id+".onPropertyChanged",{propertyName:"IsPlaying"})}}__onVolumeChange(){return e=>{let volume=this.__elemVideo.volume,mute=this.__elemVideo.muted;mute!==this.__mute&&(this.__mute=mute,TcHmi.EventProvider.raise(this.__id+".onPropertyChanged",{propertyName:"Mute"})),volume!==this.__volume&&(this.__volume=volume,TcHmi.EventProvider.raise(this.__id+".onVolumeChange",this.__volume),TcHmi.EventProvider.raise(this.__id+".onPropertyChanged",{propertyName:"Volume"}),this.__volume>0&&this.__mute?(this.__mute=!1,TcHmi.EventProvider.raise(this.__id+".onPropertyChanged",{propertyName:"Mute"})):0===this.__volume&&!0===this.__mute&&(this.__mute=!0,TcHmi.EventProvider.raise(this.__id+".onPropertyChanged",{propertyName:"Mute"})))}}__onDurationChange(){return e=>{this.__duration=this.__elemVideo.duration,isNaN(this.__duration)&&(this.__duration=0),TcHmi.EventProvider.raise(this.__id+".onPropertyChanged",{propertyName:"Duration"}),TcHmi.EventProvider.raise(this.__id+".onDurationChange",this.__duration)}}__onEnded(){return e=>{TcHmi.EventProvider.raise(this.__id+".onPropertyChanged",{propertyName:"IsEnded"}),TcHmi.EventProvider.raise(this.__id+".onIsEndedChange",this.__elemVideo.ended)}}__onRateChange(){return e=>{this.__playbackrate=this.__elemVideo.playbackRate,TcHmi.EventProvider.raise(this.__id+".onPropertyChanged",{propertyName:"Playbackrate"})}}__onTimeUpdate(){return e=>{this.__currentTime=this.__elemVideo.currentTime,TcHmi.EventProvider.raise(this.__id+".onPropertyChanged",{propertyName:"CurrentTime"}),TcHmi.EventProvider.raise(this.__id+".onTimeUpdate")}}getDuration(){return this.__duration}getIsEnded(){return this.__elemVideo.ended}getIsPlaying(){return!this.__elemVideo.paused}setSrcList(valueNew){let convertedValue=TcHmi.ValueConverter.toObject(valueNew);null===convertedValue&&(convertedValue=this.getAttributeDefaultValueInternal("SrcList"));let resolverInfo=this.__objectResolvers.get("srcList");resolverInfo&&(resolverInfo.watchDestroyer&&resolverInfo.watchDestroyer(),resolverInfo.resolver.destroy());let resolver=new TcHmi.Symbol.ObjectResolver(convertedValue);this.__objectResolvers.set("srcList",{resolver:resolver,watchCallback:this.__onResolverForSrcListWatchCallback,watchDestroyer:resolver.watch(this.__onResolverForSrcListWatchCallback)})}getSrcList(){return this.__srcList}__processSrcList(){if(!0===TCHMI_DESIGNER)return;if(!0!==TcHmi.Access.checkAccess(this,"observe")||!this.getIsEnabled())return void(this.__elemVideo.textContent="");let loadNeeded=!1;if(this.__srcList){let ii=this.__srcList.length;for(;this.__elemVideo.childElementCount>ii;)this.__elemVideo.removeChild(this.__elemVideo.lastElementChild);for(let i=0;i<ii;i++){var vs=this.__srcList[i];let currentSourceElem;i<this.__elemVideo.childElementCount?currentSourceElem=this.__elemVideo.children[i]:(currentSourceElem=document.createElement("source"),currentSourceElem.addEventListener("error",this.__onError)),vs.source!==currentSourceElem.getAttribute("src")&&(currentSourceElem.src=vs.source,loadNeeded=!0),vs.type!==currentSourceElem.type&&(currentSourceElem.type=vs.type,loadNeeded=!0),currentSourceElem.parentElement||this.__elemVideo.insertBefore(currentSourceElem,this.__elemVideo.lastElementChild?this.__elemVideo.lastElementChild.nextSibling:null)}this.__elemVideo.lastChild&&this.__elemVideo.lastChild.nodeType!==Node.TEXT_NODE&&this.__elemVideo.appendChild(document.createTextNode("HTML5 Video support is missing..."))}else this.__elemVideo.childElementCount&&(loadNeeded=!0,this.__elemVideo.textContent="");loadNeeded&&this.__elemVideo.load(),TcHmi.EventProvider.raise(this.__id+".onIsPlayingChange",!this.__elemVideo.paused)}play(){if(!0!==TcHmi.Access.checkAccess(this,"operate"))return;if(!this.getIsEnabled())return;const playPromise=this.__elemVideo.play();void 0!==playPromise&&playPromise.then(result=>{}).catch(error=>{TCHMI_CONSOLE_LOG_LEVEL>=2&&TcHmi.Log.warn("[Source=Framework, Module=TcHmi.System.ThemeManager] Video playback was prevented. Please set video control to mute or activate video with user interaction.")})}pause(){!0===TcHmi.Access.checkAccess(this,"operate")&&this.getIsEnabled()&&this.__elemVideo.pause()}stop(){!0===TcHmi.Access.checkAccess(this,"operate")&&this.getIsEnabled()&&(this.__currentTime=0,this.__elemVideo.currentTime=0,this.pause())}skipBackward(valueNew){!0===TcHmi.Access.checkAccess(this,"operate")&&this.getIsEnabled()&&null!=valueNew&&(isNaN(valueNew)||(this.__elemVideo.currentTime-=valueNew))}skipForward(valueNew){!0===TcHmi.Access.checkAccess(this,"operate")&&this.getIsEnabled()&&null!=valueNew&&(isNaN(valueNew)||(this.__elemVideo.currentTime+=valueNew))}setCurrentTime(valueNew){if(!0!==TcHmi.Access.checkAccess(this,"operate"))return;if(!1===this.getIsEnabled())return;let convertedValue=TcHmi.ValueConverter.toNumber(valueNew);null===convertedValue&&(convertedValue=this.getAttributeDefaultValueInternal("CurrentTime")),convertedValue!==this.__currentTime&&null!==convertedValue&&(this.__currentTime=convertedValue,TcHmi.EventProvider.raise(this.__id+".onPropertyChanged",{propertyName:"CurrentTime"}),this.__processCurrentTime())}getCurrentTime(){return this.__currentTime}__processCurrentTime(){this.__elemVideo.currentTime=this.__currentTime}setControls(valueNew){let convertedValue=TcHmi.ValueConverter.toBoolean(valueNew);null===convertedValue&&(convertedValue=this.getAttributeDefaultValueInternal("Controls")),convertedValue!==this.__controls&&(this.__controls=convertedValue,TcHmi.EventProvider.raise(this.__id+".onPropertyChanged",{propertyName:"Controls"}),this.__processControls())}getControls(){return this.__controls}__processControls(){void 0!==this.__controls&&(!0===TcHmi.Access.checkAccess(this,"operate")?this.__elemVideo.controls=this.__controls:this.__elemVideo.controls=!1)}setVolume(valueNew){let convertedValue=TcHmi.ValueConverter.toNumber(valueNew);null===convertedValue&&(convertedValue=this.getAttributeDefaultValueInternal("Volume")),convertedValue!==this.__volume&&(this.__volume=convertedValue,TcHmi.EventProvider.raise(this.__id+".onPropertyChanged",{propertyName:"Volume"}),this.__processVolume())}getVolume(){return this.__volume}__processVolume(){if(void 0===this.__volume)return;let volume=this.__volume;volume=volume<0?0:volume,volume=volume>1?1:volume,this.__elemVideo.volume=volume}setAutoplay(valueNew){let convertedValue=TcHmi.ValueConverter.toBoolean(valueNew);null===convertedValue&&(convertedValue=this.getAttributeDefaultValueInternal("Autoplay")),convertedValue!==this.__autoplay&&(this.__autoplay=convertedValue,TcHmi.EventProvider.raise(this.__id+".onPropertyChanged",{propertyName:"Autoplay"}),this.__processAutoplay())}getAutoplay(){return this.__autoplay}__processAutoplay(){void 0!==this.__autoplay&&(this.__elemVideo.autoplay=this.__autoplay)}setMute(valueNew){let convertedValue=TcHmi.ValueConverter.toBoolean(valueNew);null===convertedValue&&(convertedValue=this.getAttributeDefaultValueInternal("Mute")),convertedValue!==this.__mute&&(this.__mute=convertedValue,TcHmi.EventProvider.raise(this.__id+".onPropertyChanged",{propertyName:"Mute"}),this.__processMute())}getMute(){return this.__mute}__processMute(){void 0!==this.__mute&&(this.__elemVideo.muted=this.__mute)}setLoop(valueNew){let convertedValue=TcHmi.ValueConverter.toBoolean(valueNew);null===convertedValue&&(convertedValue=this.getAttributeDefaultValueInternal("Loop")),convertedValue!==this.__loop&&(this.__loop=convertedValue,TcHmi.EventProvider.raise(this.__id+".onPropertyChanged",{propertyName:"Loop"}),this.__processLoop())}getLoop(){return this.__loop}__processLoop(){void 0!==this.__loop&&(this.__elemVideo.loop=this.__loop)}setPoster(valueNew){let convertedValue=TcHmi.ValueConverter.toString(valueNew);null===convertedValue&&(convertedValue=this.getAttributeDefaultValueInternal("Poster")),convertedValue!==this.__poster&&(this.__poster=convertedValue,TcHmi.EventProvider.raise(this.__id+".onPropertyChanged",{propertyName:"Poster"}),this.__processPoster())}getPoster(){return this.__poster}__processPoster(){!0===TcHmi.Access.checkAccess(this,"observe")&&!1!==this.getIsEnabled()&&(this.__poster?this.__elemVideo.poster=this.__poster:this.__elemVideo.poster="")}setPlaybackrate(valueNew){let convertedValue=TcHmi.ValueConverter.toNumber(valueNew);null===convertedValue&&(convertedValue=this.getAttributeDefaultValueInternal("Playbackrate")),convertedValue!==this.__playbackrate&&(this.__playbackrate=convertedValue,TcHmi.EventProvider.raise(this.__id+".onPropertyChanged",{propertyName:"Playbackrate"}),this.__processPlaybackrate())}getPlaybackrate(){return this.__playbackrate}__processPlaybackrate(){if(null!==this.__playbackrate&&void 0!==this.__playbackrate)try{this.__elemVideo.playbackRate=this.__playbackrate}catch(ex){}}getOriginalWidth(){return this.__elemVideo.videoWidth}getOriginalHeight(){return this.__elemVideo.videoHeight}}Beckhoff.TcHmiVideo=TcHmiVideo}(Beckhoff=Controls.Beckhoff||(Controls.Beckhoff={})),Controls.registerEx("TcHmiVideo","TcHmi.Controls.Beckhoff",TcHmi.Controls.Beckhoff.TcHmiVideo)}(Controls=TcHmi.Controls||(TcHmi.Controls={}))}(TcHmi||(TcHmi={}));