text: var TcHmi;!function(TcHmi){let Controls;!function(Controls){let Beckhoff;!function(Beckhoff){class TcHmiAudio extends TcHmi.Controls.System.TcHmiControl{constructor(element,pcElement,attrs){super(element,pcElement,attrs),this.__duration=0,this.__currentTime=0,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.TcHmiAudio, Id="+this.getId()+"] Could not load or play any requested audio files. Perhaps the file format is not supported on this device."),this.getIsEnabled()&&(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.__elemAudio.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.TcHmiAudio, 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_TcHmiAudio-template"),this.__elementBorder=this.__elementTemplateRoot.find(".TcHmi_Controls_Beckhoff_TcHmiAudio-template-border"),this.__elementFocusBorder=this.__elementTemplateRoot.find(".TcHmi_Controls_Beckhoff_TcHmiAudio-template-focus-border");let elemAudio=this.__elementTemplateRoot.find(".TcHmi_Controls_Beckhoff_TcHmiAudio-template-content");if(0===this.__elementTemplateRoot.length||0===this.__elementBorder.length||0===this.__elementFocusBorder.length||0===elemAudio.length)throw new Error("Invalid Template.html");this.__elemAudio=elemAudio[0],super.__previnit()}__init(){super.__init();const passiveEventOptions={passive:!0,capture:!1};this.__elemAudio.addEventListener("loadeddata",this.__loadeddataHandler,!!TCHMI_EVENT_OPTION_OBJECT_SUPPORTED&&passiveEventOptions),this.__elemAudio.addEventListener("error",this.__onError,!!TCHMI_EVENT_OPTION_OBJECT_SUPPORTED&&passiveEventOptions),this.__elemAudio.addEventListener("volumechange",this.__volumechangeHandler,!!TCHMI_EVENT_OPTION_OBJECT_SUPPORTED&&passiveEventOptions),this.__elemAudio.addEventListener("ratechange",this.__ratechangeHandler,!!TCHMI_EVENT_OPTION_OBJECT_SUPPORTED&&passiveEventOptions),this.__elemAudio.addEventListener("durationchange",this.__durationchangeHandler,!!TCHMI_EVENT_OPTION_OBJECT_SUPPORTED&&passiveEventOptions),this.__elemAudio.addEventListener("timeupdate",this.__timeupdateHandler,!!TCHMI_EVENT_OPTION_OBJECT_SUPPORTED&&passiveEventOptions),this.__elemAudio.addEventListener("ended",this.__endedHandler,!!TCHMI_EVENT_OPTION_OBJECT_SUPPORTED&&passiveEventOptions),this.__elemAudio.addEventListener("playing",this.__onPlayingChange,!!TCHMI_EVENT_OPTION_OBJECT_SUPPORTED&&passiveEventOptions),this.__elemAudio.addEventListener("pause",this.__onPlayingChange,!!TCHMI_EVENT_OPTION_OBJECT_SUPPORTED&&passiveEventOptions)}__attach(){super.__attach(),this.__processControls(),TcHmi.Access.checkAccess(this,"observe")&&this.getIsEnabled()&&this.__elemAudio.load()}__detach(){super.__detach()}destroy(){if(this.__keepAlive)return;const passiveEventOptions={passive:!0,capture:!1};this.__elemAudio.removeEventListener("loadeddata",this.__loadeddataHandler,!!TCHMI_EVENT_OPTION_OBJECT_SUPPORTED&&passiveEventOptions),this.__elemAudio.removeEventListener("error",this.__onError,!!TCHMI_EVENT_OPTION_OBJECT_SUPPORTED&&passiveEventOptions),this.__elemAudio.removeEventListener("volumechange",this.__volumechangeHandler,!!TCHMI_EVENT_OPTION_OBJECT_SUPPORTED&&passiveEventOptions),this.__elemAudio.removeEventListener("ratechange",this.__ratechangeHandler,!!TCHMI_EVENT_OPTION_OBJECT_SUPPORTED&&passiveEventOptions),this.__elemAudio.removeEventListener("durationchange",this.__durationchangeHandler,!!TCHMI_EVENT_OPTION_OBJECT_SUPPORTED&&passiveEventOptions),this.__elemAudio.removeEventListener("timeupdate",this.__timeupdateHandler,!!TCHMI_EVENT_OPTION_OBJECT_SUPPORTED&&passiveEventOptions),this.__elemAudio.removeEventListener("ended",this.__endedHandler,!!TCHMI_EVENT_OPTION_OBJECT_SUPPORTED&&passiveEventOptions),this.__elemAudio.removeEventListener("playing",this.__onPlayingChange,!!TCHMI_EVENT_OPTION_OBJECT_SUPPORTED&&passiveEventOptions),this.__elemAudio.removeEventListener("pause",this.__onPlayingChange,!!TCHMI_EVENT_OPTION_OBJECT_SUPPORTED&&passiveEventOptions),super.destroy()}__processAccessConfig(){super.__processAccessConfig(),this.__processSrcList()}__processIsEnabled(){super.__processIsEnabled(),this.__processSrcList()}__onLoadedData(){return e=>{void 0!==this.__playbackrate&&null!==this.__playbackrate&&this.__processPlaybackrate(),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.__elemAudio.volume,mute=this.__elemAudio.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.__elemAudio.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.__elemAudio.ended)}}__onRateChange(){return e=>{this.__playbackrate=this.__elemAudio.playbackRate,TcHmi.EventProvider.raise(this.__id+".onPropertyChanged",{propertyName:"Playbackrate"})}}__onTimeUpdate(){return e=>{this.__currentTime=this.__elemAudio.currentTime,TcHmi.EventProvider.raise(this.__id+".onPropertyChanged",{propertyName:"CurrentTime"}),TcHmi.EventProvider.raise(this.__id+".onTimeUpdate")}}getDuration(){return this.__duration}getIsEnded(){return this.__elemAudio.ended}getIsPlaying(){return!this.__elemAudio.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;let removeSources=()=>{for(;this.__elemAudio.firstChild;)this.__elemAudio.removeChild(this.__elemAudio.firstChild)};if(!0!==TcHmi.Access.checkAccess(this,"observe"))return void removeSources();if(!this.getIsEnabled())return void removeSources();let loadNeeded=!1;if(this.__srcList){let ii=this.__srcList.length;for(;this.__elemAudio.childElementCount>ii;)this.__elemAudio.removeChild(this.__elemAudio.lastElementChild);for(let i=0;i<ii;i++){let currentSourceElem,vs=this.__srcList[i];i<this.__elemAudio.childElementCount?currentSourceElem=this.__elemAudio.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.__elemAudio.insertBefore(currentSourceElem,this.__elemAudio.lastElementChild?this.__elemAudio.lastElementChild.nextSibling:null)}this.__elemAudio.lastChild&&this.__elemAudio.lastChild.nodeType!==Node.TEXT_NODE&&this.__elemAudio.appendChild(document.createTextNode("HTML5 Audio support is missing..."))}else this.__elemAudio.childElementCount&&(loadNeeded=!0,removeSources());loadNeeded&&this.__elemAudio.load(),TcHmi.EventProvider.raise(this.__id+".onIsPlayingChange",!this.__elemAudio.paused)}play(){if(!0!==TcHmi.Access.checkAccess(this,"operate"))return;if(!this.getIsEnabled())return;const playPromise=this.__elemAudio.play();void 0!==playPromise&&playPromise.then(result=>{}).catch(error=>{TCHMI_CONSOLE_LOG_LEVEL>=2&&TcHmi.Log.warn("[Source=Framework, Module=TcHmi.System.ThemeManager] Audio playback was prevented. Please set audio control to mute or activate audio with user interaction.")})}pause(){!0===TcHmi.Access.checkAccess(this,"operate")&&this.getIsEnabled()&&this.__elemAudio.pause()}stop(){!0===TcHmi.Access.checkAccess(this,"operate")&&this.getIsEnabled()&&(this.__currentTime=0,this.__elemAudio.currentTime=0,this.pause())}skipBackward(valueNew){!0===TcHmi.Access.checkAccess(this,"operate")&&this.getIsEnabled()&&null!=valueNew&&(isNaN(valueNew)||(this.__elemAudio.currentTime-=valueNew))}skipForward(valueNew){!0===TcHmi.Access.checkAccess(this,"operate")&&this.getIsEnabled()&&null!=valueNew&&(isNaN(valueNew)||(this.__elemAudio.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.__elemAudio.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.__elemAudio.controls=this.__controls:this.__elemAudio.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.__elemAudio.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.__elemAudio.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.__elemAudio.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.__elemAudio.loop=this.__loop)}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.__elemAudio.playbackRate=this.__playbackrate}catch(ex){}}}Beckhoff.TcHmiAudio=TcHmiAudio}(Beckhoff=Controls.Beckhoff||(Controls.Beckhoff={}))}(Controls=TcHmi.Controls||(TcHmi.Controls={}))}(TcHmi||(TcHmi={})),TcHmi.Controls.registerEx("TcHmiAudio","TcHmi.Controls.Beckhoff",TcHmi.Controls.Beckhoff.TcHmiAudio);