allow to see time left for playing episode

This commit is contained in:
2026-03-12 14:10:39 +03:00
parent 8e226e9ea1
commit 618c034b05

View File

@@ -12,6 +12,7 @@ export const Player = () => {
const [currentTime, setCurrentTime] = useState(0); const [currentTime, setCurrentTime] = useState(0);
const [duration, setDuration] = useState(0); const [duration, setDuration] = useState(0);
const [showTimeLeft, setShowTimeLeft] = useState(false);
useEffect(() => { useEffect(() => {
if (!episode) return; if (!episode) return;
@@ -62,6 +63,7 @@ export const Player = () => {
}, []); }, []);
const progress = currentTime / duration; const progress = currentTime / duration;
const timeLeft = duration - currentTime;
if (status === "stopped") { if (status === "stopped") {
return null; return null;
@@ -117,11 +119,13 @@ export const Player = () => {
className="bg-red-500 h-full" className="bg-red-500 h-full"
></div> ></div>
</div> </div>
<p <button
className={`${Math.floor(duration / 3600) > 0 ? "min-w-[70px]" : "min-w-[50px]"} text-right`} className="min-w-[70px] text-right cursor-pointer"
onClick={() => setShowTimeLeft((prev) => !prev)}
> >
{formatTime(currentTime)} {showTimeLeft ? "-" : ""}
</p> {formatTime(showTimeLeft ? timeLeft : currentTime)}
</button>
</div> </div>
<h3 className="text-base font-semibold mt-2">{episode?.title}</h3> <h3 className="text-base font-semibold mt-2">{episode?.title}</h3>