Browse Source

feat(config) Add config for disabled sound id's

- unify naming for sound id values
master
Horatiu Muresan 3 years ago
parent
commit
9a16733950
No account linked to committer's email address

+ 25
- 0
config.js View File

@@ -683,13 +683,38 @@ var config = {
683 683
         // userRegion: "asia"
684 684
     },
685 685
 
686
+    // Array<string> of disabled sounds.
687
+    // Possible values:
688
+    // - 'E2EE_OFF_SOUND'
689
+    // - 'E2EE_ON_SOUND'
690
+    // - 'INCOMING_MSG_SOUND'
691
+    // - 'KNOCKING_PARTICIPANT_SOUND'
692
+    // - 'LIVE_STREAMING_OFF_SOUND'
693
+    // - 'LIVE_STREAMING_ON_SOUND'
694
+    // - 'NO_AUDIO_SIGNAL_SOUND'
695
+    // - 'NOISY_AUDIO_INPUT_SOUND'
696
+    // - 'OUTGOING_CALL_EXPIRED_SOUND'
697
+    // - 'OUTGOING_CALL_REJECTED_SOUND'
698
+    // - 'OUTGOING_CALL_RINGING_SOUND'
699
+    // - 'OUTGOING_CALL_START_SOUND'
700
+    // - 'PARTICIPANT_JOINED_SOUND'
701
+    // - 'PARTICIPANT_LEFT_SOUND'
702
+    // - 'RAISE_HAND_SOUND'
703
+    // - 'RECORDING_OFF_SOUND'
704
+    // - 'RECORDING_ON_SOUND'
705
+    // - 'TALK_WHILE_MUTED_SOUND'
706
+    // disabledSounds: [],
707
+
708
+    // DEPRECATED! Use `disabledSounds` instead.
686 709
     // Decides whether the start/stop recording audio notifications should play on record.
687 710
     // disableRecordAudioNotification: false,
688 711
 
712
+    // DEPRECATED! Use `disabledSounds` instead.
689 713
     // Disables the sounds that play when other participants join or leave the
690 714
     // conference (if set to true, these sounds will not be played).
691 715
     // disableJoinLeaveSounds: false,
692 716
 
717
+    // DEPRECATED! Use `disabledSounds` instead.
693 718
     // Disables the sounds that play when a chat message is received.
694 719
     // disableIncomingMessageSound: false,
695 720
 

+ 1
- 0
react/features/base/config/configWhitelist.js View File

