Skip to content

Commit 5cdad44

Browse files
committed
Load sound file on startup (cinnyapp#444)
1 parent 43762df commit 5cdad44

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

public/index.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,11 @@
1818
</head>
1919
<body id="appBody">
2020
<div id="root"></div>
21+
<audio id="notificationSound">
22+
<source src="./sound/notification.ogg" type="audio/ogg" />
23+
</audio>
24+
<audio id="inviteSound">
25+
<source src="./sound/invite.ogg" type="audio/ogg" />
26+
</audio>
2127
</body>
2228
</html>

src/client/state/Notifications.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@ import cons from './cons';
66
import navigation from './navigation';
77
import settings from './settings';
88

9-
import NotificationSound from '../../../public/sound/notification.ogg';
10-
import InviteSound from '../../../public/sound/invite.ogg';
11-
129
function isNotifEvent(mEvent) {
1310
const eType = mEvent.getType();
1411
if (!cons.supportEventTypes.includes(eType)) return false;
@@ -238,14 +235,14 @@ class Notifications extends EventEmitter {
238235

239236
_playNotiSound() {
240237
if (!this._notiAudio) {
241-
this._notiAudio = new Audio(NotificationSound);
238+
this._notiAudio = document.getElementById('notificationSound');
242239
}
243240
this._notiAudio.play();
244241
}
245242

246243
_playInviteSound() {
247244
if (!this._inviteAudio) {
248-
this._inviteAudio = new Audio(InviteSound);
245+
this._inviteAudio = document.getElementById('inviteSound');
249246
}
250247
this._inviteAudio.play();
251248
}

src/index.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,10 @@ textarea {
475475
supported by Chrome, Edge, Opera and Firefox */
476476
}
477477

478+
audio:not([controls]) {
479+
display: none !important;
480+
}
481+
478482
.flex--center {
479483
display: flex;
480484
justify-content: center;

0 commit comments

Comments
 (0)