From c427782cfe1ffec68debead6d3d34ea132e82b1b Mon Sep 17 00:00:00 2001 From: Carlos Martins Date: Thu, 14 Mar 2024 18:52:36 -0600 Subject: [PATCH] Merge pull request #38364 from jeremy-croff/38362 fix(38362): add optional chain for stopasync video ref (cherry picked from commit 71db721203386f684332f4a25cf4eb195cc52522) --- src/components/VideoPlayerContexts/PlaybackContext.tsx | 10 +++++----- .../VideoPlayerContexts/VideoPopoverMenuContext.tsx | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/components/VideoPlayerContexts/PlaybackContext.tsx b/src/components/VideoPlayerContexts/PlaybackContext.tsx index ae33a82fd0e7..caad4ce5519b 100644 --- a/src/components/VideoPlayerContexts/PlaybackContext.tsx +++ b/src/components/VideoPlayerContexts/PlaybackContext.tsx @@ -15,15 +15,15 @@ function PlaybackContextProvider({children}: ChildrenProps) { const {currentReportID} = useCurrentReportID() ?? {}; const pauseVideo = useCallback(() => { - currentVideoPlayerRef.current?.setStatusAsync({shouldPlay: false}); + currentVideoPlayerRef.current?.setStatusAsync?.({shouldPlay: false}); }, [currentVideoPlayerRef]); const stopVideo = useCallback(() => { - currentVideoPlayerRef.current?.stopAsync(); + currentVideoPlayerRef.current?.stopAsync?.(); }, [currentVideoPlayerRef]); const playVideo = useCallback(() => { - currentVideoPlayerRef.current?.getStatusAsync().then((status) => { + currentVideoPlayerRef.current?.getStatusAsync?.().then((status) => { const newStatus: AVPlaybackStatusToSet = {shouldPlay: true}; if ('durationMillis' in status && status.durationMillis === status.positionMillis) { newStatus.positionMillis = 0; @@ -33,7 +33,7 @@ function PlaybackContextProvider({children}: ChildrenProps) { }, [currentVideoPlayerRef]); const unloadVideo = useCallback(() => { - currentVideoPlayerRef.current?.unloadAsync(); + currentVideoPlayerRef.current?.unloadAsync?.(); }, [currentVideoPlayerRef]); const updateCurrentlyPlayingURL = useCallback( @@ -61,7 +61,7 @@ function PlaybackContextProvider({children}: ChildrenProps) { const checkVideoPlaying = useCallback( (statusCallback: StatusCallback) => { - currentVideoPlayerRef.current?.getStatusAsync().then((status) => { + currentVideoPlayerRef.current?.getStatusAsync?.().then((status) => { statusCallback('isPlaying' in status && status.isPlaying); }); }, diff --git a/src/components/VideoPlayerContexts/VideoPopoverMenuContext.tsx b/src/components/VideoPlayerContexts/VideoPopoverMenuContext.tsx index 0a53801683c3..f953ed802623 100644 --- a/src/components/VideoPlayerContexts/VideoPopoverMenuContext.tsx +++ b/src/components/VideoPlayerContexts/VideoPopoverMenuContext.tsx @@ -22,7 +22,7 @@ function VideoPopoverMenuContextProvider({children}: ChildrenProps) { const updatePlaybackSpeed = useCallback( (speed: PlaybackSpeed) => { setCurrentPlaybackSpeed(speed); - currentVideoPlayerRef.current?.setStatusAsync({rate: speed}); + currentVideoPlayerRef.current?.setStatusAsync?.({rate: speed}); }, [currentVideoPlayerRef], );