Browse Source

feat(api): add ability to toggle tile view

j8
Leonard Kim 6 years ago
parent
commit
37b343a797

+ 12
- 0
doc/api.md View File

@@ -222,6 +222,11 @@ api.executeCommand('toggleChat');
222 222
 api.executeCommand('toggleShareScreen');
223 223
 ```
224 224
 
225
+* **toggleTileView** - Enter / exit tile view layout mode. No arguments are required.
226
+```javascript
227
+api.executeCommand('toggleTileView');
228
+```
229
+
225 230
 * **hangup** - Hangups the call. No arguments are required.
226 231
 ```javascript
227 232
 api.executeCommand('hangup');
@@ -296,6 +301,13 @@ changes. The listener will receive an object with the following structure:
296 301
 }
297 302
 ```
298 303
 
304
+* **tileViewChanged** - event notifications about tile view layout mode being entered or exited. The listener will receive object with the following structure:
305
+```javascript
306
+{
307
+    enabled: boolean, // whether tile view is not displayed or not
308
+}
309
+```
310
+
299 311
 * **incomingMessage** - Event notifications about incoming
300 312
 messages. The listener will receive an object with the following structure:
301 313
 ```javascript

+ 21
- 0
modules/API/API.js View File

@@ -8,6 +8,7 @@ import {
8 8
 import { setSubject } from '../../react/features/base/conference';
9 9
 import { parseJWTFromURLParams } from '../../react/features/base/jwt';
10 10
 import { invite } from '../../react/features/invite';
11
+import { toggleTileView } from '../../react/features/video-layout';
11 12
 import { getJitsiMeetTransport } from '../transport';
12 13
 
13 14
 import { API_ID } from './constants';
@@ -97,6 +98,11 @@ function initCommands() {
97 98
             sendAnalytics(createApiEvent('screen.sharing.toggled'));
98 99
             toggleScreenSharing();
99 100
         },
101
+        'toggle-tile-view': () => {
102
+            sendAnalytics(createApiEvent('tile-view.toggled'));
103
+
104
+            APP.store.dispatch(toggleTileView());
105
+        },
100 106
         'video-hangup': () => {
101 107
             sendAnalytics(createApiEvent('video.hangup'));
102 108
             APP.conference.hangup(true);
@@ -622,6 +628,21 @@ class API {
622 628
         });
623 629
     }
624 630
 
631
+    /**
632
+     * Notify external application (if API is enabled) that tile view has been
633
+     * entered or exited.
634
+     *
635
+     * @param {string} enabled - True if tile view is currently displayed, false
636
+     * otherwise.
637
+     * @returns {void}
638
+     */
639
+    notifyTileViewChanged(enabled: boolean) {
640
+        this._sendEvent({
641
+            name: 'tile-view-changed',
642
+            enabled
643
+        });
644
+    }
645
+
625 646
     /**
626 647
      * Disposes the allocated resources.
627 648
      *

+ 3
- 1
modules/API/external/external_api.js View File

@@ -39,6 +39,7 @@ const commands = {
39 39
     toggleChat: 'toggle-chat',
40 40
     toggleFilmStrip: 'toggle-film-strip',
41 41
     toggleShareScreen: 'toggle-share-screen',
42
+    toggleTileView: 'toggle-tile-view',
42 43
     toggleVideo: 'toggle-video'
43 44
 };
44 45
 
@@ -67,7 +68,8 @@ const events = {
67 68
     'video-availability-changed': 'videoAvailabilityChanged',
68 69
     'video-mute-status-changed': 'videoMuteStatusChanged',
69 70
     'screen-sharing-status-changed': 'screenSharingStatusChanged',
70
-    'subject-change': 'subjectChange'
71
+    'subject-change': 'subjectChange',
72
+    'tile-view-changed': 'tileViewChanged'
71 73
 };
72 74
 
73 75
 /**

+ 16
- 0
react/features/video-layout/actions.js View File

@@ -1,5 +1,7 @@
1 1
 // @flow
2 2
 
3
+import type { Dispatch } from 'redux';
4
+
3 5
 import {
4 6
     SCREEN_SHARE_PARTICIPANTS_UPDATED,
5 7
     SET_TILE_VIEW
@@ -39,3 +41,17 @@ export function setTileView(enabled: boolean) {
39 41
         enabled
40 42
     };
41 43
 }
44
+
45
+/**
46
+ * Creates a (redux) action which signals either to exit tile view if currently
47
+ * enabled or enter tile view if currently disabled.
48
+ *
49
+ * @returns {Function}
50
+ */
51
+export function toggleTileView() {
52
+    return (dispatch: Dispatch<any>, getState: Function) => {
53
+        const { tileViewEnabled } = getState()['features/video-layout'];
54
+
55
+        dispatch(setTileView(!tileViewEnabled));
56
+    };
57
+}

+ 5
- 0
react/features/video-layout/subscriber.js View File

@@ -13,6 +13,7 @@ import { selectParticipant } from '../large-video';
13 13
 import { shouldDisplayTileView } from './functions';
14 14
 import { setParticipantsWithScreenShare } from './actions';
15 15
 
16
+declare var APP: Object;
16 17
 declare var interfaceConfig: Object;
17 18
 
18 19
 /**
@@ -35,6 +36,10 @@ StateListenerRegistry.register(
35 36
                 _updateAutoPinnedParticipant(store);
36 37
             }
37 38
         }
39
+
40
+        if (typeof APP === 'object') {
41
+            APP.API.notifyTileViewChanged(displayTileView);
42
+        }
38 43
     }
39 44
 );
40 45
 

Loading…
Cancel
Save