blob: a248dc8971213e90edd643c0050bb57f7129f4f7 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
import { Button, notification } from "antd";
const audio = new Audio('alarm.mp3');
audio.preload = "auto";
export const timerComplete = (sound, browserNotifications, timer) => {
timer.started = false; // останавливаем
timer.time = 0;
if (sound) {
audio.currentTime = 0;
audio.play();
}
// уведомление
if (browserNotifications) {
const notif = new Notification("Мультитаймер", {
body: `Сработал ${timer.name}`,
icon: "/logo192.png",
});
notif.onclick = () => {
audio.pause();
};
} else {
notification.open({
message: `Сработал ${timer.name}`,
description: (sound && (<Button type="primary" onClick={() => audio.pause()}>Звук выкл.</Button>)),
duration: 12,
onClose: () => {
audio.pause();
},
});
}
}
|