Load sound file on startup (#444)
authorAjay Bura <ajbura@gmail.com>
Tue, 3 May 2022 07:48:27 +0000 (13:18 +0530)
committerAjay Bura <ajbura@gmail.com>
Tue, 3 May 2022 07:48:27 +0000 (13:18 +0530)
public/index.html
src/client/state/Notifications.js
src/index.scss

index a4a3119639f9ba6d88776ba65fd88ac88330c79a..aa6a95ecd6c382af79f3fdd9043eaa2af5dc0b22 100644 (file)
 </head>
 <body id="appBody">
     <div id="root"></div>
+    <audio id="notificationSound">
+        <source src="./sound/notification.ogg" type="audio/ogg" />
+    </audio>
+    <audio id="inviteSound">
+        <source src="./sound/invite.ogg" type="audio/ogg" />
+    </audio>
 </body>
 </html>
\ No newline at end of file
index 512b3e76259452a2e0680a8f9e3c358f4d6a3fbb..f0f7a8c25ee0f2764d0a0393b9d734912a615ce0 100644 (file)
@@ -6,9 +6,6 @@ import cons from './cons';
 import navigation from './navigation';
 import settings from './settings';
 
-import NotificationSound from '../../../public/sound/notification.ogg';
-import InviteSound from '../../../public/sound/invite.ogg';
-
 function isNotifEvent(mEvent) {
   const eType = mEvent.getType();
   if (!cons.supportEventTypes.includes(eType)) return false;
@@ -238,14 +235,14 @@ class Notifications extends EventEmitter {
 
   _playNotiSound() {
     if (!this._notiAudio) {
-      this._notiAudio = new Audio(NotificationSound);
+      this._notiAudio = document.getElementById('notificationSound');
     }
     this._notiAudio.play();
   }
 
   _playInviteSound() {
     if (!this._inviteAudio) {
-      this._inviteAudio = new Audio(InviteSound);
+      this._inviteAudio = document.getElementById('inviteSound');
     }
     this._inviteAudio.play();
   }
index b80353463405a3300046f7c5060cfe96ceb816fc..3a4707ca94717fc52ead1c6b7ff231df79485de6 100644 (file)
@@ -475,6 +475,10 @@ textarea {
                                   supported by Chrome, Edge, Opera and Firefox */
 }
 
+audio:not([controls]) {
+  display: none !important;
+}
+
 .flex--center {
   display: flex;
   justify-content: center;