Skip to content

Commit

Permalink
Fix sharing video player from chat to attachment modal
Browse files Browse the repository at this point in the history
  • Loading branch information
Skalakid committed Feb 26, 2024
1 parent 56c0218 commit b08fbc9
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
4 changes: 2 additions & 2 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1999,8 +1999,8 @@ SPEC CHECKSUMS:
SocketRocket: f32cd54efbe0f095c4d7594881e52619cfe80b17
Turf: 13d1a92d969ca0311bbc26e8356cca178ce95da2
VisionCamera: 0a6794d1974aed5d653d0d0cb900493e2583e35a
Yoga: e64aa65de36c0832d04e8c7bd614396c77a80047
Yoga: 13c8ef87792450193e117976337b8527b49e8c03

PODFILE CHECKSUM: 0ccbb4f2406893c6e9f266dc1e7470dcd72885d2

COCOAPODS: 1.13.0
COCOAPODS: 1.14.3
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ function CarouselItem({item, onPress, isFocused, isModalHovered}) {
isHovered={isModalHovered}
isFocused={isFocused}
optionalVideoDuration={item.duration}
isUsedInCarousel
/>
</View>

Expand Down
18 changes: 10 additions & 8 deletions src/components/VideoPlayer/BaseVideoPlayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import PressableWithoutFeedback from '@components/Pressable/PressableWithoutFeed
import {usePlaybackContext} from '@components/VideoPlayerContexts/PlaybackContext';
import VideoPopoverMenu from '@components/VideoPopoverMenu';
import useThemeStyles from '@hooks/useThemeStyles';
import useWindowDimensions from '@hooks/useWindowDimensions';
import addEncryptedAuthTokenToURL from '@libs/addEncryptedAuthTokenToURL';
import * as Browser from '@libs/Browser';
import * as DeviceCapabilities from '@libs/DeviceCapabilities';
Expand Down Expand Up @@ -41,7 +40,6 @@ function BaseVideoPlayer({
isVideoHovered,
}) {
const styles = useThemeStyles();
const {isSmallScreenWidth} = useWindowDimensions();
const {pauseVideo, playVideo, currentlyPlayingURL, updateSharedElements, sharedElement, originalParent, shareVideoPlayerElements, currentVideoPlayerRef, updateCurrentlyPlayingURL} =
usePlaybackContext();
const [duration, setDuration] = useState(videoDuration * 1000);
Expand Down Expand Up @@ -96,20 +94,24 @@ function BaseVideoPlayer({

const handlePlaybackStatusUpdate = useCallback(
(e) => {
if (shouldReplayVideo(e, isPlaying, duration, position)) {
const isVideoPlaying = e.isPlaying || false;
const currentDuration = e.durationMillis || videoDuration * 1000;
const currentPositon = e.positionMillis || 0;

if (shouldReplayVideo(e, isVideoPlaying, currentDuration, currentPositon)) {
videoPlayerRef.current.setStatusAsync({positionMillis: 0, shouldPlay: true});
}
const isVideoPlaying = e.isPlaying || false;

preventPausingWhenExitingFullscreen(isVideoPlaying);
setIsPlaying(isVideoPlaying);
setIsLoading(!e.isLoaded || Number.isNaN(e.durationMillis)); // when video is ready to display duration is not NaN
setIsBuffering(e.isBuffering || false);
setDuration(e.durationMillis || videoDuration * 1000);
setPosition(e.positionMillis || 0);
setDuration(currentDuration);
setPosition(currentPositon);

onPlaybackStatusUpdate(e);
},
[onPlaybackStatusUpdate, preventPausingWhenExitingFullscreen, videoDuration, isPlaying, duration, position],
[onPlaybackStatusUpdate, preventPausingWhenExitingFullscreen, videoDuration],
);

const handleFullscreenUpdate = useCallback(
Expand Down Expand Up @@ -165,7 +167,7 @@ function BaseVideoPlayer({
}
originalParent.appendChild(sharedElement);
};
}, [bindFunctions, currentVideoPlayerRef, currentlyPlayingURL, isSmallScreenWidth, originalParent, sharedElement, shouldUseSharedVideoElement, url]);
}, [bindFunctions, currentVideoPlayerRef, currentlyPlayingURL, originalParent, sharedElement, shouldUseSharedVideoElement, url]);

return (
<>
Expand Down

0 comments on commit b08fbc9

Please sign in to comment.