From ff429117cdf888fa2a85ab323d181a06e6a9899c Mon Sep 17 00:00:00 2001 From: Sean Yesmunt Date: Tue, 5 May 2020 16:45:59 -0400 Subject: [PATCH] make sure player callback has access to latest desktop start time --- ui/component/fileRenderFloating/view.jsx | 6 ++++++ ui/component/viewers/videoViewer/view.jsx | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/ui/component/fileRenderFloating/view.jsx b/ui/component/fileRenderFloating/view.jsx index d42f2e7c3..88d0eae62 100644 --- a/ui/component/fileRenderFloating/view.jsx +++ b/ui/component/fileRenderFloating/view.jsx @@ -78,6 +78,12 @@ export default function FileRenderFloating(props: Props) { // @if TARGET='app' setDesktopPlayStartTime(Date.now()); // @endif + + return () => { + // @if TARGET='app' + setDesktopPlayStartTime(undefined); + // @endif + }; }, [uri]); if (!isPlayable || !uri || (isFloating && (isMobile || !floatingPlayerEnabled))) { diff --git a/ui/component/viewers/videoViewer/view.jsx b/ui/component/viewers/videoViewer/view.jsx index db1c7ea6f..41e4c32b6 100644 --- a/ui/component/viewers/videoViewer/view.jsx +++ b/ui/component/viewers/videoViewer/view.jsx @@ -88,6 +88,7 @@ function VideoViewer(props: Props) { function doTrackingFirstPlay(e: Event, data: any) { let timeToStartInMs = data.secondsToLoad * 1000; + if (desktopPlayStartTime !== undefined) { const differenceToAdd = Date.now() - desktopPlayStartTime; timeToStartInMs += differenceToAdd; @@ -166,7 +167,7 @@ function VideoViewer(props: Props) { } player.on('dispose', () => savePosition(uri, player.currentTime())); }, - [uri] + IS_WEB ? [uri] : [uri, desktopPlayStartTime] ); return (