Merge pull request #293 from zisra/fix-time

Fix "Finish at xx:xxPM/AM"
This commit is contained in:
James Hawkins 2023-05-10 10:40:17 +01:00 committed by GitHub
commit 835e818ca0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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 = "";
}