| private alertInterval: any; | private alertInterval: any; | ||||
| private alertDuration: number = 10000; | private alertDuration: number = 10000; | ||||
| private audio = new Audio(); | private audio = new Audio(); | ||||
| isPlay = false; | |||||
| constructor() { | constructor() { | ||||
| this.audio.src = 'assets/sound/alarm_5m.mp3'; | this.audio.src = 'assets/sound/alarm_5m.mp3'; | ||||
| this.audio.load(); | this.audio.load(); | ||||
| } | } | ||||
| playSound(): void { | playSound(): void { | ||||
| this.isPlay = true; | |||||
| this.audio.play().catch((error) => { | this.audio.play().catch((error) => { | ||||
| console.error('Error playing audio:', error); | console.error('Error playing audio:', error); | ||||
| }); | }); | ||||
| state1: boolean, | state1: boolean, | ||||
| state2: boolean, | state2: boolean, | ||||
| ): void { | ): void { | ||||
| if (state5 && isReady && (state1 || state2)) { | |||||
| if (state5 && isReady && (state1 || state2) && !this.isPlay) { | |||||
| this.playSound(); | this.playSound(); | ||||
| this.alertInterval = setInterval(() => { | this.alertInterval = setInterval(() => { | ||||
| this.stopAlarm(); | this.stopAlarm(); | ||||
| stopAlarm(): void { | stopAlarm(): void { | ||||
| this.stopSound(); | this.stopSound(); | ||||
| clearInterval(this.alertInterval); | clearInterval(this.alertInterval); | ||||
| this.isPlay = false; | |||||
| } | } | ||||
| simulateClick(element: HTMLElement) { | simulateClick(element: HTMLElement) { |