12
12
</template >
13
13
14
14
<script >
15
+ import { linkTo } from " @nextcloud/router"
16
+
15
17
import { showSimpleAlertModal } from " cookbook/js/modals"
16
18
17
19
export default {
@@ -63,6 +65,18 @@ export default {
63
65
},
64
66
mounted () {
65
67
this .resetTimeDisplay ()
68
+ // Start loading the sound early so it's ready to go when we need to
69
+ // play it
70
+
71
+ // Source for the sound https://pixabay.com/sound-effects/alarm-clock-short-6402/
72
+ // Voted by poll https://nextcloud.christian-wolf.click/nextcloud/apps/polls/s/Wke3s6CscDwQEjPV
73
+ this .audio = new Audio (
74
+ linkTo (" cookbook" , " assets/alarm-continuous.mp3" )
75
+ )
76
+
77
+ // For now, the alarm should play continuously until it is dismissed
78
+ // See https://github.com/nextcloud/cookbook/issues/671#issuecomment-1279030452
79
+ this .audio .loop = true
66
80
},
67
81
methods: {
68
82
onTimerEnd () {
@@ -71,7 +85,18 @@ export default {
71
85
window .setTimeout (async () => {
72
86
// The short timeout is needed or Vue doesn't have time to update the countdown
73
87
// display to display 00:00:00
88
+
89
+ // Ensure audio starts at the beggining
90
+ // If it's paused midway, by default it will resume from that point
91
+ this .audio .currentTime = 0
92
+ // Start playing audio to alert the user that the timer is up
93
+ this .audio .play ()
94
+
74
95
await showSimpleAlertModal (t (" cookbook" , " Cooking time is up!" ))
96
+
97
+ // Stop audio after the alert is confirmed
98
+ this .audio .pause ()
99
+
75
100
// cookbook.notify(t('cookbook', 'Cooking time is up!'))
76
101
$this .countdown = null
77
102
$this .showFullTime = false
0 commit comments