Merge pull request #168 from UniversityRadioYork/michaelg-channeltimers
Total Channel Duration
This commit is contained in:
commit
801d5ae072
2 changed files with 21 additions and 1 deletions
|
@ -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");
|
||||
}
|
||||
|
|
|
@ -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 (
|
||||
<div
|
||||
className={
|
||||
|
@ -269,6 +278,7 @@ export function Player({ id }: { id: number }) {
|
|||
<FaRedo />
|
||||
Repeat {playerState.repeat}
|
||||
</button>
|
||||
<div>Total Time: {secToHHMM(duration)}</div>
|
||||
</div>
|
||||
{proMode && <ProModeButtons channel={id} />}
|
||||
<div className="card-body p-0">
|
||||
|
|
Loading…
Reference in a new issue