mirror of
https://github.com/edumeet/edumeet.git
synced 2026-07-28 13:33:53 +00:00
Add distinct audio notification with rate-limiting.
Introducing optionally configurable distinct audio notification with an
optional delay between them. This is configurable in
app/public/config/config.js via the "notificationSounds" object.
Added two sample audio files.
- notify-chat.mp3: from sound-theme-freedesktop (Debian) package;
Copyright: Ivica Bukvic; License: CC-BY-SA-3.0
- notify-hand.mp3: from
https://samplefocus.com/collections/notification-sounds
License: Public Domain
This commit is contained in:
parent
fa7c8eeb01
commit
dcf916e715
4 changed files with 52 additions and 10 deletions
|
|
@ -153,6 +153,26 @@ var config =
|
|||
drawerOverlayed : true,
|
||||
// Position of notifications
|
||||
notificationPosition : 'right',
|
||||
/**
|
||||
* Set the notificationSounds. Valid keys are:
|
||||
* 'parkedPeer', 'parkedPeers', 'raisedHand', 'chatMessage',
|
||||
* 'sendFile', 'newPeer' and 'default'.
|
||||
*
|
||||
* Not defining a key is equivalent to using the default notification sound.
|
||||
* Setting 'play' to null disables the sound notification.
|
||||
*/
|
||||
notificationSounds : {
|
||||
chatMessage : {
|
||||
play : '/sounds/notify-chat.mp3',
|
||||
},
|
||||
raisedHand : {
|
||||
play : '/sounds/notify-hand.mp3',
|
||||
},
|
||||
default : {
|
||||
delay : 5000, // minimum delay between alert sounds [ms]
|
||||
play : '/sounds/notify.mp3',
|
||||
},
|
||||
},
|
||||
// Timeout for autohiding topbar and button control bar
|
||||
hideTimeout : 3000,
|
||||
// max number of participant that will be visible in
|
||||
|
|
|
|||
BIN
app/public/sounds/notify-chat.mp3
Normal file
BIN
app/public/sounds/notify-chat.mp3
Normal file
Binary file not shown.
BIN
app/public/sounds/notify-hand.mp3
Normal file
BIN
app/public/sounds/notify-hand.mp3
Normal file
Binary file not shown.
|
|
@ -185,8 +185,19 @@ export default class RoomClient
|
|||
// Access code
|
||||
this._accessCode = accessCode;
|
||||
|
||||
// Alert sound
|
||||
this._soundAlert = new Audio('/sounds/notify.mp3');
|
||||
// Alert sounds
|
||||
this._soundAlerts = { 'default': { audio: new Audio('/sounds/notify.mp3') } };
|
||||
if ('notificationSounds' in window.config)
|
||||
{
|
||||
for (const [ k, v ] of Object.entries(window.config.notificationSounds))
|
||||
{
|
||||
if (v != null && v.play !== undefined)
|
||||
this._soundAlerts[k] = {
|
||||
audio : new Audio(v.play),
|
||||
delay : v.delay ? v.delay: 0
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
// Socket.io peer connection
|
||||
this._signalingSocket = null;
|
||||
|
|
@ -597,13 +608,24 @@ export default class RoomClient
|
|||
}));
|
||||
}
|
||||
|
||||
_soundNotification()
|
||||
_soundNotification(type = 'default')
|
||||
{
|
||||
const { notificationSounds } = store.getState().settings;
|
||||
|
||||
if (notificationSounds)
|
||||
{
|
||||
const alertPromise = this._soundAlert.play();
|
||||
const soundAlert = this._soundAlerts[type] === undefined
|
||||
? this._soundAlerts['default'] : this._soundAlerts[type];
|
||||
|
||||
const now = Date.now();
|
||||
|
||||
if (soundAlert.last !== undefined && (now - soundAlert.last) < soundAlert.delay)
|
||||
{
|
||||
return;
|
||||
}
|
||||
soundAlert.last = now;
|
||||
|
||||
const alertPromise = soundAlert.audio.play();
|
||||
|
||||
if (alertPromise !== undefined)
|
||||
{
|
||||
|
|
@ -2631,7 +2653,7 @@ export default class RoomClient
|
|||
store.dispatch(
|
||||
roomActions.setToolbarsVisible(true));
|
||||
|
||||
this._soundNotification();
|
||||
this._soundNotification(notification.method);
|
||||
|
||||
store.dispatch(requestActions.notify(
|
||||
{
|
||||
|
|
@ -2673,7 +2695,7 @@ export default class RoomClient
|
|||
store.dispatch(
|
||||
roomActions.setToolbarsVisible(true));
|
||||
|
||||
this._soundNotification();
|
||||
this._soundNotification(notification.method);
|
||||
|
||||
store.dispatch(requestActions.notify(
|
||||
{
|
||||
|
|
@ -2892,7 +2914,7 @@ export default class RoomClient
|
|||
}));
|
||||
}
|
||||
|
||||
this._soundNotification();
|
||||
this._soundNotification(notification.method);
|
||||
|
||||
break;
|
||||
}
|
||||
|
|
@ -2912,7 +2934,7 @@ export default class RoomClient
|
|||
{
|
||||
store.dispatch(
|
||||
roomActions.setToolbarsVisible(true));
|
||||
this._soundNotification();
|
||||
this._soundNotification(notification.method);
|
||||
}
|
||||
|
||||
break;
|
||||
|
|
@ -2955,7 +2977,7 @@ export default class RoomClient
|
|||
{
|
||||
store.dispatch(
|
||||
roomActions.setToolbarsVisible(true));
|
||||
this._soundNotification();
|
||||
this._soundNotification(notification.method);
|
||||
}
|
||||
|
||||
break;
|
||||
|
|
@ -2995,7 +3017,7 @@ export default class RoomClient
|
|||
|
||||
this._spotlights.newPeer(id);
|
||||
|
||||
this._soundNotification();
|
||||
this._soundNotification(notification.method);
|
||||
|
||||
store.dispatch(requestActions.notify(
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue