make sure player callback has access to latest desktop start time

This commit is contained in:
Sean Yesmunt 2020-05-05 16:45:59 -04:00
parent ab70f1c758
commit ff429117cd
2 changed files with 8 additions and 1 deletions

View file

@ -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))) {

View file

@ -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 (