Quellcode durchsuchen

fix(share-youtube-video): Validate youtube url.

j8
Tudor D. Pop vor 3 Jahren
Ursprung
Commit
8d562b9d59
Es ist kein Account mit der E-Mail-Adresse des Committers verbunden

+ 1
- 1
lang/main.json Datei anzeigen

@@ -311,7 +311,7 @@
311 311
         "shareAudioWarningD1": "you need to stop screen sharing before sharing your audio.",
312 312
         "shareAudioWarningD2": "you need to restart your screen sharing and check the \"share audio\" option.",
313 313
         "shareMediaWarningGenericH2": "If you want to share your screen and audio",
314
-        "shareVideoLinkError": "Please provide a correct youtube link.",
314
+        "shareVideoLinkError": "Please provide a correct video link.",
315 315
         "shareVideoTitle": "Share video",
316 316
         "shareYourScreen": "Share your screen",
317 317
         "shareYourScreenDisabled": "Screen sharing disabled.",

+ 34
- 3
react/features/shared-video/components/web/AbstractVideoManager.js Datei anzeigen

@@ -1,6 +1,6 @@
1 1
 /* @flow */
2 2
 /* eslint-disable no-invalid-this */
3
-
3
+import Logger from 'jitsi-meet-logger';
4 4
 import throttle from 'lodash/throttle';
5 5
 import { Component } from 'react';
6 6
 
@@ -9,16 +9,18 @@ import { getCurrentConference } from '../../../base/conference';
9 9
 import { MEDIA_TYPE } from '../../../base/media';
10 10
 import { getLocalParticipant } from '../../../base/participants';
11 11
 import { isLocalTrackMuted } from '../../../base/tracks';
12
+import { showWarningNotification } from '../../../notifications/actions';
12 13
 import { dockToolbox } from '../../../toolbox/actions.web';
13 14
 import { muteLocal } from '../../../video-menu/actions.any';
14
-import { setSharedVideoStatus } from '../../actions.any';
15
-
15
+import { setSharedVideoStatus, stopSharedVideo } from '../../actions.any';
16 16
 export const PLAYBACK_STATES = {
17 17
     PLAYING: 'playing',
18 18
     PAUSED: 'pause',
19 19
     STOPPED: 'stop'
20 20
 };
21 21
 
22
+const logger = Logger.getLogger(__filename);
23
+
22 24
 /**
23 25
  * Return true if the diffenrece between the two timees is larger than 5.
24 26
  *
@@ -41,11 +43,21 @@ export type Props = {
41 43
      */
42 44
     _conference: Object,
43 45
 
46
+    /**
47
+     * Warning that indicates an incorect video url
48
+     */
49
+    _displayWarning: Function,
50
+
44 51
     /**
45 52
      * Docks the toolbox
46 53
      */
47 54
     _dockToolbox: Function,
48 55
 
56
+    /**
57
+     * Action to stop video sharing
58
+    */
59
+    _stopSharedVideo: Function,
60
+
49 61
     /**
50 62
      * Indicates whether the local audio is muted
51 63
     */
@@ -197,6 +209,17 @@ class AbstractVideoManager extends Component<Props> {
197 209
         }
198 210
     }
199 211
 
212
+    /**
213
+     * Handle video error.
214
+     *
215
+     * @returns {void}
216
+     */
217
+    onError() {
218
+        logger.error('Error in the video player');
219
+        this.props._stopSharedVideo();
220
+        this.props._displayWarning();
221
+    }
222
+
200 223
     /**
201 224
      * Handle video playing.
202 225
      *
@@ -406,9 +429,17 @@ export function _mapStateToProps(state: Object): $Shape<Props> {
406 429
  */
