瀏覽代碼

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

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

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

@@ -197,6 +197,15 @@ api.executeCommand('displayName', 'New Nickname');
197 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 209
 * **subject** - Sets the subject of the conference. This command requires one argument - the new subject to be set.
201 210
 ```javascript
202 211
 api.executeCommand('subject', 'New Conference Subject');

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

@@ -5,7 +5,11 @@ import {
5 5
     createApiEvent,
6 6
     sendAnalytics
7 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 13
 import { parseJWTFromURLParams } from '../../react/features/base/jwt';
10 14
 import { invite } from '../../react/features/invite';
11 15
 import { toggleTileView } from '../../react/features/video-layout';
@@ -90,6 +94,11 @@ function initCommands() {
90 94
         'proxy-connection-event': event => {
91 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 102
         'subject': subject => {
94 103
             sendAnalytics(createApiEvent('subject.changed'));
95 104
             APP.store.dispatch(setSubject(subject));

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

@@ -34,6 +34,7 @@ const commands = {
34 34
     email: 'email',
35 35
     hangup: 'video-hangup',
36 36
     password: 'password',
37
+    sendTones: 'send-tones',
37 38
     subject: 'subject',
38 39
     submitFeedback: 'submit-feedback',
39 40
     toggleAudio: 'toggle-audio',

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

@@ -118,6 +118,18 @@ export const LOCK_STATE_CHANGED = 'LOCK_STATE_CHANGED';
118 118
  */
119 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 134
  * The type of (redux) action which sets the desktop sharing enabled flag for
123 135
  * the current conference.

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

@@ -37,6 +37,7 @@ import {
37 37
     KICKED_OUT,
38 38
     LOCK_STATE_CHANGED,
39 39
     P2P_STATUS_CHANGED,
40
+    SEND_TONES,
40 41
     SET_DESKTOP_SHARING_ENABLED,
41 42
     SET_FOLLOW_ME,
42 43
     SET_MAX_RECEIVER_VIDEO_QUALITY,
@@ -520,6 +521,28 @@ export function p2pStatusChanged(p2p: boolean) {
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 547
  * Sets the flag for indicating if desktop sharing is enabled.
525 548
  *

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

@@ -35,6 +35,7 @@ import {
35 35
     CONFERENCE_SUBJECT_CHANGED,
36 36
     CONFERENCE_WILL_LEAVE,
37 37
     DATA_CHANNEL_OPENED,
38
+    SEND_TONES,
38 39
     SET_PENDING_SUBJECT_CHANGE,
39 40
     SET_ROOM
40 41
 } from './actionTypes';
@@ -89,6 +90,9 @@ MiddlewareRegistry.register(store => next => action => {
89 90
     case PIN_PARTICIPANT:
90 91
         return _pinParticipant(store, next, action);
91 92
 
93
+    case SEND_TONES:
94
+        return _sendTones(store, next, action);
95
+
92 96
     case SET_ROOM:
93 97
         return _setRoom(store, next, action);
94 98
 
@@ -446,6 +450,31 @@ function _pinParticipant({ getState }, next, action) {
446 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 479
  * Helper function for updating the preferred receiver video constraint, based
451 480
  * on the user preference and the internal maximum.

Loading…
取消
儲存