Sfoglia il codice sorgente

feat(rnsdk): add audio and video muted state changed

factor2
Abbas Al-Mansoori 2 anni fa
parent
commit
6d02f50d09

+ 4
- 0
react-native-sdk/index.tsx Vedi File

@@ -19,6 +19,8 @@ import { setAudioMuted, setVideoMuted } from './react/features/base/media/action
19 19
 
20 20
 
21 21
 interface IEventListeners {
22
+    onAudioMutedChanged?: Function;
23
+    onVideoMutedChanged?: Function;
22 24
     onConferenceBlurred?: Function;
23 25
     onConferenceFocused?: Function;
24 26
     onConferenceJoined?: Function;
@@ -107,6 +109,8 @@ export const JitsiMeeting = forwardRef((props: IAppProps, ref) => {
107 109
             setAppProps({
108 110
                 'flags': flags,
109 111
                 'rnSdkHandlers': {
112
+                    onAudioMutedChanged: eventListeners?.onAudioMutedChanged,
113
+                    onVideoMutedChanged: eventListeners?.onVideoMutedChanged,
110 114
                     onConferenceBlurred: eventListeners?.onConferenceBlurred,
111 115
                     onConferenceFocused: eventListeners?.onConferenceFocused,
112 116
                     onConferenceJoined: eventListeners?.onConferenceJoined,

+ 18
- 0
react/features/base/conference/actionTypes.ts Vedi File

@@ -72,6 +72,24 @@ export const CONFERENCE_BLURRED = 'CONFERENCE_BLURRED';
72 72
  */
73 73
 export const CONFERENCE_FOCUSED = 'CONFERENCE_FOCUSED';
74 74
 
75
+/**
76
+ * The type of (redux) action which signals that the audio mute state is changed.
77
+ * 
78
+ * {
79
+ *      type: AUDIO_MUTED_CHANGED,
80
+ * }
81
+ */
82
+export const AUDIO_MUTED_CHANGED = 'AUDIO_MUTED_CHANGED';
83
+
84
+/**
85
+ * The type of (redux) action which signals that the video mute state is changed.
86
+ * 
87
+ * {
88
+ *      type: VIDEO_MUTED_CHANGED,
89
+ * }
90
+ */
91
+export const VIDEO_MUTED_CHANGED = 'VIDEO_MUTED_CHANGED';
92
+
75 93
 /**
76 94
  * The type of (redux) action, which indicates conference local subject changes.
77 95
  *

+ 13
- 1
react/features/mobile/external-api/middleware.ts Vedi File

@@ -10,13 +10,15 @@ import { appNavigate } from '../../app/actions.native';
10 10
 import { IStore } from '../../app/types';
11 11
 import { APP_WILL_MOUNT, APP_WILL_UNMOUNT } from '../../base/app/actionTypes';
12 12
 import {
13
+    AUDIO_MUTED_CHANGED,
13 14
     CONFERENCE_BLURRED,
14 15
     CONFERENCE_FAILED,
15 16
     CONFERENCE_FOCUSED,
16 17
     CONFERENCE_JOINED,
17 18
     CONFERENCE_LEFT,
18 19
     CONFERENCE_WILL_JOIN,
19
-    SET_ROOM
20
+    SET_ROOM,
21
+    VIDEO_MUTED_CHANGED
20 22
 } from '../../base/conference/actionTypes';
21 23
 import { JITSI_CONFERENCE_URL_KEY } from '../../base/conference/constants';
22 24
 import {
@@ -158,6 +160,16 @@ externalAPIEnabled && MiddlewareRegistry.register(store => next => action => {
158 160
         sendEvent(store, CONFERENCE_BLURRED, {});
159 161
         break;
160 162
 
163
+    case AUDIO_MUTED_CHANGED:
164
+        sendEvent(store, AUDIO_MUTED_CHANGED,
165
+        /* data */ { muted: action.muted });
166
+        break;
167
+
168
+    case VIDEO_MUTED_CHANGED:
169
+        sendEvent(store, VIDEO_MUTED_CHANGED,
170
+        /* data */ { muted: action.muted });
171
+        break;
172
+
161 173
     case CONFERENCE_FOCUSED:
162 174
         sendEvent(store, CONFERENCE_FOCUSED, {});
163 175
         break;

+ 9
- 1
react/features/mobile/react-native-sdk/middleware.js Vedi File

@@ -2,11 +2,13 @@ import { NativeModules } from 'react-native';
2 2
 
3 3
 import { getAppProp } from '../../base/app/functions';
4 4
 import {
5
+    AUDIO_MUTED_CHANGED,
5 6
     CONFERENCE_BLURRED,
6 7
     CONFERENCE_FOCUSED,
7 8
     CONFERENCE_JOINED,
8 9
     CONFERENCE_LEFT,
9
-    CONFERENCE_WILL_JOIN
10
+    CONFERENCE_WILL_JOIN,
11
+    VIDEO_MUTED_CHANGED
10 12
 } from '../../base/conference/actionTypes';
11 13
 import { PARTICIPANT_JOINED } from '../../base/participants/actionTypes';
12 14
 import MiddlewareRegistry from '../../base/redux/MiddlewareRegistry';
@@ -31,6 +33,12 @@ const { JMOngoingConference } = NativeModules;
31 33
     const rnSdkHandlers = getAppProp(store, 'rnSdkHandlers');
32 34
 
33 35
     switch (type) {
36
+    case AUDIO_MUTED_CHANGED:
37
+        rnSdkHandlers?.onAudioMutedChanged && rnSdkHandlers?.onAudioMutedChanged(action.muted);
38
+        break;
39
+    case VIDEO_MUTED_CHANGED:
40
+        rnSdkHandlers?.onVideoMutedChanged && rnSdkHandlers?.onVideoMutedChanged(action.muted);
41
+        break;
34 42
     case CONFERENCE_BLURRED:
35 43
         rnSdkHandlers?.onConferenceBlurred && rnSdkHandlers?.onConferenceBlurred();
36 44
         break;

+ 25
- 1
react/features/toolbox/components/native/AudioMuteButton.tsx Vedi File

@@ -1,6 +1,30 @@
1 1
 import { connect } from 'react-redux';
2 2
 
3
+import { AUDIO_MUTED_CHANGED } from '../../../base/conference/actionTypes';
3 4
 import { translate } from '../../../base/i18n/functions';
4 5
 import AbstractAudioMuteButton, { IProps, mapStateToProps } from '../AbstractAudioMuteButton';
5 6
 
6
-export default translate(connect(mapStateToProps)(AbstractAudioMuteButton<IProps>));
7
+/**
8
+ * Component that renders native toolbar button for toggling audio mute.
9
+ *
10
+ * @augments AbstractAudioMuteButton
11
+ */
12
+class AudioMuteButton extends AbstractAudioMuteButton<IProps> {
13
+    /**
14
+     * Changes audio muted state and dispatches the state to redux.
15
+     *
16
+     * @param {boolean} audioMuted - Whether audio should be muted or not.
17
+     * @protected
18
+     * @returns {void}
19
+     */
20
+    _setAudioMuted(audioMuted: boolean) {
21
+        this.props.dispatch?.({
22
+            type: AUDIO_MUTED_CHANGED,
23
+            muted: audioMuted
24
+        });
25
+
26
+        super._setAudioMuted(audioMuted);
27
+    }
28
+}
29
+
30
+export default translate(connect(mapStateToProps)(AudioMuteButton));

+ 25
- 1
react/features/toolbox/components/native/VideoMuteButton.tsx Vedi File

@@ -1,7 +1,31 @@
1 1
 import { connect } from 'react-redux';
2 2
 
3
+import { VIDEO_MUTED_CHANGED } from '../../../base/conference/actionTypes';
3 4
 import { translate } from '../../../base/i18n/functions';
4 5
 import AbstractVideoMuteButton, { IProps, mapStateToProps } from '../AbstractVideoMuteButton';
5 6
 
7
+/**
8
+ * Component that renders native toolbar button for toggling video mute.
9
+ *
10
+ * @augments AbstractVideoMuteButton
11
+ */
12
+class VideoMuteButton extends AbstractVideoMuteButton<IProps> {
13
+    /**
14
+     * Changes video muted state and dispatches the state to redux.
15
+     *
16
+     * @override
17
+     * @param {boolean} videoMuted - Whether video should be muted or not.
18
+     * @protected
19
+     * @returns {void}
20
+     */
21
+    _setVideoMuted(videoMuted: boolean) {
22
+        this.props.dispatch?.({
23
+            type: VIDEO_MUTED_CHANGED,
24
+            muted: videoMuted
25
+        });
6 26
 
7
-export default translate(connect(mapStateToProps)(AbstractVideoMuteButton<IProps>));
27
+        super._setVideoMuted(videoMuted);
28
+    }
29
+}
30
+
31
+export default translate(connect(mapStateToProps)(VideoMuteButton));

Loading…
Annulla
Salva