Skip to content

Commit 03089d1

Browse files
Merge pull request #1120 from MarcelRobitaille/671-timer-alarm-sound
Add timer alarm sound
2 parents 69724a0 + d329e02 commit 03089d1

File tree

4 files changed

+36
-1
lines changed

4 files changed

+36
-1
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
## [Unreleased]
22

3+
### Added
4+
- Add alarm sound to timers
5+
[#1120](https://github.com/nextcloud/cookbook/pull/1120) @MarcelRobitaille
6+
37
### Changed
48
- Create build script for GitHub pages with GitHub actions to allow for custom building
59
[#1203](https://github.com/nextcloud/cookbook/pull/1203) @christianlupus

assets/alarm-continuous.mp3

37 KB
Binary file not shown.

package-lock.json

+7-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/RecipeTimer.vue

+25
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
</template>
1313

1414
<script>
15+
import { linkTo } from "@nextcloud/router"
16+
1517
import { showSimpleAlertModal } from "cookbook/js/modals"
1618
1719
export default {
@@ -63,6 +65,18 @@ export default {
6365
},
6466
mounted() {
6567
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
6680
},
6781
methods: {
6882
onTimerEnd() {
@@ -71,7 +85,18 @@ export default {
7185
window.setTimeout(async () => {
7286
// The short timeout is needed or Vue doesn't have time to update the countdown
7387
// 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+
7495
await showSimpleAlertModal(t("cookbook", "Cooking time is up!"))
96+
97+
// Stop audio after the alert is confirmed
98+
this.audio.pause()
99+
75100
// cookbook.notify(t('cookbook', 'Cooking time is up!'))
76101
$this.countdown = null
77102
$this.showFullTime = false

0 commit comments

Comments
 (0)