Quellcode durchsuchen

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

j8
Jaya Allamsetty vor 4 Jahren
Ursprung
Commit
bbb4fbd5f8

+ 6
- 1
modules/API/API.js Datei anzeigen

@@ -21,7 +21,7 @@ import {
21 21
 import { isEnabled as isDropboxEnabled } from '../../react/features/dropbox';
22 22
 import { toggleE2EE } from '../../react/features/e2ee/actions';
23 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 25
 import { toggleLobbyMode } from '../../react/features/lobby/actions.web';
26 26
 import { RECORDING_TYPES } from '../../react/features/recording/constants';
27 27
 import { getActiveSession } from '../../react/features/recording/functions';
@@ -119,6 +119,11 @@ function initCommands() {
119 119
         'proxy-connection-event': event => {
120 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 127
         'send-tones': (options = {}) => {
123 128
             const { duration, tones, pause } = options;
124 129
 

+ 16
- 0
modules/API/external/external_api.js Datei anzeigen

@@ -35,6 +35,7 @@ const commands = {
35 35
     hangup: 'video-hangup',
36 36
     muteEveryone: 'mute-everyone',
37 37
     password: 'password',
38
+    resizeLargeVideo: 'resize-large-video',
38 39
     sendEndpointTextMessage: 'send-endpoint-text-message',
39 40
     sendTones: 'send-tones',
40 41
     setLargeVideoParticipant: 'set-large-video-participant',
@@ -437,10 +438,12 @@ export default class JitsiMeetExternalAPI extends EventEmitter {
437 438
         const parsedWidth = parseSizeParam(width);
438 439
 
439 440
         if (parsedHeight !== undefined) {
441
+            this._height = height;
440 442
             this._frame.style.height = parsedHeight;
441 443
         }
442 444
 
443 445
         if (parsedWidth !== undefined) {
446
+            this._width = width;
444 447
             this._frame.style.width = parsedWidth;
445 448
         }
446 449
     }
@@ -930,6 +933,19 @@ export default class JitsiMeetExternalAPI extends EventEmitter {
930 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 950
      * Passes an event along to the local conference participant to establish
935 951
      * or update a direct peer connection. This is currently used for developing

+ 0
- 7
modules/UI/util/UIUtil.js Datei anzeigen

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

+ 12
- 8
modules/UI/videolayout/LargeVideoManager.js Datei anzeigen

@@ -21,7 +21,6 @@ import { PresenceLabel } from '../../../react/features/presence-status';
21 21
 import UIEvents from '../../../service/UI/UIEvents';
22 22
 import { createDeferred } from '../../util/helpers';
23 23
 import AudioLevels from '../audio_levels/AudioLevels';
24
-import UIUtil from '../util/UIUtil';
25 24
 
26 25
 import { VideoContainer, VIDEO_CONTAINER_TYPE } from './VideoContainer';
27 26
 
@@ -323,20 +322,25 @@ export default class LargeVideoManager {
323 322
     /**
324 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 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 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 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 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 Datei anzeigen

@@ -2,6 +2,7 @@
2 2
 
3 3
 import type { Dispatch } from 'redux';
4 4
 
5
+import VideoLayout from '../../../modules/UI/videolayout/VideoLayout';
5 6
 import {
6 7
     createSelectParticipantFailedEvent,
7 8
     sendAnalytics
@@ -19,6 +20,27 @@ import {
19 20
 
20 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 45
  * Signals conference to select a participant.
24 46
  *

Laden…
Abbrechen
Speichern