瀏覽代碼

feat(iFrame): Add a method for resizing large video container from iFrame

master
Jaya Allamsetty 4 年之前
父節點
當前提交
bbb4fbd5f8

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

21
 import { isEnabled as isDropboxEnabled } from '../../react/features/dropbox';
21
 import { isEnabled as isDropboxEnabled } from '../../react/features/dropbox';
22
 import { toggleE2EE } from '../../react/features/e2ee/actions';
22
 import { toggleE2EE } from '../../react/features/e2ee/actions';
23
 import { invite } from '../../react/features/invite';
23
 import { invite } from '../../react/features/invite';
24
-import { selectParticipantInLargeVideo } from '../../react/features/large-video/actions';
24
+import { resizeLargeVideo, selectParticipantInLargeVideo } from '../../react/features/large-video/actions';
25
 import { toggleLobbyMode } from '../../react/features/lobby/actions.web';
25
 import { toggleLobbyMode } from '../../react/features/lobby/actions.web';
26
 import { RECORDING_TYPES } from '../../react/features/recording/constants';
26
 import { RECORDING_TYPES } from '../../react/features/recording/constants';
27
 import { getActiveSession } from '../../react/features/recording/functions';
27
 import { getActiveSession } from '../../react/features/recording/functions';
119
         'proxy-connection-event': event => {
119
         'proxy-connection-event': event => {
120
             APP.conference.onProxyConnectionEvent(event);
120
             APP.conference.onProxyConnectionEvent(event);
121
         },
121
         },
122
+        'resize-large-video': (width, height) => {
123
+            logger.debug('Resize large video command received');
124
+            sendAnalytics(createApiEvent('largevideo.resized'));
125
+            APP.store.dispatch(resizeLargeVideo(width, height));
126
+        },
122
         'send-tones': (options = {}) => {
127
         'send-tones': (options = {}) => {
123
             const { duration, tones, pause } = options;
128
             const { duration, tones, pause } = options;
124
 
129
 

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

35
     hangup: 'video-hangup',
35
     hangup: 'video-hangup',
36
     muteEveryone: 'mute-everyone',
36
     muteEveryone: 'mute-everyone',
37
     password: 'password',
37
     password: 'password',
38
+    resizeLargeVideo: 'resize-large-video',
38
     sendEndpointTextMessage: 'send-endpoint-text-message',
39
     sendEndpointTextMessage: 'send-endpoint-text-message',
39
     sendTones: 'send-tones',
40
     sendTones: 'send-tones',
40
     setLargeVideoParticipant: 'set-large-video-participant',
41
     setLargeVideoParticipant: 'set-large-video-participant',
437
         const parsedWidth = parseSizeParam(width);
438
         const parsedWidth = parseSizeParam(width);
438
 
439
 
439
         if (parsedHeight !== undefined) {
440
         if (parsedHeight !== undefined) {
441
+            this._height = height;
440
             this._frame.style.height = parsedHeight;
442
             this._frame.style.height = parsedHeight;
441
         }
443
         }
442
 
444
 
443
         if (parsedWidth !== undefined) {
445
         if (parsedWidth !== undefined) {
446
+            this._width = width;
444
             this._frame.style.width = parsedWidth;
447
             this._frame.style.width = parsedWidth;
445
         }
448
         }
446
     }
449
     }
930
         eventList.forEach(event => this.removeEventListener(event));
933
         eventList.forEach(event => this.removeEventListener(event));
931
     }
934
     }
932
 
935
 
936
+    /**
937
+     * Resizes the large video container as per the dimensions provided.
938
+     *
939
+     * @param {number} width - Width that needs to be applied on the large video container.
940
+     * @param {number} height - Height that needs to be applied on the large video container.
941
+     * @returns {void}
942
+     */
943
+    resizeLargeVideo(width, height) {
944
+        if (width <= this._width && height <= this._height) {
945
+            this.executeCommand('resizeLargeVideo', width, height);
946
+        }
947
+    }
948
+
933
     /**
949
     /**
934
      * Passes an event along to the local conference participant to establish
950
      * Passes an event along to the local conference participant to establish
935
      * or update a direct peer connection. This is currently used for developing
951
      * or update a direct peer connection. This is currently used for developing

+ 0
- 7
modules/UI/util/UIUtil.js 查看文件

5
  */
