Sfoglia il codice sorgente

fix(iframeAPI): startShareVideo command.

master
Hristo Terezov 3 anni fa
parent
commit
2c2b2c0bec

+ 6
- 1
modules/API/API.js Vedi File

71
 import { startScreenShareFlow, startAudioScreenShareFlow } from '../../react/features/screen-share/actions';
71
 import { startScreenShareFlow, startAudioScreenShareFlow } from '../../react/features/screen-share/actions';
72
 import { toggleScreenshotCaptureSummary } from '../../react/features/screenshot-capture';
72
 import { toggleScreenshotCaptureSummary } from '../../react/features/screenshot-capture';
73
 import { playSharedVideo, stopSharedVideo } from '../../react/features/shared-video/actions.any';
73
 import { playSharedVideo, stopSharedVideo } from '../../react/features/shared-video/actions.any';
74
+import { extractYoutubeIdOrURL } from '../../react/features/shared-video/functions';
74
 import { toggleTileView, setTileView } from '../../react/features/video-layout';
75
 import { toggleTileView, setTileView } from '../../react/features/video-layout';
75
 import { muteAllParticipants } from '../../react/features/video-menu/actions';
76
 import { muteAllParticipants } from '../../react/features/video-menu/actions';
76
 import { setVideoQuality } from '../../react/features/video-quality';
77
 import { setVideoQuality } from '../../react/features/video-quality';
382
         'start-share-video': url => {
383
         'start-share-video': url => {
383
             logger.debug('Share video command received');
384
             logger.debug('Share video command received');
384
             sendAnalytics(createApiEvent('share.video.start'));
385
             sendAnalytics(createApiEvent('share.video.start'));
385
-            APP.store.dispatch(playSharedVideo(url));
386
+            const id = extractYoutubeIdOrURL(url);
387
+
388
+            if (id) {
389
+                APP.store.dispatch(playSharedVideo(id));
390
+            }
386
         },
391
         },
387
 
392
 
388
         'stop-share-video': () => {
393
         'stop-share-video': () => {

+ 4
- 23
react/features/shared-video/components/AbstractSharedVideoDialog.js Vedi File

3
 import { Component } from 'react';
3
 import { Component } from 'react';
4
 import type { Dispatch } from 'redux';
4
 import type { Dispatch } from 'redux';
5
 
5
 
6
-import { getYoutubeId } from '../functions';
6
+import { extractYoutubeIdOrURL } from '../functions';
7
 
7
 
8
 /**
8
 /**
9
  * The type of the React {@code Component} props of
9
  * The type of the React {@code Component} props of
56
      * @returns {boolean}
56
      * @returns {boolean}
57
      */
57
      */
58
     _onSetVideoLink(link: string) {
58
     _onSetVideoLink(link: string) {
59
-        if (!link) {
60
-            return false;
61
-        }
62
-
63
-        const trimmedLink = link.trim();
64
-
65
-        if (!trimmedLink) {
66
-            return false;
67
-        }
68
-
69
         const { onPostSubmit } = this.props;
59
         const { onPostSubmit } = this.props;
70
-        const youtubeId = getYoutubeId(trimmedLink);
71
 
60
 
72
-        if (youtubeId) {
73
-            onPostSubmit(youtubeId);
74
-
75
-            return true;
76
-        }
61
+        const id = extractYoutubeIdOrURL(link);
77
 
62
 
78
-        // Check if the URL is valid, native may crash otherwise.
79
-        try {
80
-            // eslint-disable-next-line no-new
81
-            new URL(trimmedLink);
82
-        } catch (_) {
63
+        if (!id) {
83
             return false;
64
             return false;
84
         }
65
         }
85
 
66
 
86
-        onPostSubmit(trimmedLink);
67
+        onPostSubmit(id);
87
 
68
 
88
         return true;
69
         return true;
89
     }
70
     }

+ 35
- 1
react/features/shared-video/functions.js Vedi File

12
  * @param {string} url - The entered video link.
12
  * @param {string} url - The entered video link.
13
  * @returns {string} The youtube video id if matched.
13
  * @returns {string} The youtube video id if matched.
14
  */
14
  */
15
-export function getYoutubeId(url: string) {
15
+function getYoutubeId(url: string) {
16
     if (!url) {
16
     if (!url) {
17
         return null;
17
         return null;
18
     }
18
     }
54
     return videoPlaying;
54
     return videoPlaying;
55
 }
55
 }
56
 
56
 
57
+/**
58
+ * Extracts a Youtube id or URL from the user input.
59
+ *
60
+ * @param {string} input - The user input.
61
+ * @returns {string|undefined}
62
+ */
63
+export function extractYoutubeIdOrURL(input: string) {
64
+    if (!input) {
65
+        return;
66
+    }
67
+
68
+    const trimmedLink = input.trim();
69
+
70
+    if (!trimmedLink) {
71
+        return;
72
+    }
73
+
74
+    const youtubeId = getYoutubeId(trimmedLink);
75
+
76
+    if (youtubeId) {
77
+        return youtubeId;
78
+    }
79
+
80
+    // Check if the URL is valid, native may crash otherwise.
81
+    try {
82
+        // eslint-disable-next-line no-new
83
+        new URL(trimmedLink);
84
+    } catch (_) {
85
+        return;
86
+    }
87
+
88
+    return trimmedLink;
89
+}
90
+

Loading…
Annulla
Salva