Bläddra i källkod

fix(share-video) fix backwards compatibility issue

j8
Tudor-Ovidiu Avram 3 år sedan
förälder
incheckning
b2985934f7

+ 1
- 1
react/features/base/participants/components/ParticipantView.native.js Visa fil

@@ -224,7 +224,7 @@ class ParticipantView extends Component<Props> {
224 224
                     onPress = { renderYoutubeLargeVideo ? undefined : onPress }
225 225
                     value = '' />
226 226
 
227
-                { renderYoutubeLargeVideo && <YoutubeLargeVideo youtubeUrl = { this.props.participantId } /> }
227
+                { renderYoutubeLargeVideo && <YoutubeLargeVideo youtubeId = { this.props.participantId } /> }
228 228
 
229 229
                 { !_isFakeParticipant && renderVideo
230 230
                     && <VideoTrack

+ 1
- 1
react/features/shared-video/components/native/SharedVideoDialog.js Visa fil

@@ -49,7 +49,7 @@ class SharedVideoDialog extends AbstractSharedVideoDialog<*> {
49 49
         if (videoId) {
50 50
             const { onPostSubmit } = this.props;
51 51
 
52
-            onPostSubmit && onPostSubmit(link);
52
+            onPostSubmit && onPostSubmit(videoId);
53 53
 
54 54
             return true;
55 55
         }

+ 9
- 10
react/features/shared-video/components/native/YoutubeLargeVideo.js Visa fil

@@ -9,7 +9,6 @@ import { connect } from '../../../base/redux';
9 9
 import { ASPECT_RATIO_WIDE } from '../../../base/responsive-ui';
10 10
 import { setToolboxVisible } from '../../../toolbox/actions';
11 11
 import { setSharedVideoStatus } from '../../actions.native';
12
-import { getYoutubeId } from '../../functions';
13 12
 
14 13
 import styles from './styles';
15 14
 
@@ -101,11 +100,11 @@ type Props = {
101 100
     dispatch: Function,
102 101
 
103 102
     /**
104
-     * Youtube url of the video to be played.
103
+     * Youtube id of the video to be played.
105 104
      *
106 105
      * @private
107 106
      */
108
-    youtubeUrl: string
107
+     youtubeId: string
109 108
 };
110 109
 
111 110
 /**
@@ -200,7 +199,7 @@ class YoutubeLargeVideo extends Component<Props, *> {
200 199
             _isPlaying,
201 200
             _playerHeight,
202 201
             _playerWidth,
203
-            youtubeUrl
202
+            youtubeId
204 203
         } = this.props;
205 204
 
206 205
         return (
@@ -221,7 +220,7 @@ class YoutubeLargeVideo extends Component<Props, *> {
221 220
                     play = { _isPlaying }
222 221
                     playbackRate = { 1 }
223 222
                     ref = { this.playerRef }
224
-                    videoId = { getYoutubeId(youtubeUrl) }
223
+                    videoId = { youtubeId }
225 224
                     volume = { 50 }
226 225
                     webViewProps = {{
227 226
                         bounces: false,
@@ -244,7 +243,7 @@ class YoutubeLargeVideo extends Component<Props, *> {
244 243
     _onReady() {
245 244
         if (this.props?._isOwner) {
246 245
             this.onVideoReady(
247
-                this.props.youtubeUrl,
246
+                this.props.youtubeId,
248 247
                 this.playerRef.current && this.playerRef.current.getCurrentTime(),
249 248
                 this.props._ownerId);
250 249
         }
@@ -267,11 +266,11 @@ class YoutubeLargeVideo extends Component<Props, *> {
267 266
                 _isStopped,
268 267
                 _ownerId,
269 268
                 _seek,
270
-                youtubeUrl
269
+                youtubeId
271 270
             } = this.props;
272 271
 
273 272
             if (shouldSetNewStatus(_isStopped, _isOwner, status, _isPlaying, time, _seek)) {
274
-                this.onVideoChangeEvent(youtubeUrl, status, time, _ownerId);
273
+                this.onVideoChangeEvent(youtubeId, status, time, _ownerId);
275 274
             }
276 275
         });
277 276
     }
@@ -283,10 +282,10 @@ class YoutubeLargeVideo extends Component<Props, *> {
283 282
      * @returns {void}
284 283
     */
285 284
     saveRefTime() {
286
-        const { youtubeUrl, _status, _ownerId } = this.props;
285
+        const { youtubeId, _status, _ownerId } = this.props;
287 286
 
288 287
         this.playerRef.current && this.playerRef.current.getCurrentTime().then(time => {
289
-            this.onVideoChangeEvent(youtubeUrl, _status, time, _ownerId);
288
+            this.onVideoChangeEvent(youtubeId, _status, time, _ownerId);
290 289
         });
291 290
     }
292 291
 

+ 8
- 18
react/features/shared-video/components/web/SharedVideo.js Visa fil

@@ -6,7 +6,6 @@ import Filmstrip from '../../../../../modules/UI/videolayout/Filmstrip';
6 6
 import { getLocalParticipant } from '../../../base/participants';
7 7
 import { connect } from '../../../base/redux';
8 8
 import { getToolboxHeight } from '../../../toolbox/functions.web';
9
-import { getYoutubeId } from '../../functions';
10 9
 
11 10
 import VideoManager from './VideoManager';
12 11
 import YoutubeVideoManager from './YoutubeVideoManager';
@@ -38,14 +37,9 @@ type Props = {
38 37
      isOwner: boolean,
39 38
 
40 39
     /**
41
-     * The shared video id
40
+     * The shared video url
42 41
      */
43
-     sharedVideoId: string,
44
-
45
-    /**
46
-     * The shared youtube video id
47
-     */
48
-     sharedYoutubeVideoId: string,
42
+     videoUrl: string,
49 43
 }
50 44
 
51 45
 /**
@@ -97,20 +91,17 @@ class SharedVideo extends Component<Props> {
97 91
      * @returns {Component}
98 92
      */
99 93
     getManager() {
100
-        const {
101
-            sharedVideoId,
102
-            sharedYoutubeVideoId
103
-        } = this.props;
94
+        const { videoUrl } = this.props;
104 95
 
105
-        if (!sharedVideoId) {
96
+        if (!videoUrl) {
106 97
             return null;
107 98
         }
108 99
 
109
-        if (sharedYoutubeVideoId) {
110
-            return <YoutubeVideoManager videoId = { sharedYoutubeVideoId } />;
100
+        if (videoUrl.match(/http/)) {
101
+            return <VideoManager videoId = { videoUrl } />;
111 102
         }
112 103
 
113
-        return <VideoManager videoId = { sharedVideoId } />;
104
+        return <YoutubeVideoManager videoId = { videoUrl } />;
114 105
     }
115 106
 
116 107
     /**
@@ -154,8 +145,7 @@ function _mapStateToProps(state) {
154 145
         clientWidth,
155 146
         filmstripVisible: visible,
156 147
         isOwner: ownerId === localParticipant.id,
157
-        sharedVideoId: videoUrl,
158
-        sharedYoutubeVideoId: getYoutubeId(videoUrl)
148
+        videoUrl
159 149
     };
160 150
 }
161 151
 

+ 3
- 1
react/features/shared-video/components/web/SharedVideoDialog.js Visa fil

@@ -8,6 +8,7 @@ import { translate } from '../../../base/i18n';
8 8
 import { getFieldValue } from '../../../base/react';
9 9
 import { connect } from '../../../base/redux';
10 10
 import { defaultSharedVideoLink } from '../../constants';
11
+import { getYoutubeId } from '../../functions';
11 12
 import AbstractSharedVideoDialog from '../AbstractSharedVideoDialog';
12 13
 
13 14
 /**
@@ -108,9 +109,10 @@ class SharedVideoDialog extends AbstractSharedVideoDialog<*> {
108 109
             return false;
109 110
         }
110 111
 
112
+        const youtubeId = getYoutubeId(link);
111 113
         const { onPostSubmit } = this.props;
112 114
 
113
-        onPostSubmit(link);
115
+        onPostSubmit(youtubeId || link);
114 116
 
115 117
         return true;
116 118
     }

+ 2
- 2
react/features/shared-video/middleware.any.js Visa fil

@@ -18,7 +18,7 @@ import {
18 18
     setSharedVideoStatus
19 19
 } from './actions.any';
20 20
 import { SHARED_VIDEO, VIDEO_PLAYER_PARTICIPANT_NAME } from './constants';
21
-import { getYoutubeId, isSharingStatus } from './functions';
21
+import { isSharingStatus } from './functions';
22 22
 
23 23
 /**
24 24
  * Middleware that captures actions related to video sharing and updates
@@ -126,7 +126,7 @@ function handleSharingVideoStatus(store, videoUrl, { state, time, from, muted },
126 126
     const oldStatus = getState()['features/shared-video']?.status;
127 127
 
128 128
     if (state === 'start' || ![ 'playing', 'pause', 'start' ].includes(oldStatus)) {
129
-        const youtubeId = getYoutubeId(videoUrl);
129
+        const youtubeId = videoUrl.match(/http/) ? false : videoUrl;
130 130
         const avatarURL = youtubeId ? `https://img.youtube.com/vi/${youtubeId}/0.jpg` : '';
131 131
 
132 132
         dispatch(participantJoined({

Laddar…
Avbryt
Spara