5
  */
6
 const UIUtil = {
6
 const UIUtil = {
7
 
7
 
8
-    /**
9
-     * Returns the available video width.
10
-     */
11
-    getAvailableVideoWidth() {
12
-        return window.innerWidth;
13
-    },
14
-
15
     /**
8
     /**
16
      * Escapes the given text.
9
      * Escapes the given text.
17
      */
10
      */

+ 12
- 8
modules/UI/videolayout/LargeVideoManager.js 查看文件

21
 import UIEvents from '../../../service/UI/UIEvents';
21
 import UIEvents from '../../../service/UI/UIEvents';
22
 import { createDeferred } from '../../util/helpers';
22
 import { createDeferred } from '../../util/helpers';
23
 import AudioLevels from '../audio_levels/AudioLevels';
23
 import AudioLevels from '../audio_levels/AudioLevels';
24
-import UIUtil from '../util/UIUtil';
25
 
24
 
26
 import { VideoContainer, VIDEO_CONTAINER_TYPE } from './VideoContainer';
25
 import { VideoContainer, VIDEO_CONTAINER_TYPE } from './VideoContainer';
27
 
26
 
323
     /**
322
     /**
324
      * Update container size.
323
      * Update container size.
325
      */
324
      */
326
-    updateContainerSize() {
327
-        let widthToUse = UIUtil.getAvailableVideoWidth();
325
+    updateContainerSize(width, height) {
326
+        let widthToUse = width ?? (this.width > 0 ? this.width : window.innerWidth);
328
         const { isOpen } = APP.store.getState()['features/chat'];
327
         const { isOpen } = APP.store.getState()['features/chat'];
329
 
328
 
329
+        /**
330
+         * If chat state is open, we re-compute the container width by subtracting the default width of
331
+         * the chat. We re-compute the width again after the chat window is closed. This is needed when
332
+         * custom styling is configured on the large video container through the iFrame API.
333
+         */
330
         if (isOpen) {
334
         if (isOpen) {
331
-            /**
332
-             * If chat state is open, we re-compute the container width
333
-             * by subtracting the default width of the chat.
334
-             */
335
             widthToUse -= CHAT_SIZE;
335
             widthToUse -= CHAT_SIZE;
336
+            this.resizedForChat = true;
337
+        } else if (this.resizedForChat) {
338
+            this.resizedForChat = false;
339
+            widthToUse += CHAT_SIZE;
336
         }
340
         }
337
 
341
 
338
         this.width = widthToUse;
342
         this.width = widthToUse;
339
-        this.height = window.innerHeight;
343
+        this.height = height ?? (this.height > 0 ? this.height : window.innerHeight);
340
     }
344
     }
341
 
345
 
342
     /**
346
     /**

+ 22
- 0
react/features/large-video/actions.js 查看文件

2
 
2
 
3
 import type { Dispatch } from 'redux';
3
 import type { Dispatch } from 'redux';
4
 
4
 
5
+import VideoLayout from '../../../modules/UI/videolayout/VideoLayout';
5
 import {
6
 import {
6
     createSelectParticipantFailedEvent,
7
     createSelectParticipantFailedEvent,
7
     sendAnalytics
8
     sendAnalytics
19
 
20
 
20
 declare var APP: Object;
21
 declare var APP: Object;
21
 
22
 
23
+/**
24
+ * Resizes the large video container based on the dimensions provided.
25
+ *
26
+ * @param {number} width - Width that needs to be applied on the large video container.
27
+ * @param {number} height - Height that needs to be applied on the large video container.
28
+ * @returns {void}
29
+ */
30
+export function resizeLargeVideo(width: number, height: number) {
31
+    return (dispatch: Dispatch<any>, getState: Function) => {
32
+        const state = getState();
33
+        const largeVideo = state['features/large-video'];
34
+
35
+        if (largeVideo) {
36
+            const largeVideoContainer = VideoLayout.getLargeVideo();
37
+
38
+            largeVideoContainer.updateContainerSize(width, height);
39
+            largeVideoContainer.resize();
40
+        }
41
+    };
42
+}
43
+
22
 /**
44
 /**
23
  * Signals conference to select a participant.
45
  * Signals conference to select a participant.
24
  *
46
  *

Loading…
取消
儲存