working on logging process and adding sounds

This commit is contained in:
2024-12-03 11:56:54 +01:00
parent 17af0f2015
commit 64ca83083e
4 changed files with 44 additions and 6 deletions

View File

@@ -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 {

View File

@@ -32,6 +32,8 @@ export class FocusPage implements OnInit, OnDestroy {
$stats: Observable<FocusStats> = 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;
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
}
}

BIN
src/assets/hardstop.mp3 Normal file

Binary file not shown.

BIN
src/assets/wind-up.mp3 Normal file

Binary file not shown.