diff --git a/src/components/VideoPlayerContexts/VideoPopoverMenuContext.js b/src/components/VideoPlayerContexts/VideoPopoverMenuContext.js index ed502136716f..4bb10e526fe4 100644 --- a/src/components/VideoPlayerContexts/VideoPopoverMenuContext.js +++ b/src/components/VideoPlayerContexts/VideoPopoverMenuContext.js @@ -4,15 +4,15 @@ import _ from 'underscore'; import * as Expensicons from '@components/Icon/Expensicons'; import useLocalize from '@hooks/useLocalize'; import useNetwork from '@hooks/useNetwork'; +import addEncryptedAuthTokenToURL from '@libs/addEncryptedAuthTokenToURL'; import fileDownload from '@libs/fileDownload'; -import tryResolveUrlFromApiRoot from '@libs/tryResolveUrlFromApiRoot'; import CONST from '@src/CONST'; import {usePlaybackContext} from './PlaybackContext'; const VideoPopoverMenuContext = React.createContext(null); function VideoPopoverMenuContextProvider({children}) { - const {currentVideoPlayerRef} = usePlaybackContext(); + const {currentVideoPlayerRef, currentlyPlayingURL} = usePlaybackContext(); const {translate} = useLocalize(); const [currentPlaybackSpeed, setCurrentPlaybackSpeed] = useState(CONST.VIDEO_PLAYER.PLAYBACK_SPEEDS[2]); const {isOffline} = useNetwork(); @@ -26,11 +26,9 @@ function VideoPopoverMenuContextProvider({children}) { ); const downloadAttachment = useCallback(() => { - currentVideoPlayerRef.current.getStatusAsync().then((status) => { - const sourceURI = tryResolveUrlFromApiRoot(status.uri); - fileDownload(sourceURI); - }); - }, [currentVideoPlayerRef]); + const sourceURI = currentlyPlayingURL.startsWith('blob:') || currentlyPlayingURL.startsWith('file:') ? currentlyPlayingURL : addEncryptedAuthTokenToURL(currentlyPlayingURL); + fileDownload(sourceURI); + }, [currentlyPlayingURL]); const menuItems = useMemo(() => { const items = [];