fix player time

This commit is contained in:
2026-03-12 12:42:29 +03:00
parent da9f4bb0ec
commit 3d92096bb8

View File

@@ -115,14 +115,24 @@ export const Player = () => {
className="bg-red-500 h-full" className="bg-red-500 h-full"
></div> ></div>
</div> </div>
<p className="min-w-[50px] text-right">{formatTime(currentTime)}</p> <p
className={`${Math.floor(duration / 3600) > 0 ? "min-w-[70px]" : "min-w-[50px]"} text-right`}
>
{formatTime(currentTime)}
</p>
</div> </div>
</div> </div>
); );
}; };
const formatTime = (seconds: number): string => { const formatTime = (time: number): string => {
const m = Math.floor(seconds / 60); let hours = Math.floor(time / 3600);
const s = Math.floor(seconds % 60); let minutes = Math.floor((time % 3600) / 60);
return `${m}:${String(s).padStart(2, "0")}`; let seconds = Math.floor(time % 60);
const h = String(hours).padStart(2, "0");
const m = String(minutes).padStart(2, "0");
const s = String(seconds).padStart(2, "0");
return [h, m, s].join(":");
}; };