Browse Source

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

j8
Tudor D. Pop 3 years ago
parent
commit
8d562b9d59
No account linked to committer's email address

+ 1
- 1
lang/main.json View File

311
         "shareAudioWarningD1": "you need to stop screen sharing before sharing your audio.",
311
         "shareAudioWarningD1": "you need to stop screen sharing before sharing your audio.",
312
         "shareAudioWarningD2": "you need to restart your screen sharing and check the \"share audio\" option.",
312
         "shareAudioWarningD2": "you need to restart your screen sharing and check the \"share audio\" option.",
313
         "shareMediaWarningGenericH2": "If you want to share your screen and audio",
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
         "shareVideoTitle": "Share video",
315
         "shareVideoTitle": "Share video",
316
         "shareYourScreen": "Share your screen",
316
         "shareYourScreen": "Share your screen",
317
         "shareYourScreenDisabled": "Screen sharing disabled.",
317
         "shareYourScreenDisabled": "Screen sharing disabled.",

+ 34
- 3
react/features/shared-video/components/web/AbstractVideoManager.js View File

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

+ 1
- 5
react/features/shared-video/components/web/VideoManager.js View File

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

+ 1
- 23
react/features/shared-video/components/web/YoutubeVideoManager.js View File

1
 /* eslint-disable no-invalid-this */
1
 /* eslint-disable no-invalid-this */
2
-import Logger from 'jitsi-meet-logger';
3
 import React from 'react';
2
 import React from 'react';
4
 import YouTube from 'react-youtube';
3
 import YouTube from 'react-youtube';
5
 
4
 
11
     PLAYBACK_STATES
10
     PLAYBACK_STATES
12
 } from './AbstractVideoManager';
11
 } from './AbstractVideoManager';
13
 
12
 
14
-const logger = Logger.getLogger(__filename);
15
-
16
 /**
13
 /**
17
  * Manager of shared video.
14
  * Manager of shared video.
18
  *
15
  *
152
             this.player.destroy();
149
             this.player.destroy();
153
             this.player = null;
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
         }
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
     getPlayerOptions = () => {
198
     getPlayerOptions = () => {
221
         const { _isOwner, videoId } = this.props;
199
         const { _isOwner, videoId } = this.props;
222
         const showControls = _isOwner ? 1 : 0;
200
         const showControls = _isOwner ? 1 : 0;
234
                     'rel': 0
212
                     'rel': 0
235
                 }
213
                 }
236
             },
214
             },
237
-            onError: this.onPlayerError,
215
+            onError: () => this.onError(),
238
             onReady: this.onPlayerReady,
216
             onReady: this.onPlayerReady,
239
             onStateChange: this.onPlayerStateChange,
217
             onStateChange: this.onPlayerStateChange,
240
             videoId
218
             videoId

+ 1
- 0
react/features/shared-video/functions.js View File

53
 
53
 
54
     return videoPlaying;
54
     return videoPlaying;
55
 }
55
 }
56
+

Loading…
Cancel
Save