瀏覽代碼

feat(api): expose method for playing touch tones (#4584)

master
virtuacoplenny 6 年之前
父節點
當前提交
55ff9dbe80
沒有連結到貢獻者的電子郵件帳戶。

+ 9
- 0
doc/api.md 查看文件

197
 api.executeCommand('password', 'The Password');
197
 api.executeCommand('password', 'The Password');
198
 ```
198
 ```
199
 
199
 
200
+* **sendTones** - Play touch tones.
201
+```javascript
202
+api.executeCommand('sendTones', {
203
+    tones: string, // The dial pad touch tones to play. For example, '12345#'.
204
+    duration: number, // Optional. The number of milliseconds each tone should play. The default is 200.
205
+    pause: number // Optional. The number of milliseconds between each tone. The default is 200.
206
+});
207
+```
208
+
200
 * **subject** - Sets the subject of the conference. This command requires one argument - the new subject to be set.
209
 * **subject** - Sets the subject of the conference. This command requires one argument - the new subject to be set.
201
 ```javascript
210
 ```javascript
202
 api.executeCommand('subject', 'New Conference Subject');
211
 api.executeCommand('subject', 'New Conference Subject');

+ 10
- 1
modules/API/API.js 查看文件

5
     createApiEvent,
5
     createApiEvent,
6
     sendAnalytics
6
     sendAnalytics
7
 } from '../../react/features/analytics';
7
 } from '../../react/features/analytics';
8
-import { setPassword, setSubject } from '../../react/features/base/conference';
8
+import {
9
+    sendTones,
10
+    setPassword,
11
+    setSubject
12
+} from '../../react/features/base/conference';
9
 import { parseJWTFromURLParams } from '../../react/features/base/jwt';
13
 import { parseJWTFromURLParams } from '../../react/features/base/jwt';
10
 import { invite } from '../../react/features/invite';
14
 import { invite } from '../../react/features/invite';
11
 import { toggleTileView } from '../../react/features/video-layout';
15
 import { toggleTileView } from '../../react/features/video-layout';
90
         'proxy-connection-event': event => {
94
         'proxy-connection-event': event => {
91
             APP.conference.onProxyConnectionEvent(event);
95
             APP.conference.onProxyConnectionEvent(event);
92
         },
96
         },
