Load sound file on startup (#444)

This commit is contained in:
Ajay Bura 2022-05-03 13:18:27 +05:30
parent 43762df998
commit 5cdad44abf
3 changed files with 12 additions and 5 deletions

View file

@ -18,5 +18,11 @@
</head> </head>
<body id="appBody"> <body id="appBody">
<div id="root"></div> <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> </body>
</html> </html>

View file

@ -6,9 +6,6 @@ import cons from './cons';
import navigation from './navigation'; import navigation from './navigation';
import settings from './settings'; import settings from './settings';
import NotificationSound from '../../../public/sound/notification.ogg';
import InviteSound from '../../../public/sound/invite.ogg';
function isNotifEvent(mEvent) { function isNotifEvent(mEvent) {
const eType = mEvent.getType(); const eType = mEvent.getType();
if (!cons.supportEventTypes.includes(eType)) return false; if (!cons.supportEventTypes.includes(eType)) return false;
@ -238,14 +235,14 @@ class Notifications extends EventEmitter {
_playNotiSound() { _playNotiSound() {
if (!this._notiAudio) { if (!this._notiAudio) {
this._notiAudio = new Audio(NotificationSound); this._notiAudio = document.getElementById('notificationSound');
} }
this._notiAudio.play(); this._notiAudio.play();
} }
_playInviteSound() { _playInviteSound() {
if (!this._inviteAudio) { if (!this._inviteAudio) {
this._inviteAudio = new Audio(InviteSound); this._inviteAudio = document.getElementById('inviteSound');
} }
this._inviteAudio.play(); this._inviteAudio.play();
} }

View file

@ -475,6 +475,10 @@ textarea {
supported by Chrome, Edge, Opera and Firefox */ supported by Chrome, Edge, Opera and Firefox */
} }
audio:not([controls]) {
display: none !important;
}
.flex--center { .flex--center {
display: flex; display: flex;
justify-content: center; justify-content: center;