mirror of
https://github.com/edumeet/edumeet.git
synced 2026-07-28 13:33:53 +00:00
Merge pull request #697 from jmencak/distinct-audio-notifications
Add distinct audio notification with rate-limiting.
This commit is contained in:
commit
da67406935
4 changed files with 52 additions and 10 deletions
|
|
@ -158,6 +158,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.
|
|
@ -247,8 +247,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;
|
||||
|
|
@ -659,13 +670,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)
|
||||
{
|
||||
|
|
@ -2624,7 +2646,7 @@ export default class RoomClient
|
|||
store.dispatch(
|
||||
roomActions.setToolbarsVisible(true));
|
||||
|
||||
this._soundNotification();
|
||||
this._soundNotification(notification.method);
|
||||
|
||||
store.dispatch(requestActions.notify(
|
||||
{
|
||||
|
|
@ -2666,7 +2688,7 @@ export default class RoomClient
|
|||
store.dispatch(
|
||||
roomActions.setToolbarsVisible(true));
|
||||
|
||||
this._soundNotification();
|
||||
this._soundNotification(notification.method);
|
||||
|
||||
store.dispatch(requestActions.notify(
|
||||
{
|
||||
|
|
@ -2885,7 +2907,7 @@ export default class RoomClient
|
|||
}));
|
||||
}
|
||||
|
||||
this._soundNotification();
|
||||
this._soundNotification(notification.method);
|
||||
|
||||
break;
|
||||
}
|
||||
|
|
@ -2905,7 +2927,7 @@ export default class RoomClient
|
|||
{
|
||||
store.dispatch(
|
||||
roomActions.setToolbarsVisible(true));
|
||||
this._soundNotification();
|
||||
this._soundNotification(notification.method);
|
||||
}
|
||||
|
||||
break;
|
||||
|
|
@ -2948,7 +2970,7 @@ export default class RoomClient
|
|||
{
|
||||
store.dispatch(
|
||||
roomActions.setToolbarsVisible(true));
|
||||
this._soundNotification();
|
||||
this._soundNotification(notification.method);
|
||||
}
|
||||
|
||||
break;
|
||||
|
|
@ -2988,7 +3010,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