From b2985934f7ea43b28c4fbc33bea855e74fa244ab Mon Sep 17 00:00:00 2001 From: Tudor-Ovidiu Avram Date: Fri, 11 Jun 2021 11:40:23 +0300 Subject: [PATCH] fix(share-video) fix backwards compatibility issue --- .../components/ParticipantView.native.js | 2 +- .../components/native/SharedVideoDialog.js | 2 +- .../components/native/YoutubeLargeVideo.js | 19 +++++++------- .../components/web/SharedVideo.js | 26 ++++++------------- .../components/web/SharedVideoDialog.js | 4 ++- react/features/shared-video/middleware.any.js | 4 +-- 6 files changed, 24 insertions(+), 33 deletions(-) diff --git a/react/features/base/participants/components/ParticipantView.native.js b/react/features/base/participants/components/ParticipantView.native.js index ffc94101d..3c930abee 100644 --- a/react/features/base/participants/components/ParticipantView.native.js +++ b/react/features/base/participants/components/ParticipantView.native.js @@ -224,7 +224,7 @@ class ParticipantView extends Component { onPress = { renderYoutubeLargeVideo ? undefined : onPress } value = '' /> - { renderYoutubeLargeVideo && } + { renderYoutubeLargeVideo && } { !_isFakeParticipant && renderVideo && { if (videoId) { const { onPostSubmit } = this.props; - onPostSubmit && onPostSubmit(link); + onPostSubmit && onPostSubmit(videoId); return true; } diff --git a/react/features/shared-video/components/native/YoutubeLargeVideo.js b/react/features/shared-video/components/native/YoutubeLargeVideo.js index 0096ccbaf..772df86a1 100644 --- a/react/features/shared-video/components/native/YoutubeLargeVideo.js +++ b/react/features/shared-video/components/native/YoutubeLargeVideo.js @@ -9,7 +9,6 @@ import { connect } from '../../../base/redux'; import { ASPECT_RATIO_WIDE } from '../../../base/responsive-ui'; import { setToolboxVisible } from '../../../toolbox/actions'; import { setSharedVideoStatus } from '../../actions.native'; -import { getYoutubeId } from '../../functions'; import styles from './styles'; @@ -101,11 +100,11 @@ type Props = { dispatch: Function, /** - * Youtube url of the video to be played. + * Youtube id of the video to be played. * * @private */ - youtubeUrl: string + youtubeId: string }; /** @@ -200,7 +199,7 @@ class YoutubeLargeVideo extends Component { _isPlaying, _playerHeight, _playerWidth, - youtubeUrl + youtubeId } = this.props; return ( @@ -221,7 +220,7 @@ class YoutubeLargeVideo extends Component { play = { _isPlaying } playbackRate = { 1 } ref = { this.playerRef } - videoId = { getYoutubeId(youtubeUrl) } + videoId = { youtubeId } volume = { 50 } webViewProps = {{ bounces: false, @@ -244,7 +243,7 @@ class YoutubeLargeVideo extends Component { _onReady() { if (this.props?._isOwner) { this.onVideoReady( - this.props.youtubeUrl, + this.props.youtubeId, this.playerRef.current && this.playerRef.current.getCurrentTime(), this.props._ownerId); } @@ -267,11 +266,11 @@ class YoutubeLargeVideo extends Component { _isStopped, _ownerId, _seek, - youtubeUrl + youtubeId } = this.props; if (shouldSetNewStatus(_isStopped, _isOwner, status, _isPlaying, time, _seek)) { - this.onVideoChangeEvent(youtubeUrl, status, time, _ownerId); + this.onVideoChangeEvent(youtubeId, status, time, _ownerId); } }); } @@ -283,10 +282,10 @@ class YoutubeLargeVideo extends Component { * @returns {void} */ saveRefTime() { - const { youtubeUrl, _status, _ownerId } = this.props; + const { youtubeId, _status, _ownerId } = this.props; this.playerRef.current && this.playerRef.current.getCurrentTime().then(time => { - this.onVideoChangeEvent(youtubeUrl, _status, time, _ownerId); + this.onVideoChangeEvent(youtubeId, _status, time, _ownerId); }); } diff --git a/react/features/shared-video/components/web/SharedVideo.js b/react/features/shared-video/components/web/SharedVideo.js index e29b1eecd..bd05fde8e 100644 --- a/react/features/shared-video/components/web/SharedVideo.js +++ b/react/features/shared-video/components/web/SharedVideo.js @@ -6,7 +6,6 @@ import Filmstrip from '../../../../../modules/UI/videolayout/Filmstrip'; import { getLocalParticipant } from '../../../base/participants'; import { connect } from '../../../base/redux'; import { getToolboxHeight } from '../../../toolbox/functions.web'; -import { getYoutubeId } from '../../functions'; import VideoManager from './VideoManager'; import YoutubeVideoManager from './YoutubeVideoManager'; @@ -38,14 +37,9 @@ type Props = { isOwner: boolean, /** - * The shared video id + * The shared video url */ - sharedVideoId: string, - - /** - * The shared youtube video id - */ - sharedYoutubeVideoId: string, + videoUrl: string, } /** @@ -97,20 +91,17 @@ class SharedVideo extends Component { * @returns {Component} */ getManager() { - const { - sharedVideoId, - sharedYoutubeVideoId - } = this.props; + const { videoUrl } = this.props; - if (!sharedVideoId) { + if (!videoUrl) { return null; } - if (sharedYoutubeVideoId) { - return ; + if (videoUrl.match(/http/)) { + return ; } - return ; + return ; } /** @@ -154,8 +145,7 @@ function _mapStateToProps(state) { clientWidth, filmstripVisible: visible, isOwner: ownerId === localParticipant.id, - sharedVideoId: videoUrl, - sharedYoutubeVideoId: getYoutubeId(videoUrl) + videoUrl }; } diff --git a/react/features/shared-video/components/web/SharedVideoDialog.js b/react/features/shared-video/components/web/SharedVideoDialog.js index 13246cdd2..83adfd9b1 100644 --- a/react/features/shared-video/components/web/SharedVideoDialog.js +++ b/react/features/shared-video/components/web/SharedVideoDialog.js @@ -8,6 +8,7 @@ import { translate } from '../../../base/i18n'; import { getFieldValue } from '../../../base/react'; import { connect } from '../../../base/redux'; import { defaultSharedVideoLink } from '../../constants'; +import { getYoutubeId } from '../../functions'; import AbstractSharedVideoDialog from '../AbstractSharedVideoDialog'; /** @@ -108,9 +109,10 @@ class SharedVideoDialog extends AbstractSharedVideoDialog<*> { return false; } + const youtubeId = getYoutubeId(link); const { onPostSubmit } = this.props; - onPostSubmit(link); + onPostSubmit(youtubeId || link); return true; } diff --git a/react/features/shared-video/middleware.any.js b/react/features/shared-video/middleware.any.js index 6ed88303c..def1aabd8 100644 --- a/react/features/shared-video/middleware.any.js +++ b/react/features/shared-video/middleware.any.js @@ -18,7 +18,7 @@ import { setSharedVideoStatus } from './actions.any'; import { SHARED_VIDEO, VIDEO_PLAYER_PARTICIPANT_NAME } from './constants'; -import { getYoutubeId, isSharingStatus } from './functions'; +import { isSharingStatus } from './functions'; /** * Middleware that captures actions related to video sharing and updates @@ -126,7 +126,7 @@ function handleSharingVideoStatus(store, videoUrl, { state, time, from, muted }, const oldStatus = getState()['features/shared-video']?.status; if (state === 'start' || ![ 'playing', 'pause', 'start' ].includes(oldStatus)) { - const youtubeId = getYoutubeId(videoUrl); + const youtubeId = videoUrl.match(/http/) ? false : videoUrl; const avatarURL = youtubeId ? `https://img.youtube.com/vi/${youtubeId}/0.jpg` : ''; dispatch(participantJoined({