mirror of
https://github.com/p-stream/p-stream.git
synced 2026-04-21 00:02:07 +00:00
fix "end time" to account for playback speed
This commit is contained in:
parent
654cb061a4
commit
7014d85fcd
1 changed files with 6 additions and 1 deletions
|
|
@ -8,6 +8,7 @@ import { durationExceedsHour, formatSeconds } from "@/utils/formatSeconds";
|
||||||
export function Time(props: { short?: boolean }) {
|
export function Time(props: { short?: boolean }) {
|
||||||
const timeFormat = usePlayerStore((s) => s.interface.timeFormat);
|
const timeFormat = usePlayerStore((s) => s.interface.timeFormat);
|
||||||
const setTimeFormat = usePlayerStore((s) => s.setTimeFormat);
|
const setTimeFormat = usePlayerStore((s) => s.setTimeFormat);
|
||||||
|
const playbackRate = usePlayerStore((s) => s.mediaPlaying.playbackRate);
|
||||||
|
|
||||||
const {
|
const {
|
||||||
duration: timeDuration,
|
duration: timeDuration,
|
||||||
|
|
@ -32,12 +33,16 @@ export function Time(props: { short?: boolean }) {
|
||||||
);
|
);
|
||||||
const secondsRemaining = Math.abs(currentTime - timeDuration);
|
const secondsRemaining = Math.abs(currentTime - timeDuration);
|
||||||
|
|
||||||
|
// Adjust seconds remaining based on playback speed
|
||||||
|
const secondsRemainingAdjusted =
|
||||||
|
playbackRate > 0 ? secondsRemaining / playbackRate : secondsRemaining;
|
||||||
|
|
||||||
const timeLeft = formatSeconds(
|
const timeLeft = formatSeconds(
|
||||||
secondsRemaining,
|
secondsRemaining,
|
||||||
durationExceedsHour(secondsRemaining),
|
durationExceedsHour(secondsRemaining),
|
||||||
);
|
);
|
||||||
const timeWatched = formatSeconds(currentTime, hasHours);
|
const timeWatched = formatSeconds(currentTime, hasHours);
|
||||||
const timeFinished = new Date(Date.now() + secondsRemaining * 1e3);
|
const timeFinished = new Date(Date.now() + secondsRemainingAdjusted * 1e3);
|
||||||
const duration = formatSeconds(timeDuration, hasHours);
|
const duration = formatSeconds(timeDuration, hasHours);
|
||||||
|
|
||||||
let localizationKey =
|
let localizationKey =
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue