working on logging process and adding sounds
This commit is contained in:
@@ -24,7 +24,14 @@ export class FocusStats {
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
// nothing
|
// 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 {
|
get focusCycles(): number {
|
||||||
|
|||||||
@@ -32,6 +32,8 @@ export class FocusPage implements OnInit, OnDestroy {
|
|||||||
$stats: Observable<FocusStats> = this.focusService.$stats;
|
$stats: Observable<FocusStats> = this.focusService.$stats;
|
||||||
|
|
||||||
private endOfTimerChime: HTMLAudioElement;
|
private endOfTimerChime: HTMLAudioElement;
|
||||||
|
private forcedEndOfTimerChime: HTMLAudioElement;
|
||||||
|
private windUpChime: HTMLAudioElement;
|
||||||
|
|
||||||
pathD: string = 'M100 10 A90 90 0 1 1 0 0';
|
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) {
|
constructor(private renderer: Renderer2, private focusService: FocusService) {
|
||||||
this.endOfTimerChime = new Audio('../../../assets/race-start-beeps-125125.mp3');
|
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() {
|
ngOnInit() {
|
||||||
@@ -72,9 +76,16 @@ export class FocusPage implements OnInit, OnDestroy {
|
|||||||
|
|
||||||
if (progress >= 1) {
|
if (progress >= 1) {
|
||||||
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 => {
|
this.endOfTimerChime.play().catch(error => {
|
||||||
console.error('Error playing audio:', error);
|
console.error('Error playing audio:', error);
|
||||||
});
|
});
|
||||||
|
}
|
||||||
clearInterval(this.interval);
|
clearInterval(this.interval);
|
||||||
this.timerStarted = null;
|
this.timerStarted = null;
|
||||||
}
|
}
|
||||||
@@ -121,27 +132,47 @@ export class FocusPage implements OnInit, OnDestroy {
|
|||||||
stopTimer() {
|
stopTimer() {
|
||||||
this.focusRuns = 0;
|
this.focusRuns = 0;
|
||||||
this.state = FocusState.STOPPED;
|
this.state = FocusState.STOPPED;
|
||||||
|
this.stopStatsCounter();
|
||||||
this.startTimer(0);
|
this.startTimer(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private stopStatsCounter() {
|
||||||
|
this.focusService.stopCurrent(this.timerStarted !== null);
|
||||||
|
}
|
||||||
|
|
||||||
focus() {
|
focus() {
|
||||||
|
this.windUpChime.play().catch(error => {
|
||||||
|
console.error('Error playing audio:', error);
|
||||||
|
});
|
||||||
this.state = FocusState.FOCUS;
|
this.state = FocusState.FOCUS;
|
||||||
this.startTimer(25);
|
this.stopStatsCounter();
|
||||||
|
this.focusService.startFocus();
|
||||||
|
this.startTimer(1); // 25
|
||||||
}
|
}
|
||||||
|
|
||||||
reload() {
|
reload() {
|
||||||
|
this.windUpChime.play().catch(error => {
|
||||||
|
console.error('Error playing audio:', error);
|
||||||
|
});
|
||||||
if (!!this.timerStarted) {
|
if (!!this.timerStarted) {
|
||||||
this.focusRuns = 0;
|
this.focusRuns = 0;
|
||||||
}
|
}
|
||||||
this.state = FocusState.SHORT_BREAK;
|
this.state = FocusState.SHORT_BREAK;
|
||||||
this.startTimer(5);
|
this.stopStatsCounter();
|
||||||
|
this.focusService.startShortBreak();
|
||||||
|
this.startTimer(0.3); // 5
|
||||||
}
|
}
|
||||||
|
|
||||||
recharge() {
|
recharge() {
|
||||||
|
this.windUpChime.play().catch(error => {
|
||||||
|
console.error('Error playing audio:', error);
|
||||||
|
});
|
||||||
if (!!this.timerStarted) {
|
if (!!this.timerStarted) {
|
||||||
this.focusRuns = 0;
|
this.focusRuns = 0;
|
||||||
}
|
}
|
||||||
this.state = FocusState.LONG_BREAK;
|
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
BIN
src/assets/hardstop.mp3
Normal file
Binary file not shown.
BIN
src/assets/wind-up.mp3
Normal file
BIN
src/assets/wind-up.mp3
Normal file
Binary file not shown.
Reference in New Issue
Block a user