diff --git a/src/app/pages/modus/focus/focus-stats.ts b/src/app/pages/modus/focus/focus-stats.ts index b0953fb..418d7e1 100644 --- a/src/app/pages/modus/focus/focus-stats.ts +++ b/src/app/pages/modus/focus/focus-stats.ts @@ -24,7 +24,14 @@ export class FocusStats { break; default: // nothing + break; } + console.log("stas after inc", state, "with", deltaInMs); + console.log("focusCylces", this._focusCycles); + console.log("focusTime" , this._focusTimeInMs); + console.log("shortBreakCycles", this._shortBreakCycles); + console.log("longBreakCycles", this._longBreakCycles); + console.log("beeakTime", this._breakTimeInMs); } get focusCycles(): number { diff --git a/src/app/pages/modus/focus/focus.component.ts b/src/app/pages/modus/focus/focus.component.ts index bf6c8b0..ae032a1 100644 --- a/src/app/pages/modus/focus/focus.component.ts +++ b/src/app/pages/modus/focus/focus.component.ts @@ -32,6 +32,8 @@ export class FocusPage implements OnInit, OnDestroy { $stats: Observable = this.focusService.$stats; private endOfTimerChime: HTMLAudioElement; + private forcedEndOfTimerChime: HTMLAudioElement; + private windUpChime: HTMLAudioElement; pathD: string = 'M100 10 A90 90 0 1 1 0 0'; @@ -39,6 +41,8 @@ export class FocusPage implements OnInit, OnDestroy { constructor(private renderer: Renderer2, private focusService: FocusService) { this.endOfTimerChime = new Audio('../../../assets/race-start-beeps-125125.mp3'); + this.forcedEndOfTimerChime = new Audio('../../../assets/hardstop.mp3'); + this.windUpChime = new Audio('../../../assets/wind-up.mp3'); } ngOnInit() { @@ -72,9 +76,16 @@ export class FocusPage implements OnInit, OnDestroy { if (progress >= 1) { progress = 1; - this.endOfTimerChime.play().catch(error => { - console.error('Error playing audio:', error); - }); + if (this.duration === 0) { + this.forcedEndOfTimerChime.play().catch(error => { + console.error('Error playing audio:', error); + }); + } + else { + this.endOfTimerChime.play().catch(error => { + console.error('Error playing audio:', error); + }); + } clearInterval(this.interval); this.timerStarted = null; } @@ -121,27 +132,47 @@ export class FocusPage implements OnInit, OnDestroy { stopTimer() { this.focusRuns = 0; this.state = FocusState.STOPPED; + this.stopStatsCounter(); this.startTimer(0); } + private stopStatsCounter() { + this.focusService.stopCurrent(this.timerStarted !== null); + } + focus() { + this.windUpChime.play().catch(error => { + console.error('Error playing audio:', error); + }); this.state = FocusState.FOCUS; - this.startTimer(25); + this.stopStatsCounter(); + this.focusService.startFocus(); + this.startTimer(1); // 25 } reload() { + this.windUpChime.play().catch(error => { + console.error('Error playing audio:', error); + }); if (!!this.timerStarted) { this.focusRuns = 0; } this.state = FocusState.SHORT_BREAK; - this.startTimer(5); + this.stopStatsCounter(); + this.focusService.startShortBreak(); + this.startTimer(0.3); // 5 } recharge() { + this.windUpChime.play().catch(error => { + console.error('Error playing audio:', error); + }); if (!!this.timerStarted) { this.focusRuns = 0; } this.state = FocusState.LONG_BREAK; - this.startTimer(15); + this.stopStatsCounter(); + this.focusService.startLongBreak(); + this.startTimer(0.5); // 15 } } diff --git a/src/assets/hardstop.mp3 b/src/assets/hardstop.mp3 new file mode 100644 index 0000000..774af07 Binary files /dev/null and b/src/assets/hardstop.mp3 differ diff --git a/src/assets/wind-up.mp3 b/src/assets/wind-up.mp3 new file mode 100644 index 0000000..70828ec Binary files /dev/null and b/src/assets/wind-up.mp3 differ