mirror of
https://github.com/p-stream/p-stream.git
synced 2026-03-29 01:18:43 +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 }) {
|
||||
const timeFormat = usePlayerStore((s) => s.interface.timeFormat);
|
||||
const setTimeFormat = usePlayerStore((s) => s.setTimeFormat);
|
||||
const playbackRate = usePlayerStore((s) => s.mediaPlaying.playbackRate);
|
||||
|
||||
const {
|
||||
duration: timeDuration,
|
||||
|
|
@ -32,12 +33,16 @@ export function Time(props: { short?: boolean }) {
|
|||
);
|
||||
const secondsRemaining = Math.abs(currentTime - timeDuration);
|
||||
|
||||
// Adjust seconds remaining based on playback speed
|
||||
const secondsRemainingAdjusted =
|
||||
playbackRate > 0 ? secondsRemaining / playbackRate : secondsRemaining;
|
||||
|
||||
const timeLeft = formatSeconds(
|
||||
secondsRemaining,
|
||||
durationExceedsHour(secondsRemaining),
|
||||
);
|
||||
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);
|
||||
|
||||
let localizationKey =
|
||||
|
|
|
|||
Loading…
Reference in a new issue