Просмотр исходного кода

feat(lobby) Add sound for participant knocking

master
hmuresan 4 лет назад
Родитель
Сommit
b6b943e7de
4 измененных файлов: 30 добавлений и 4 удалений
  1. 6
    0
      react/features/lobby/constants.js
  2. 19
    4
      react/features/lobby/middleware.js
  3. 5
    0
      react/features/lobby/sounds.js
  4. Двоичные данные
      sounds/knock.mp3

+ 6
- 0
react/features/lobby/constants.js Просмотреть файл

@@ -2,3 +2,9 @@
2 2
  * Hide these emails when trying to join a lobby
3 3
  */
4 4
 export const HIDDEN_EMAILS = [ 'inbound-sip-jibri@jitsi.net', 'outbound-sip-jibri@jitsi.net' ];
5
+
6
+/**
7
+ * The identifier of the sound to be played when a participant joins lobby.
8
+ * @type {string}
9
+ */
10
+export const KNOCKING_PARTICIPANT_SOUND_ID = 'KNOCKING_PARTICIPANT_SOUND';

+ 19
- 4
react/features/lobby/middleware.js Просмотреть файл

@@ -1,9 +1,13 @@
1 1
 // @flow
2 2
 
3
+import { batch } from 'react-redux';
4
+
5
+import { APP_WILL_MOUNT, APP_WILL_UNMOUNT } from '../base/app';
3 6
 import { CONFERENCE_FAILED, CONFERENCE_JOINED } from '../base/conference';
4 7
 import { JitsiConferenceErrors, JitsiConferenceEvents } from '../base/lib-jitsi-meet';
5 8
 import { getFirstLoadableAvatarUrl, getParticipantDisplayName } from '../base/participants';
6 9
 import { MiddlewareRegistry, StateListenerRegistry } from '../base/redux';
10
+import { playSound, registerSound, unregisterSound } from '../base/sounds';
7 11
 import { isTestModeEnabled } from '../base/testing';
8 12
 import { NOTIFICATION_TYPE, showNotification } from '../notifications';
9 13
 import { shouldAutoKnock } from '../prejoin/functions';
@@ -18,9 +22,17 @@ import {
18 22
     startKnocking,
19 23
     setPasswordJoinFailed
20 24
 } from './actions';
25
+import { KNOCKING_PARTICIPANT_SOUND_ID } from './constants';
26
+import { KNOCKING_PARTICIPANT_FILE } from './sounds';
21 27
 
22 28
 MiddlewareRegistry.register(store => next => action => {
23 29
     switch (action.type) {
30
+    case APP_WILL_MOUNT:
31
+        store.dispatch(registerSound(KNOCKING_PARTICIPANT_SOUND_ID, KNOCKING_PARTICIPANT_FILE));
32
+        break;
33
+    case APP_WILL_UNMOUNT:
34
+        store.dispatch(unregisterSound(KNOCKING_PARTICIPANT_SOUND_ID));
35
+        break;
24 36
     case CONFERENCE_FAILED:
25 37
         return _conferenceFailed(store, next, action);
26 38
     case CONFERENCE_JOINED:
@@ -51,10 +63,13 @@ StateListenerRegistry.register(
51 63
             });
52 64
 
53 65
             conference.on(JitsiConferenceEvents.LOBBY_USER_JOINED, (id, name) => {
54
-                dispatch(participantIsKnockingOrUpdated({
55
-                    id,
56
-                    name
57
-                }));
66
+                batch(() => {
67
+                    dispatch(participantIsKnockingOrUpdated({
68
+                        id,
69
+                        name
70
+                    }));
71
+                    dispatch(playSound(KNOCKING_PARTICIPANT_SOUND_ID));
72
+                });
58 73
             });
59 74
 
60 75
             conference.on(JitsiConferenceEvents.LOBBY_USER_UPDATED, (id, participant) => {

+ 5
- 0
react/features/lobby/sounds.js Просмотреть файл

@@ -0,0 +1,5 @@
1
+/**
2
+ * The name of the bundled sound file which will be played when a
3
+ * participant enters lobby.
4
+ */
5
+export const KNOCKING_PARTICIPANT_FILE = 'knock.mp3';

Двоичные данные
sounds/knock.mp3 Просмотреть файл


Загрузка…
Отмена
Сохранить