From 942725d04c37023d1fa37e4c7dc87fd086bfeec3 Mon Sep 17 00:00:00 2001
From: Isra <byzkk@protonmail.com>
Date: Tue, 9 May 2023 14:07:09 -0500
Subject: [PATCH] Fix time finished

---
 src/video/components/actions/TimeAction.tsx | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/src/video/components/actions/TimeAction.tsx b/src/video/components/actions/TimeAction.tsx
index 46a27b44..0c5d5042 100644
--- a/src/video/components/actions/TimeAction.tsx
+++ b/src/video/components/actions/TimeAction.tsx
@@ -55,13 +55,14 @@ export function TimeAction(props: Props) {
     hasHours
   );
   const duration = formatSeconds(videoTime.duration, hasHours);
-  const timeLeft = formatSeconds(
+  const remaining = formatSeconds(
     (videoTime.duration - videoTime.time) / mediaPlaying.playbackSpeed,
     hasHours
   );
   const timeFinished = new Date(
     new Date().getTime() +
-      (videoTime.duration * 1000) / mediaPlaying.playbackSpeed
+      ((videoTime.duration - videoTime.time) * 1000) /
+        mediaPlaying.playbackSpeed
   ).toLocaleTimeString("en-US", {
     hour: "numeric",
     minute: "numeric",
@@ -77,10 +78,10 @@ export function TimeAction(props: Props) {
     formattedTime = `${currentTime} ${props.noDuration ? "" : `/ ${duration}`}`;
   } else if (timeFormat === VideoPlayerTimeFormat.REMAINING && !isMobile) {
     formattedTime = `${t("videoPlayer.timeLeft", {
-      timeLeft,
+      timeLeft: remaining,
     })}${videoTime.time === videoTime.duration ? "" : formattedTimeFinished} `;
   } else if (timeFormat === VideoPlayerTimeFormat.REMAINING && isMobile) {
-    formattedTime = `-${timeLeft}`;
+    formattedTime = `-${remaining}`;
   } else {
     formattedTime = "";
   }