text: var TcHmi;!function(s){var e,t,n,i;function o(e,t,i){var o=n.call(this,e,t,i)||this;return o.__duration=0,o.__currentTime=0,o.__runtimeWidthNeededForHeight=!1,o.__runtimeHeightNeededForWidth=!1,o.__onResizedEventDestroyEvent=null,o.__objectResolvers=new Map,o.__onError=function(e){e.currentTarget instanceof HTMLElement&&(e.currentTarget instanceof HTMLSourceElement&&e.currentTarget.nextElementSibling&&e.currentTarget.nextElementSibling instanceof HTMLSourceElement||(s.Log.error("[Source=Control, Module=TcHmi.Controls.Beckhoff.TcHmiVideo, Id="+o.getId()+"] Could not load or play any requested video files. Perhaps the file format is not supported on this device."),!0===o.getIsEnabled()&&("Content"===o.getHeightMode()&&o.__processHeight(),"Content"===o.getWidthMode()&&o.__processWidth(),s.EventProvider.raise(o.__id+".onError",e),s.EventProvider.raise(o.__id+".onFunctionResultChanged",["getOriginalWidth","getOriginalHeight","getCurrentTime","getIsPlaying"]))))},o.__onPlayingChange=function(e){s.EventProvider.raise(o.__id+".onFunctionResultChanged",["getCurrentTime","getIsPlaying"]),s.EventProvider.raise(o.__id+".onIsPlayingChange",!o.__elemVideo.paused)},o.__onResolverForSrcListWatchCallback=function(e){!1===o.__isAttached&&e.destroy&&e.destroy(),tchmi_equal(e.value,o.__srcList)||(o.__srcList=e.value,s.EventProvider.raise(o.__id+".onFunctionResultChanged",["getSrcList"]),o.__processSrcList())},o.__loadeddataHandler=o.__onLoadedData(),o.__volumechangeHandler=o.__onVolumeChange(),o.__ratechangeHandler=o.__onRateChange(),o.__durationchangeHandler=o.__onDurationChange(),o.__timeupdateHandler=o.__onTimeUpdate(),o.__endedHandler=o.__onEnded(),o}e=s.Controls||(s.Controls={}),t=e.Beckhoff||(e.Beckhoff={}),n=s.Controls.System.TcHmiControl,__extends(o,n),o.prototype.__previnit=function(){this.__elementTemplateRoot=this.__element.find(".tchmi-video-template"),this.__elementBorder=this.__elementTemplateRoot.find(".tchmi-video-template-border"),this.__elementFocusBorder=this.__elementTemplateRoot.find(".tchmi-video-template-focus-border");var e=this.__elementTemplateRoot.find(".tchmi-video-template-content");if(0===this.__elementTemplateRoot.length||0===this.__elementBorder.length||0===this.__elementFocusBorder.length||0===e.length)throw new Error("Invalid Template.html");this.__elemVideo=e[0],n.prototype.__previnit.call(this)},o.prototype.__init=function(){n.prototype.__init.call(this)},o.prototype.__attach=function(){n.prototype.__attach.call(this),this.__processControls(),s.Access.checkAccess(this,"observe")&&this.getIsEnabled()&&this.__elemVideo.load();var e={passive:!0,capture:!1};this.__elemVideo.addEventListener("loadeddata",this.__loadeddataHandler,!!TCHMI_EVENT_OPTION_OBJECT_SUPPORTED&&e),this.__elemVideo.addEventListener("error",this.__onError,!!TCHMI_EVENT_OPTION_OBJECT_SUPPORTED&&e),this.__elemVideo.addEventListener("volumechange",this.__volumechangeHandler,!!TCHMI_EVENT_OPTION_OBJECT_SUPPORTED&&e),this.__elemVideo.addEventListener("ratechange",this.__ratechangeHandler,!!TCHMI_EVENT_OPTION_OBJECT_SUPPORTED&&e),this.__elemVideo.addEventListener("durationchange",this.__durationchangeHandler,!!TCHMI_EVENT_OPTION_OBJECT_SUPPORTED&&e),this.__elemVideo.addEventListener("timeupdate",this.__timeupdateHandler,!!TCHMI_EVENT_OPTION_OBJECT_SUPPORTED&&e),this.__elemVideo.addEventListener("ended",this.__endedHandler,!!TCHMI_EVENT_OPTION_OBJECT_SUPPORTED&&e),this.__elemVideo.addEventListener("playing",this.__onPlayingChange,!!TCHMI_EVENT_OPTION_OBJECT_SUPPORTED&&e),this.__elemVideo.addEventListener("pause",this.__onPlayingChange,!!TCHMI_EVENT_OPTION_OBJECT_SUPPORTED&&e),this.__objectResolvers.forEach(function(e){return e.resolver.watch(e.watchCallback)})},o.prototype.__detach=function(){n.prototype.__detach.call(this);var e={passive:!0,capture:!1};this.__elemVideo.removeEventListener("loadeddata",this.__loadeddataHandler,!!TCHMI_EVENT_OPTION_OBJECT_SUPPORTED&&e),this.__elemVideo.removeEventListener("error",this.__onError,!!TCHMI_EVENT_OPTION_OBJECT_SUPPORTED&&e),this.__elemVideo.removeEventListener("volumechange",this.__volumechangeHandler,!!TCHMI_EVENT_OPTION_OBJECT_SUPPORTED&&e),this.__elemVideo.removeEventListener("ratechange",this.__ratechangeHandler,!!TCHMI_EVENT_OPTION_OBJECT_SUPPORTED&&e),this.__elemVideo.removeEventListener("durationchange",this.__durationchangeHandler,!!TCHMI_EVENT_OPTION_OBJECT_SUPPORTED&&e),this.__elemVideo.removeEventListener("timeupdate",this.__timeupdateHandler,!!TCHMI_EVENT_OPTION_OBJECT_SUPPORTED&&e),this.__elemVideo.removeEventListener("ended",this.__endedHandler,!!TCHMI_EVENT_OPTION_OBJECT_SUPPORTED&&e),this.__elemVideo.removeEventListener("playing",this.__onPlayingChange,!!TCHMI_EVENT_OPTION_OBJECT_SUPPORTED&&e),this.__elemVideo.removeEventListener("pause",this.__onPlayingChange,!!TCHMI_EVENT_OPTION_OBJECT_SUPPORTED&&e),null!==this.__onResizedEventDestroyEvent&&(this.__onResizedEventDestroyEvent(),this.__onResizedEventDestroyEvent=null),this.__objectResolvers.forEach(function(e){e.watchDestroyer&&(e.watchDestroyer(),e.watchDestroyer=null)})},o.prototype.destroy=function(){this.__objectResolvers.forEach(function(e){e.watchDestroyer&&e.watchDestroyer(),e.resolver.destroy()}),this.__objectResolvers.clear(),n.prototype.destroy.call(this)},o.prototype.__onResized=function(){var i=this;return function(e,t){!0===i.__runtimeHeightNeededForWidth?i.__processWidth():!0===i.__runtimeWidthNeededForHeight&&i.__processHeight()}},o.prototype.__processWidth=function(){if("Content"===this.getWidthMode()){var e="",t=this.__getContentWidth();null!==t&&(e=t+"px"),s.StyleProvider.setSimpleElementStyle(this.__element,"width",e)}n.prototype.__processWidth.call(this),"Content"===this.getHeightMode()&&"Content"!==this.getWidthMode()&&this.__processHeight()},o.prototype.__processHeight=function(){if("Content"===this.getHeightMode()){this.__intHeight=null;var e=this.__getContentHeight();null!==e&&(this.__intHeight=e+"px")}n.prototype.__processHeight.call(this),"Content"===this.getWidthMode()&&"Content"!==this.getHeightMode()&&this.__processWidth()},o.prototype.setWidthMode=function(e){var t=s.ValueConverter.toSizeModeWithContent(e);null===t&&(t=this.getAttributeDefaultValueInternal("WidthMode")),t!==this.__widthMode&&(this.__widthMode=t,s.EventProvider.raise(this.__id+".onFunctionResultChanged",["getWidthMode"]),this.__processWidthMode(),"Content"===t&&"Content"===this.getHeightMode()&&this.__processHeightMode())},o.prototype.setHeightMode=function(e){var t=s.ValueConverter.toSizeModeWithContent(e);null===t&&(t=this.getAttributeDefaultValueInternal("HeightMode")),t!==this.__heightMode&&(this.__heightMode=t,s.EventProvider.raise(this.__id+".onFunctionResultChanged",["getHeightMode"]),this.__processHeightMode(),"Content"===t&&"Content"===this.getHeightMode()&&this.__processWidthMode())},o.prototype.__getContentWidth=function(){return this.__runtimeHeightNeededForWidth=!1,"Content"!==this.getWidthMode()?n.prototype.__getContentWidth.call(this):this.__srcList&&"px"===this.__widthUnit?TCHMI_ENABLE_DESIGNER_MODE_MASTER?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=s.EventProvider.register(this.__id+".onResized",this.__onResized())),!1===this.__isAttached?null:this.__element.height()*this.__elemVideo.videoWidth/this.__elemVideo.videoHeight):null},o.prototype.__getContentHeight=function(){return this.__runtimeWidthNeededForHeight=!1,"Content"!==this.getHeightMode()?n.prototype.__getContentHeight.call(this):this.__srcList&&"px"===this.__heightUnit?TCHMI_ENABLE_DESIGNER_MODE_MASTER?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=s.EventProvider.register(this.__id+".onResized",this.__onResized())),!1===this.__isAttached?null:this.__element.width()*this.__elemVideo.videoHeight/this.__elemVideo.videoWidth):null},o.prototype.__processAccessConfig=function(){n.prototype.__processAccessConfig.call(this),this.__processSrcList(),this.__processPoster()},o.prototype.__processIsEnabled=function(){n.prototype.__processIsEnabled.call(this),this.__processSrcList(),this.__processPoster()},o.prototype.__onLoadedData=function(){var t=this;return function(e){void 0!==t.__playbackrate&&null!==t.__playbackrate&&t.__processPlaybackrate(),"Content"===t.getHeightMode()&&t.__processHeight(),"Content"===t.getWidthMode()&&t.__processWidth(),s.EventProvider.raise(t.__id+".onLoadedData"),s.EventProvider.raise(t.__id+".onFunctionResultChanged",["getOriginalWidth","getOriginalHeight","getCurrentTime","getIsPlaying"])}},o.prototype.__onVolumeChange=function(){var o=this;return function(e){var t=o.__elemVideo.volume,i=o.__elemVideo.muted;i!==o.__mute&&(o.__mute=i,s.EventProvider.raise(o.__id+".onFunctionResultChanged",["getMute"])),t!==o.__volume&&(o.__volume=t,s.EventProvider.raise(o.__id+".onVolumeChange",o.__volume),s.EventProvider.raise(o.__id+".onFunctionResultChanged",["getVolume"]),0<o.__volume&&o.__mute?(o.__mute=!1,s.EventProvider.raise(o.__id+".onFunctionResultChanged",["getMute"])):0===o.__volume&&!0===o.__mute&&(o.__mute=!0,s.EventProvider.raise(o.__id+".onFunctionResultChanged",["getMute"])))}},o.prototype.__onDurationChange=function(){var t=this;return function(e){t.__duration=t.__elemVideo.duration,isNaN(t.__duration)&&(t.__duration=0),s.EventProvider.raise(t.__id+".onFunctionResultChanged",["getDuration"]),s.EventProvider.raise(t.__id+".onDurationChange",t.__duration)}},o.prototype.__onEnded=function(){var t=this;return function(e){s.EventProvider.raise(t.__id+".onFunctionResultChanged",["getIsEnded"]),s.EventProvider.raise(t.__id+".onIsEndedChange",t.__elemVideo.ended)}},o.prototype.__onRateChange=function(){var t=this;return function(e){t.__playbackrate=t.__elemVideo.playbackRate,s.EventProvider.raise(t.__id+".onFunctionResultChanged",["getPlaybackrate"])}},o.prototype.__onTimeUpdate=function(){var t=this;return function(e){t.__currentTime=t.__elemVideo.currentTime,s.EventProvider.raise(t.__id+".onFunctionResultChanged",["getCurrentTime"]),s.EventProvider.raise(t.__id+".onTimeUpdate")}},o.prototype.getDuration=function(){return this.__duration},o.prototype.getIsEnded=function(){return this.__elemVideo.ended},o.prototype.getIsPlaying=function(){return!this.__elemVideo.paused},o.prototype.setSrcList=function(e){var t=s.ValueConverter.toObject(e);null===t&&(t=this.getAttributeDefaultValueInternal("SrcList"));var i=this.__objectResolvers.get("srcList");i&&(i.watchDestroyer&&i.watchDestroyer(),i.resolver.destroy());var o=new s.Symbol.ObjectResolver(t);this.__objectResolvers.set("srcList",{resolver:o,watchCallback:this.__onResolverForSrcListWatchCallback,watchDestroyer:o.watch(this.__onResolverForSrcListWatchCallback)})},o.prototype.getSrcList=function(){return this.__srcList},o.prototype.__processSrcList=function(){var e=this;if(!0!==TCHMI_ENABLE_DESIGNER_MODE_MASTER){function t(){for(;e.__elemVideo.firstChild;)e.__elemVideo.removeChild(e.__elemVideo.firstChild)}if(!0===s.Access.checkAccess(this,"observe"))if(!1!==this.getIsEnabled()){var i=!1;if(this.__srcList){for(var o=this.__srcList.length;this.__elemVideo.childElementCount>o;)this.__elemVideo.removeChild(this.__elemVideo.lastElementChild);for(var n=0;n<o;n++){var _=this.__srcList[n],r=void 0;n<this.__elemVideo.childElementCount?r=this.__elemVideo.children[n]:(r=document.createElement("source")).addEventListener("error",this.__onError),_.source!==r.getAttribute("src")&&(r.src=_.source,i=!0),_.type!==r.type&&(r.type=_.type,i=!0),r.parentElement||this.__elemVideo.insertBefore(r,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&&(i=!0,t());i&&this.__elemVideo.load(),s.EventProvider.raise(this.__id+".onIsPlayingChange",!this.__elemVideo.paused)}else t();else t()}},o.prototype.play=function(){if(!0===s.Access.checkAccess(this,"operate")&&!1!==this.getIsEnabled()){var e=this.__elemVideo.play();void 0!==e&&e.then(function(e){}).catch(function(e){s.Log.warn("[Source=Framework, Module=TcHmi.System.ThemeManager] Video playback was prevented. Please set video control to mute or activate video with user interaction.")})}},o.prototype.pause=function(){!0===s.Access.checkAccess(this,"operate")&&!1!==this.getIsEnabled()&&this.__elemVideo.pause()},o.prototype.stop=function(){!0===s.Access.checkAccess(this,"operate")&&!1!==this.getIsEnabled()&&(this.__currentTime=0,this.__elemVideo.currentTime=0,this.pause())},o.prototype.skipBackward=function(e){!0===s.Access.checkAccess(this,"operate")&&!1!==this.getIsEnabled()&&null!=e&&(isNaN(e)||(this.__elemVideo.currentTime-=-e))},o.prototype.skipForward=function(e){!0===s.Access.checkAccess(this,"operate")&&!1!==this.getIsEnabled()&&null!=e&&(isNaN(e)||(this.__elemVideo.currentTime+=e))},o.prototype.setCurrentTime=function(e){if(!0===s.Access.checkAccess(this,"operate")&&!1!==this.getIsEnabled()){var t=s.ValueConverter.toNumber(e);null===t&&(t=this.getAttributeDefaultValueInternal("CurrentTime")),t!==this.__currentTime&&null!==t&&(this.__currentTime=t,s.EventProvider.raise(this.__id+".onFunctionResultChanged",["getCurrentTime"]),this.__processCurrentTime())}},o.prototype.getCurrentTime=function(){return this.__currentTime},o.prototype.__processCurrentTime=function(){this.__elemVideo.currentTime=this.__currentTime},o.prototype.setControls=function(e){var t=s.ValueConverter.toBoolean(e);null===t&&(t=this.getAttributeDefaultValueInternal("Controls")),t!==this.__controls&&(this.__controls=t,s.EventProvider.raise(this.__id+".onFunctionResultChanged",["getControls"]),this.__processControls())},o.prototype.getControls=function(){return this.__controls},o.prototype.__processControls=function(){void 0!==this.__controls&&(!0===s.Access.checkAccess(this,"operate")?this.__elemVideo.controls=this.__controls:this.__elemVideo.controls=!1)},o.prototype.setVolume=function(e){var t=s.ValueConverter.toNumber(e);null===t&&(t=this.getAttributeDefaultValueInternal("Volume")),t!==this.__volume&&(this.__volume=t,s.EventProvider.raise(this.__id+".onFunctionResultChanged",["getVolume"]),this.__processVolume())},o.prototype.getVolume=function(){return this.__volume},o.prototype.__processVolume=function(){if(void 0!==this.__volume){var e=this.__volume;e=1<(e=e<0?0:e)?1:e,this.__elemVideo.volume=e}},o.prototype.setAutoplay=function(e){var t=s.ValueConverter.toBoolean(e);null===t&&(t=this.getAttributeDefaultValueInternal("Autoplay")),t!==this.__autoplay&&(this.__autoplay=t,s.EventProvider.raise(this.__id+".onFunctionResultChanged",["getAutoplay"]),this.__processAutoplay())},o.prototype.getAutoplay=function(){return this.__autoplay},o.prototype.__processAutoplay=function(){void 0!==this.__autoplay&&(this.__elemVideo.autoplay=this.__autoplay)},o.prototype.setMute=function(e){var t=s.ValueConverter.toBoolean(e);null===t&&(t=this.getAttributeDefaultValueInternal("Mute")),t!==this.__mute&&(this.__mute=t,s.EventProvider.raise(this.__id+".onFunctionResultChanged",["getMute"]),this.__processMute())},o.prototype.getMute=function(){return this.__mute},o.prototype.__processMute=function(){void 0!==this.__mute&&(this.__elemVideo.muted=this.__mute)},o.prototype.setLoop=function(e){var t=s.ValueConverter.toBoolean(e);null===t&&(t=this.getAttributeDefaultValueInternal("Loop")),t!==this.__loop&&(this.__loop=t,s.EventProvider.raise(this.__id+".onFunctionResultChanged",["getLoop"]),this.__processLoop())},o.prototype.getLoop=function(){return this.__loop},o.prototype.__processLoop=function(){void 0!==this.__loop&&(this.__elemVideo.loop=this.__loop)},o.prototype.setPoster=function(e){var t=s.ValueConverter.toString(e);null===t&&(t=this.getAttributeDefaultValueInternal("Poster")),t!==this.__poster&&(this.__poster=t,s.EventProvider.raise(this.__id+".onFunctionResultChanged",["getPoster"]),this.__processPoster())},o.prototype.getPoster=function(){return this.__poster},o.prototype.__processPoster=function(){!0===s.Access.checkAccess(this,"observe")&&!1!==this.getIsEnabled()&&(this.__poster?this.__elemVideo.poster=this.__poster:this.__elemVideo.poster="")},o.prototype.setPlaybackrate=function(e){var t=s.ValueConverter.toNumber(e);null===t&&(t=this.getAttributeDefaultValueInternal("Playbackrate")),t!==this.__playbackrate&&(this.__playbackrate=t,s.EventProvider.raise(this.__id+".onFunctionResultChanged",["getPlaybackrate"]),this.__processPlaybackrate())},o.prototype.getPlaybackrate=function(){return this.__playbackrate},o.prototype.__processPlaybackrate=function(){if(null!==this.__playbackrate&&void 0!==this.__playbackrate)try{this.__elemVideo.playbackRate=this.__playbackrate}catch(e){}},o.prototype.getOriginalWidth=function(){return this.__elemVideo.videoWidth},o.prototype.getOriginalHeight=function(){return this.__elemVideo.videoHeight},i=o,t.TcHmiVideo=i,e.register("tchmi-video",s.Controls.Beckhoff.TcHmiVideo,"Beckhoff/TcHmiVideo/","Beckhoff/TcHmiVideo/Template.html")}(TcHmi=TcHmi||{});