407 430
 export function _mapDispatchToProps(dispatch: Function): $Shape<Props> {
408 431
     return {
432
+        _displayWarning: () => {
433
+            dispatch(showWarningNotification({
434
+                titleKey: 'dialog.shareVideoLinkError'
435
+            }));
436
+        },
409 437
         _dockToolbox: value => {
410 438
             dispatch(dockToolbox(value));
411 439
         },
440
+        _stopSharedVideo: () => {
441
+            dispatch(stopSharedVideo());
442
+        },
412 443
         _muteLocal: value => {
413 444
             dispatch(muteLocal(value, MEDIA_TYPE.AUDIO));
414 445
         },

+ 1
- 5
react/features/shared-video/components/web/VideoManager.js Datei anzeigen

@@ -1,4 +1,3 @@
1
-import Logger from 'jitsi-meet-logger';
2 1
 import React from 'react';
3 2
 
4 3
 import { connect } from '../../../base/redux';
@@ -10,7 +9,6 @@ import AbstractVideoManager, {
10 9
     Props
11 10
 } from './AbstractVideoManager';
12 11
 
13
-const logger = Logger.getLogger(__filename);
14 12
 
15 13
 /**
16 14
  * Manager of shared video.
@@ -162,9 +160,7 @@ class VideoManager extends AbstractVideoManager<Props> {
162 160
             autoPlay: true,
163 161
             src: videoId,
164 162
             controls: _isOwner,
165
-            onError: event => {
166
-                logger.error('Error in the player:', event);
167
-            },
163
+            onError: () => this.onError(),
168 164
             onPlay: () => this.onPlay(),
169 165
             onVolumeChange: () => this.onVolumeChange()
170 166
         };

+ 1
- 23
react/features/shared-video/components/web/YoutubeVideoManager.js Datei anzeigen

@@ -1,5 +1,4 @@
1 1
 /* eslint-disable no-invalid-this */
2
-import Logger from 'jitsi-meet-logger';
3 2
 import React from 'react';
4 3
 import YouTube from 'react-youtube';
5 4
 
@@ -11,8 +10,6 @@ import AbstractVideoManager, {
11 10
     PLAYBACK_STATES
12 11
 } from './AbstractVideoManager';
13 12
 
14
-const logger = Logger.getLogger(__filename);
15
-
16 13
 /**
17 14
  * Manager of shared video.
18 15
  *
@@ -152,11 +149,6 @@ class YoutubeVideoManager extends AbstractVideoManager<Props> {
152 149
             this.player.destroy();
153 150
             this.player = null;
154 151
         }
155
-
156
-        if (this.errorInPlayer) {
157
-            this.errorInPlayer.destroy();
158
-            this.errorInPlayer = null;
159
-        }
160 152
     }
161 153
 
162 154
     /**
@@ -203,20 +195,6 @@ class YoutubeVideoManager extends AbstractVideoManager<Props> {
203 195
         }
204 196
     };
205 197
 
206
-    /**
207
-     * Fired when youtube player throws an error.
208
-     *
209
-     * @param {Object} event - Youtube player error event.
210
-     *
211
-     * @returns {void}
212
-     */
213
-    onPlayerError = event => {
214
-        logger.error('Error in the player:', event.data);
215
-
216
-        // store the error player, so we can remove it
217
-        this.errorInPlayer = event.target;
218
-    };
219
-
220 198
     getPlayerOptions = () => {
221 199
         const { _isOwner, videoId } = this.props;
222 200
         const showControls = _isOwner ? 1 : 0;
@@ -234,7 +212,7 @@ class YoutubeVideoManager extends AbstractVideoManager<Props> {
234 212
                     'rel': 0
235 213
                 }
236 214
             },
237
-            onError: this.onPlayerError,
215
+            onError: () => this.onError(),
238 216
             onReady: this.onPlayerReady,
239 217
             onStateChange: this.onPlayerStateChange,
240 218
             videoId

+ 1
- 0
react/features/shared-video/functions.js Datei anzeigen

@@ -53,3 +53,4 @@ export function isVideoPlaying(stateful: Object | Function): boolean {
53 53
 
54 54
     return videoPlaying;
55 55
 }
56
+

Laden…
Abbrechen
Speichern