Skip to content

Commit

Permalink
Merge pull request Expensify#38364 from jeremy-croff/38362
Browse files Browse the repository at this point in the history
fix(38362): add optional chain for stopasync video ref
  • Loading branch information
luacmartins authored Mar 15, 2024
2 parents be9a682 + 5c4a1c2 commit 71db721
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions src/components/VideoPlayerContexts/PlaybackContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -33,7 +33,7 @@ function PlaybackContextProvider({children}: ChildrenProps) {
}, [currentVideoPlayerRef]);

const unloadVideo = useCallback(() => {
currentVideoPlayerRef.current?.unloadAsync();
currentVideoPlayerRef.current?.unloadAsync?.();
}, [currentVideoPlayerRef]);

const updateCurrentlyPlayingURL = useCallback(
Expand Down Expand Up @@ -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);
});
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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],
);
Expand Down

0 comments on commit 71db721

Please sign in to comment.