diff --git a/src/components/VideoPlayer/BaseVideoPlayer.js b/src/components/VideoPlayer/BaseVideoPlayer.js index 060bc890d5e7..8ab81afab710 100644 --- a/src/components/VideoPlayer/BaseVideoPlayer.js +++ b/src/components/VideoPlayer/BaseVideoPlayer.js @@ -142,6 +142,10 @@ function BaseVideoPlayer({ }); }, [currentVideoPlayerRef, handleFullscreenUpdate, handlePlaybackStatusUpdate]); + useEffect(() => { + currentVideoPlayerRef.current = videoPlayerRef.current; + }, [url, currentVideoPlayerRef]); + // update shared video elements useEffect(() => { if (shouldUseSharedVideoElement || url !== currentlyPlayingURL) { diff --git a/src/components/VideoPlayerContexts/VideoPopoverMenuContext.js b/src/components/VideoPlayerContexts/VideoPopoverMenuContext.js index 4bb10e526fe4..4a5c15080c98 100644 --- a/src/components/VideoPlayerContexts/VideoPopoverMenuContext.js +++ b/src/components/VideoPlayerContexts/VideoPopoverMenuContext.js @@ -16,6 +16,7 @@ function VideoPopoverMenuContextProvider({children}) { const {translate} = useLocalize(); const [currentPlaybackSpeed, setCurrentPlaybackSpeed] = useState(CONST.VIDEO_PLAYER.PLAYBACK_SPEEDS[2]); const {isOffline} = useNetwork(); + const isLocalFile = currentlyPlayingURL && _.some(CONST.ATTACHMENT_LOCAL_URL_PREFIX, (prefix) => currentlyPlayingURL.startsWith(prefix)); const updatePlaybackSpeed = useCallback( (speed) => { @@ -26,14 +27,14 @@ function VideoPopoverMenuContextProvider({children}) { ); const downloadAttachment = useCallback(() => { - const sourceURI = currentlyPlayingURL.startsWith('blob:') || currentlyPlayingURL.startsWith('file:') ? currentlyPlayingURL : addEncryptedAuthTokenToURL(currentlyPlayingURL); + const sourceURI = addEncryptedAuthTokenToURL(currentlyPlayingURL); fileDownload(sourceURI); }, [currentlyPlayingURL]); const menuItems = useMemo(() => { const items = []; - if (!isOffline) { + if (!isOffline && !isLocalFile) { items.push({ icon: Expensicons.Download, text: translate('common.download'), @@ -59,7 +60,7 @@ function VideoPopoverMenuContextProvider({children}) { }); return items; - }, [currentPlaybackSpeed, downloadAttachment, translate, updatePlaybackSpeed, isOffline]); + }, [currentPlaybackSpeed, downloadAttachment, translate, updatePlaybackSpeed, isOffline, isLocalFile]); const contextValue = useMemo(() => ({menuItems, updatePlaybackSpeed}), [menuItems, updatePlaybackSpeed]); return {children};