@@ -84,6 +84,7 @@ export default [
84 84
     'disableAP',
85 85
     'disableAudioLevels',
86 86
     'disableDeepLinking',
87
+    'disabledSounds',
87 88
     'disableFilmstripAutohiding',
88 89
     'disableInitialGUM',
89 90
     'disableH264',

+ 29
- 10
react/features/base/config/reducer.js View File

@@ -66,11 +66,11 @@ ReducerRegistry.register('features/base/config', (state = _getInitialState(), ac
66 66
             error: undefined,
67 67
 
68 68
             /**
69
-                * The URL of the location associated with/configured by this
70
-                * configuration.
71
-                *
72
-                * @type URL
73
-                */
69
+            * The URL of the location associated with/configured by this
70
+            * configuration.
71
+            *
72
+            * @type URL
73
+            */
74 74
             locationURL: action.locationURL
75 75
         };
76 76
 
@@ -84,11 +84,11 @@ ReducerRegistry.register('features/base/config', (state = _getInitialState(), ac
84 84
         if (state.locationURL === action.locationURL) {
85 85
             return {
86 86
                 /**
87
-                    * The {@link Error} which prevented the loading of the
88
-                    * configuration of the associated {@code locationURL}.
89
-                    *
90
-                    * @type Error
91
-                    */
87
+                * The {@link Error} which prevented the loading of the
88
+                * configuration of the associated {@code locationURL}.
89
+                *
90
+                * @type Error
91
+                */
92 92
                 error: action.error
93 93
             };
94 94
         }
@@ -206,6 +206,25 @@ function _translateLegacyConfig(oldValue: Object) {
206 206
         };
207 207
     }
208 208
 
209
+    newValue.disabledSounds = newValue.disabledSounds || [];
210
+
211
+    if (oldValue.disableJoinLeaveSounds) {
212
+        newValue.disabledSounds.unshift('PARTICIPANT_LEFT_SOUND', 'PARTICIPANT_JOINED_SOUND');
213
+    }
214
+
215
+    if (oldValue.disableRecordAudioNotification) {
216
+        newValue.disabledSounds.unshift(
217
+            'RECORDING_ON_SOUND',
218
+            'RECORDING_OFF_SOUND',
219
+            'LIVE_STREAMING_ON_SOUND',
220
+            'LIVE_STREAMING_OFF_SOUND'
221
+        );
222
+    }
223
+
224
+    if (oldValue.disableIncomingMessageSound) {
225
+        newValue.disabledSounds.unshift('INCOMING_MSG_SOUND');
226
+    }
227
+
209 228
     if (oldValue.stereo || oldValue.opusMaxAverageBitrate) {
210 229
         newValue.audioQuality = {
211 230
             opusMaxAverageBitrate: oldValue.audioQuality?.opusMaxAverageBitrate ?? oldValue.opusMaxAverageBitrate,

+ 1
- 6
react/features/base/participants/middleware.js View File

@@ -371,14 +371,9 @@ function _localParticipantLeft({ dispatch }, next, action) {
371 371
  */
372 372
 function _maybePlaySounds({ getState, dispatch }, action) {
373 373
     const state = getState();
374
-    const { startAudioMuted, disableJoinLeaveSounds } = state['features/base/config'];
374
+    const { startAudioMuted } = state['features/base/config'];
375 375
     const { soundsParticipantJoined: joinSound, soundsParticipantLeft: leftSound } = state['features/base/settings'];
376 376
 
377
-    // If we have join/leave sounds disabled, don't play anything.
378
-    if (disableJoinLeaveSounds) {
379
-        return;
380
-    }
381
-
382 377
     // We're not playing sounds for local participant
383 378
     // nor when the user is joining past the "startAudioMuted" limit.
384 379
     // The intention there was to not play user joined notification in big

+ 11
- 7
react/features/base/sounds/actions.js View File

@@ -11,6 +11,7 @@ import {
11 11
     UNREGISTER_SOUND
12 12
 } from './actionTypes';
13 13
 import { getSoundsPath } from './functions';
14
+import { getDisabledSounds } from './functions.any';
14 15
 
15 16
 /**
16 17
  * Adds {@link AudioElement} instance to the base/sounds feature state for the
@@ -63,15 +64,18 @@ export function _removeAudioElement(soundId: string) {
63 64
  *
64 65
  * @param {string} soundId - The id of the sound to be played (the same one
65 66
  * which was used in {@link registerSound} to register the sound).
66
- * @returns {{
67
- *     type: PLAY_SOUND,
68
- *     soundId: string
69
- * }}
67
+ * @returns {Function}
70 68
  */
71 69
 export function playSound(soundId: string): Object {
72
-    return {
73
-        type: PLAY_SOUND,
74
-        soundId
70
+    return (dispatch: Function, getState: Function) => {
71
+        const disabledSounds = getDisabledSounds(getState());
72
+
73
+        if (!disabledSounds.includes(soundId)) {
74
+            dispatch({
75
+                type: PLAY_SOUND,
76
+                soundId
77
+            });
78
+        }
75 79
     };
76 80
 }
77 81
 

+ 11
- 0
react/features/base/sounds/functions.any.js View File

@@ -0,0 +1,11 @@
1
+// @flow
2
+
3
+/**
4
+ * Selector for retrieving the disabled sounds array.
5
+ *
6
+ * @param {Object} state - The Redux state.
7
+ * @returns {Array<string>} - The disabled sound id's array.
8
+ */
9
+export function getDisabledSounds(state: Object) {
10
+    return state['features/base/config'].disabledSounds || [];
11
+}

+ 2
- 2
react/features/chat/middleware.js View File

@@ -313,10 +313,10 @@ function _handleReceivedMessage({ dispatch, getState },
313 313
     // Logic for all platforms:
314 314
     const state = getState();
315 315
     const { isOpen: isChatOpen } = state['features/chat'];
316
-    const { disableIncomingMessageSound, iAmRecorder } = state['features/base/config'];
316
+    const { iAmRecorder } = state['features/base/config'];
317 317
     const { soundsIncomingMessage: soundEnabled } = state['features/base/settings'];
318 318
 
319
-    if (!disableIncomingMessageSound && soundEnabled && shouldPlaySound && !isChatOpen) {
319
+    if (soundEnabled && shouldPlaySound && !isChatOpen) {
320 320
         dispatch(playSound(INCOMING_MSG_SOUND_ID));
321 321
     }
322 322
 

+ 4
- 4
react/features/invite/constants.js View File

@@ -17,7 +17,7 @@ export const DIAL_IN_SUMMARY_VIEW_ID = 'DIAL_IN_SUMMARY_VIEW_ID';
17 17
  * @type {string}
18 18
  */
19 19
 export const OUTGOING_CALL_EXPIRED_SOUND_ID
20
-    = 'OUTGOING_CALL_EXPIRED_SOUND_ID';
20
+    = 'OUTGOING_CALL_EXPIRED_SOUND';
21 21
 
22 22
 /**
23 23
  * The identifier of the sound to be played when the status of an outgoing call
@@ -26,7 +26,7 @@ export const OUTGOING_CALL_EXPIRED_SOUND_ID
26 26
  * @type {string}
27 27
  */
28 28
 export const OUTGOING_CALL_REJECTED_SOUND_ID
29
-    = 'OUTGOING_CALL_REJECTED_SOUND_ID';
29
+    = 'OUTGOING_CALL_REJECTED_SOUND';
30 30
 
31 31
 /**
32 32
  * The identifier of the sound to be played when the status of an outgoing call
@@ -34,14 +34,14 @@ export const OUTGOING_CALL_REJECTED_SOUND_ID
34 34
  *
35 35
  * @type {string}
36 36
  */
37
-export const OUTGOING_CALL_RINGING_SOUND_ID = 'OUTGOING_CALL_RINGING_SOUND_ID';
37
+export const OUTGOING_CALL_RINGING_SOUND_ID = 'OUTGOING_CALL_RINGING_SOUND';
38 38
 
39 39
 /**
40 40
  * The identifier of the sound to be played when outgoing call is started.
41 41
  *
42 42
  * @type {string}
43 43
  */
44
-export const OUTGOING_CALL_START_SOUND_ID = 'OUTGOING_CALL_START_SOUND_ID';
44
+export const OUTGOING_CALL_START_SOUND_ID = 'OUTGOING_CALL_START_SOUND';
45 45
 
46 46
 /**
47 47
  * Regex for matching sip addresses.

+ 1
- 1
react/features/no-audio-signal/constants.js View File

@@ -3,4 +3,4 @@
3 3
  *
4 4
  * @type {string}
5 5
  */
6
-export const NO_AUDIO_SIGNAL_SOUND_ID = 'NO_AUDIO_SIGNAL_SOUND_ID';
6
+export const NO_AUDIO_SIGNAL_SOUND_ID = 'NO_AUDIO_SIGNAL_SOUND';

+ 1
- 1
react/features/noise-detection/constants.js View File

@@ -3,4 +3,4 @@
3 3
  *
4 4
  * @type {string}
5 5
  */
6
-export const NOISY_AUDIO_INPUT_SOUND_ID = 'NOISY_AUDIO_INPUT_SOUND_ID';
6
+export const NOISY_AUDIO_INPUT_SOUND_ID = 'NOISY_AUDIO_INPUT_SOUND';

+ 1
- 1
react/features/reactions/constants.js View File

@@ -68,7 +68,7 @@ export const SILENCE_SOUND_ID = 'SILENCE_SOUND_';
68 68
  *
69 69
  * @type {string}
70 70
  */
71
-export const RAISE_HAND_SOUND_ID = 'RAISE_HAND_SOUND_ID';
71
+export const RAISE_HAND_SOUND_ID = 'RAISE_HAND_SOUND';
72 72
 
73 73
 export type ReactionEmojiProps = {
74 74
 

+ 0
- 9
react/features/recording/middleware.js View File

@@ -135,7 +135,6 @@ MiddlewareRegistry.register(({ dispatch, getState }) => next => action => {
135 135
         const {
136 136
             iAmRecorder,
137 137
             iAmSipGateway,
138
-            disableRecordAudioNotification,
139 138
             recordingLimit
140 139
         } = getState()['features/base/config'];
141 140
 
@@ -165,10 +164,6 @@ MiddlewareRegistry.register(({ dispatch, getState }) => next => action => {
165 164
 
166 165
                 sendAnalytics(createRecordingEvent('start', mode));
167 166
 
168
-                if (disableRecordAudioNotification) {
169
-                    break;
170
-                }
171
-
172 167
                 let soundID;
173 168
 
174 169
                 if (mode === JitsiRecordingConstants.mode.FILE) {
@@ -200,10 +195,6 @@ MiddlewareRegistry.register(({ dispatch, getState }) => next => action => {
200 195
                 }
201 196
                 sendAnalytics(createRecordingEvent('stop', mode, duration));
202 197
 
203
-                if (disableRecordAudioNotification) {
204
-                    break;
205
-                }
206
-
207 198
                 if (mode === JitsiRecordingConstants.mode.FILE) {
208 199
                     soundOff = RECORDING_OFF_SOUND_ID;
209 200
                     soundOn = RECORDING_ON_SOUND_ID;

+ 1
- 1
react/features/talk-while-muted/constants.js View File

@@ -3,4 +3,4 @@
3 3
  *
4 4
  * @type {string}
5 5
  */
6
-export const TALK_WHILE_MUTED_SOUND_ID = 'TALK_WHILE_MUTED_SOUND_ID';
6
+export const TALK_WHILE_MUTED_SOUND_ID = 'TALK_WHILE_MUTED_SOUND';

Loading…
Cancel
Save