From 9e6911eb6ca9fa488bc93f8a260a58e1c027f54a Mon Sep 17 00:00:00 2001 From: michael-grace Date: Sun, 18 Oct 2020 23:56:57 +0100 Subject: [PATCH] total channel duration --- src/lib/utils.ts | 10 ++++++++++ src/showplanner/Player.tsx | 12 +++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/lib/utils.ts b/src/lib/utils.ts index 23271c6..2c7f610 100644 --- a/src/lib/utils.ts +++ b/src/lib/utils.ts @@ -47,6 +47,16 @@ export function secToHHMM(sec: number = 0) { return d.toLocaleString("en-GB").split(" ")[1]; } +export function HHMMTosec(timeString: string = "00:00:00") { + var s: number = parseInt(timeString[7]); + s += 10 * parseInt(timeString[6]); + s += 60 * parseInt(timeString[4]); + s += 600 * parseInt(timeString[3]); + s += 3600 * parseInt(timeString[1]); + s += 36000 * parseInt(timeString[0]); + return s; +} + export function timestampToHHMM(sec: number = 0) { return format(fromUnixTime(sec), "HH:mm:ss"); } diff --git a/src/showplanner/Player.tsx b/src/showplanner/Player.tsx index d539d60..bc463e2 100644 --- a/src/showplanner/Player.tsx +++ b/src/showplanner/Player.tsx @@ -13,7 +13,7 @@ import { omit } from "lodash"; import { RootState } from "../rootReducer"; import * as MixerState from "../mixer/state"; import * as ShowPlanState from "../showplanner/state"; -import { secToHHMM, timestampToHHMM } from "../lib/utils"; +import { HHMMTosec, secToHHMM, timestampToHHMM } from "../lib/utils"; import ProModeButtons from "./ProModeButtons"; import { VUMeter } from "../optionsMenu/helpers/VUMeter"; import * as api from "../api"; @@ -221,6 +221,15 @@ export function Player({ id }: { id: number }) { throw new Error("Unknown Player VUMeter source: " + id); } }; + + var duration: number = 0; + const plan = useSelector((state: RootState) => state.showplan.plan); + plan?.forEach((pItem) => { + if (pItem.channel === id) { + duration += HHMMTosec(pItem.length); + } + }); + return (
  Repeat {playerState.repeat} +
Total Time: {secToHHMM(duration)}
{proMode && }