97
+        'send-tones': (options = {}) => {
98
+            const { duration, tones, pause } = options;
99
+
100
+            APP.store.dispatch(sendTones(tones, duration, pause));
101
+        },
93
         'subject': subject => {
102
         'subject': subject => {
94
             sendAnalytics(createApiEvent('subject.changed'));
103
             sendAnalytics(createApiEvent('subject.changed'));
95
             APP.store.dispatch(setSubject(subject));
104
             APP.store.dispatch(setSubject(subject));

+ 1
- 0
modules/API/external/external_api.js 查看文件

34
     email: 'email',
34
     email: 'email',
35
     hangup: 'video-hangup',
35
     hangup: 'video-hangup',
36
     password: 'password',
36
     password: 'password',
37
+    sendTones: 'send-tones',
37
     subject: 'subject',
38
     subject: 'subject',
38
     submitFeedback: 'submit-feedback',
39
     submitFeedback: 'submit-feedback',
39
     toggleAudio: 'toggle-audio',
40
     toggleAudio: 'toggle-audio',

+ 12
- 0
react/features/base/conference/actionTypes.js 查看文件

118
  */
118
  */
119
 export const P2P_STATUS_CHANGED = 'P2P_STATUS_CHANGED';
119
 export const P2P_STATUS_CHANGED = 'P2P_STATUS_CHANGED';
120
 
120
 
121
+/**
122
+ * The type of (redux) action which signals to play specified touch tones.
123
+ *
124
+ * {
125
+ *     type: SEND_TONES,
126
+ *     tones: string,
127
+ *     duration: number,
128
+ *     pause: number
129
+ * }
130
+ */
131
+export const SEND_TONES = 'SEND_TONES';
132
+
121
 /**
133
 /**
122
  * The type of (redux) action which sets the desktop sharing enabled flag for
134
  * The type of (redux) action which sets the desktop sharing enabled flag for
123
  * the current conference.
135
  * the current conference.

+ 23
- 0
react/features/base/conference/actions.js 查看文件

37
     KICKED_OUT,
37
     KICKED_OUT,
38
     LOCK_STATE_CHANGED,
38
     LOCK_STATE_CHANGED,
39
     P2P_STATUS_CHANGED,
39
     P2P_STATUS_CHANGED,
40
+    SEND_TONES,
40
     SET_DESKTOP_SHARING_ENABLED,
41
     SET_DESKTOP_SHARING_ENABLED,
41
     SET_FOLLOW_ME,
42
     SET_FOLLOW_ME,
42
     SET_MAX_RECEIVER_VIDEO_QUALITY,
43
     SET_MAX_RECEIVER_VIDEO_QUALITY,
520
     };
521
     };
521
 }
522
 }
522
 
523
 
524
+/**
525
+ * Signals to play touch tones.
526
+ *
527
+ * @param {string} tones - The tones to play.
528
+ * @param {number} [duration] - How long to play each tone.
529
+ * @param {number} [pause] - How long to pause between each tone.
530
+ * @returns {{
531
+ *     type: SEND_TONES,
532
+ *     tones: string,
533
+ *     duration: number,
534
+ *     pause: number
535
+ * }}
536
+ */
537
+export function sendTones(tones: string, duration: number, pause: number) {
538
+    return {
539
+        type: SEND_TONES,
540
+        tones,
541
+        duration,
542
+        pause
543
+    };
544
+}
545
+
523
 /**
546
 /**
524
  * Sets the flag for indicating if desktop sharing is enabled.
547
  * Sets the flag for indicating if desktop sharing is enabled.
525
  *
548
  *

+ 29
- 0
react/features/base/conference/middleware.js 查看文件

35
     CONFERENCE_SUBJECT_CHANGED,
35
     CONFERENCE_SUBJECT_CHANGED,
36
     CONFERENCE_WILL_LEAVE,
36
     CONFERENCE_WILL_LEAVE,
37
     DATA_CHANNEL_OPENED,
37
     DATA_CHANNEL_OPENED,
38
+    SEND_TONES,
38
     SET_PENDING_SUBJECT_CHANGE,
39
     SET_PENDING_SUBJECT_CHANGE,
39
     SET_ROOM
40
     SET_ROOM
40
 } from './actionTypes';
41
 } from './actionTypes';
89
     case PIN_PARTICIPANT:
90
     case PIN_PARTICIPANT:
90
         return _pinParticipant(store, next, action);
91
         return _pinParticipant(store, next, action);
91
 
92
 
93
+    case SEND_TONES:
94
+        return _sendTones(store, next, action);
95
+
92
     case SET_ROOM:
96
     case SET_ROOM:
93
         return _setRoom(store, next, action);
97
         return _setRoom(store, next, action);
94
 
98
 
446
     return next(action);
450
     return next(action);
447
 }
451
 }
448
 
452
 
453
+/**
454
+ * Requests the specified tones to be played.
455
+ *
456
+ * @param {Store} store - The redux store in which the specified {@code action}
457
+ * is being dispatched.
458
+ * @param {Dispatch} next - The redux {@code dispatch} function to dispatch the
459
+ * specified {@code action} to the specified {@code store}.
460
+ * @param {Action} action - The redux action {@code SEND_TONES} which is
461
+ * being dispatched in the specified {@code store}.
462
+ * @private
463
+ * @returns {Object} The value returned by {@code next(action)}.
464
+ */
465
+function _sendTones({ getState }, next, action) {
466
+    const state = getState();
467
+    const { conference } = state['features/base/conference'];
468
+
469
+    if (conference) {
470
+        const { duration, tones, pause } = action;
471
+
472
+        conference.sendTones(tones, duration, pause);
473
+    }
474
+
475
+    return next(action);
476
+}
477
+
449
 /**
478
 /**
450
  * Helper function for updating the preferred receiver video constraint, based
479
  * Helper function for updating the preferred receiver video constraint, based
451
  * on the user preference and the internal maximum.
480
  * on the user preference and the internal maximum.

Loading…
取消
儲存