From e87167dd2d8be66a94b0c783d6d0401042872223 Mon Sep 17 00:00:00 2001 From: Titus-Andrei Moldovan Date: Wed, 17 Jun 2020 14:35:40 +0300 Subject: [PATCH] rn: fixes the propagation of the paused event after the status was set to stop --- .../components/native/YoutubeLargeVideo.js | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/react/features/youtube-player/components/native/YoutubeLargeVideo.js b/react/features/youtube-player/components/native/YoutubeLargeVideo.js index 1229d5b37..4ccab52bc 100644 --- a/react/features/youtube-player/components/native/YoutubeLargeVideo.js +++ b/react/features/youtube-player/components/native/YoutubeLargeVideo.js @@ -101,6 +101,13 @@ type Props = { */ _seek: number, + /** + * Set to true when the status is set to stop and the view should not react to further changes. + * + * @private + */ + _shouldPrepareForStop: boolean, + /** * Youtube id of the video to be played. * @@ -131,10 +138,11 @@ const YoutubeLargeVideo = (props: Props) => { const { _isOwner, _isPlaying, + _shouldPrepareForStop, _seek } = props; - if (shouldSetNewStatus(_isOwner, e, _isPlaying, time, _seek)) { + if (shouldSetNewStatus(_shouldPrepareForStop, _isOwner, e, _isPlaying, time, _seek)) { props._onVideoChangeEvent(props.youtubeId, e, time, props._ownerId); } }); @@ -193,6 +201,7 @@ const YoutubeLargeVideo = (props: Props) => { * Return true if the user is the owner and * the status has changed or the seek time difference from the previous set is larger than 5 seconds. * + * @param {boolean} shouldPrepareForStop - Once the status was set to stop, all the other statuses should be ignored. * @param {boolean} isOwner - Whether the local user is sharing the video. * @param {string} status - The new status. * @param {boolean} isPlaying - Whether the component is playing at the moment. @@ -201,7 +210,11 @@ const YoutubeLargeVideo = (props: Props) => { * @private * @returns {boolean} */ -function shouldSetNewStatus(isOwner, status, isPlaying, newTime, previousTime) { +function shouldSetNewStatus(shouldPrepareForStop, isOwner, status, isPlaying, newTime, previousTime) { + if (shouldPrepareForStop) { + return false; + } + if (!isOwner || status === 'buffering') { return false; } @@ -247,7 +260,8 @@ function _mapStateToProps(state) { _ownerId: ownerId, _screenHeight: screenHeight, _screenWidth: screenWidth, - _seek: time + _seek: time, + _shouldPrepareForStop: status === 'stop' }; }