Update Player
This commit is contained in:
parent
5eced5e4e6
commit
9c6c7eec47
1 changed files with 119 additions and 64 deletions
|
@ -12,8 +12,10 @@ import {
|
||||||
import { omit } from "lodash";
|
import { omit } from "lodash";
|
||||||
import { RootState } from "../rootReducer";
|
import { RootState } from "../rootReducer";
|
||||||
import * as MixerState from "../mixer/state";
|
import * as MixerState from "../mixer/state";
|
||||||
//import * as ShowPlanState from "../showplanner/state";
|
import * as ShowPlanState from "../showplanner/state";
|
||||||
import { HHMMTosec, 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";
|
import * as api from "../api";
|
||||||
import { AppThunk } from "../store";
|
import { AppThunk } from "../store";
|
||||||
import { sendBAPSicleChannel } from "../bapsicle";
|
import { sendBAPSicleChannel } from "../bapsicle";
|
||||||
|
@ -67,6 +69,7 @@ const setTrackIntro = (
|
||||||
secs: number,
|
secs: number,
|
||||||
player: number
|
player: number
|
||||||
): AppThunk => async (dispatch, getState) => {
|
): AppThunk => async (dispatch, getState) => {
|
||||||
|
if (process.env.REACT_APP_BAPSICLE_INTERFACE) {
|
||||||
let marker = {
|
let marker = {
|
||||||
name: "Intro",
|
name: "Intro",
|
||||||
time: secs,
|
time: secs,
|
||||||
|
@ -79,16 +82,20 @@ const setTrackIntro = (
|
||||||
timeslotitemid: item.timeslotitemid,
|
timeslotitemid: item.timeslotitemid,
|
||||||
marker: marker,
|
marker: marker,
|
||||||
});
|
});
|
||||||
/*
|
return;
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
// Api only deals with whole seconds.
|
// Api only deals with whole seconds.
|
||||||
secs = Math.round(secs);
|
secs = Math.round(secs);
|
||||||
dispatch(MixerState.setLoadedItemIntro(player, secs));
|
dispatch(MixerState.setLoadedItemIntro(player, secs));
|
||||||
dispatch(ShowPlanState.setItemTimings({ item: track, intro: secs }));
|
if (getState().settings.saveShowPlanChanges) {
|
||||||
|
await api.setTrackIntro(item.trackid, secs);
|
||||||
|
}
|
||||||
|
dispatch(ShowPlanState.setItemTimings({ item: item, intro: secs }));
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
dispatch(ShowPlanState.planSaveError("Failed saving track intro."));
|
dispatch(ShowPlanState.planSaveError("Failed saving track intro."));
|
||||||
console.error("Failed to set track intro: " + e);
|
console.error("Failed to set track intro: " + e);
|
||||||
}*/
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const setTrackOutro = (
|
const setTrackOutro = (
|
||||||
|
@ -96,6 +103,7 @@ const setTrackOutro = (
|
||||||
secs: number,
|
secs: number,
|
||||||
player: number
|
player: number
|
||||||
): AppThunk => async (dispatch, getState) => {
|
): AppThunk => async (dispatch, getState) => {
|
||||||
|
if (process.env.REACT_APP_BAPSICLE_INTERFACE) {
|
||||||
let marker = {
|
let marker = {
|
||||||
name: "Outro",
|
name: "Outro",
|
||||||
time: secs,
|
time: secs,
|
||||||
|
@ -108,15 +116,20 @@ const setTrackOutro = (
|
||||||
timeslotitemid: item.timeslotitemid,
|
timeslotitemid: item.timeslotitemid,
|
||||||
marker: marker,
|
marker: marker,
|
||||||
});
|
});
|
||||||
/*try {
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
// Api only deals with whole seconds.
|
// Api only deals with whole seconds.
|
||||||
secs = Math.round(secs);
|
secs = Math.round(secs);
|
||||||
dispatch(MixerState.setLoadedItemOutro(player, secs));
|
dispatch(MixerState.setLoadedItemOutro(player, secs));
|
||||||
dispatch(ShowPlanState.setItemTimings({ item: track, outro: secs }));
|
if (getState().settings.saveShowPlanChanges) {
|
||||||
|
await api.setTrackOutro(item.trackid, secs);
|
||||||
|
}
|
||||||
|
dispatch(ShowPlanState.setItemTimings({ item: item, outro: secs }));
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
dispatch(ShowPlanState.planSaveError("Failed saving track outro."));
|
dispatch(ShowPlanState.planSaveError("Failed saving track outro."));
|
||||||
console.error("Failed to set track outro: " + e);
|
console.error("Failed to set track outro: " + e);
|
||||||
}*/
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const setTrackCue = (
|
const setTrackCue = (
|
||||||
|
@ -124,6 +137,7 @@ const setTrackCue = (
|
||||||
secs: number,
|
secs: number,
|
||||||
player: number
|
player: number
|
||||||
): AppThunk => async (dispatch, getState) => {
|
): AppThunk => async (dispatch, getState) => {
|
||||||
|
if (process.env.REACT_APP_BAPSICLE_INTERFACE) {
|
||||||
let marker = {
|
let marker = {
|
||||||
name: "Cue",
|
name: "Cue",
|
||||||
time: secs,
|
time: secs,
|
||||||
|
@ -136,15 +150,19 @@ const setTrackCue = (
|
||||||
timeslotitemid: item.timeslotitemid,
|
timeslotitemid: item.timeslotitemid,
|
||||||
marker: marker,
|
marker: marker,
|
||||||
});
|
});
|
||||||
//try {
|
}
|
||||||
|
try {
|
||||||
// Api only deals with whole seconds.
|
// Api only deals with whole seconds.
|
||||||
//secs = Math.round(secs);
|
secs = Math.round(secs);
|
||||||
//dispatch(MixerState.setLoadedItemCue(player, secs));
|
dispatch(MixerState.setLoadedItemCue(player, secs));
|
||||||
//dispatch(ShowPlanState.setItemTimings({ item, cue: secs }));
|
if (getState().settings.saveShowPlanChanges) {
|
||||||
//} catch (e) {
|
await api.setTimeslotItemCue(item.timeslotitemid, secs);
|
||||||
//dispatch(ShowPlanState.planSaveError("Failed saving track cue."));
|
}
|
||||||
//console.error("Failed to set track cue: " + e);
|
dispatch(ShowPlanState.setItemTimings({ item, cue: secs }));
|
||||||
//}
|
} catch (e) {
|
||||||
|
dispatch(ShowPlanState.planSaveError("Failed saving track cue."));
|
||||||
|
console.error("Failed to set track cue: " + e);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
function TimingButtons({ id }: { id: number }) {
|
function TimingButtons({ id }: { id: number }) {
|
||||||
|
@ -245,18 +263,21 @@ export function Player({ id }: { id: number }) {
|
||||||
);
|
);
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
|
|
||||||
// const VUsource = (id: number) => {
|
const settings = useSelector((state: RootState) => state.settings);
|
||||||
// switch (id) {
|
const customOutput = settings.channelOutputIds[id] !== "internal";
|
||||||
// case 0:
|
|
||||||
// return "player-0";
|
const VUsource = (id: number) => {
|
||||||
// case 1:
|
switch (id) {
|
||||||
// return "player-1";
|
case 0:
|
||||||
// case 2:
|
return "player-0";
|
||||||
// return "player-2";
|
case 1:
|
||||||
// default:
|
return "player-1";
|
||||||
// throw new Error("Unknown Player VUMeter source: " + id);
|
case 2:
|
||||||
// }
|
return "player-2";
|
||||||
// };
|
default:
|
||||||
|
throw new Error("Unknown Player VUMeter source: " + id);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
let channelDuration = 0;
|
let channelDuration = 0;
|
||||||
let channelUnplayed = 0;
|
let channelUnplayed = 0;
|
||||||
|
@ -323,6 +344,9 @@ export function Player({ id }: { id: number }) {
|
||||||
Repeat {playerState.repeat}
|
Repeat {playerState.repeat}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
{!process.env.REACT_APP_BAPSICLE_INTERFACE &&
|
||||||
|
settings.proMode &&
|
||||||
|
!customOutput && <ProModeButtons channel={id} />}
|
||||||
<div className="card-body p-0">
|
<div className="card-body p-0">
|
||||||
<span className="card-title">
|
<span className="card-title">
|
||||||
<strong>
|
<strong>
|
||||||
|
@ -450,6 +474,37 @@ export function Player({ id }: { id: number }) {
|
||||||
}}
|
}}
|
||||||
></div>
|
></div>
|
||||||
</div>
|
</div>
|
||||||
|
{!process.env.REACT_APP_BAPSICLE_INTERFACE && (
|
||||||
|
<>
|
||||||
|
<button onClick={() => dispatch(MixerState.setVolume(id, "off"))}>
|
||||||
|
Off
|
||||||
|
</button>
|
||||||
|
<button onClick={() => dispatch(MixerState.setVolume(id, "bed"))}>
|
||||||
|
Bed
|
||||||
|
</button>
|
||||||
|
<button onClick={() => dispatch(MixerState.setVolume(id, "full"))}>
|
||||||
|
Full
|
||||||
|
</button>
|
||||||
|
|
||||||
|
{settings.proMode && settings.channelVUs && (
|
||||||
|
<div className="channel-vu">
|
||||||
|
{customOutput ? (
|
||||||
|
<span className="text-muted">
|
||||||
|
Custom audio output disables VU meters.
|
||||||
|
</span>
|
||||||
|
) : (
|
||||||
|
<VUMeter
|
||||||
|
width={300}
|
||||||
|
height={40}
|
||||||
|
source={VUsource(id)}
|
||||||
|
range={[-40, 0]}
|
||||||
|
stereo={settings.channelVUsStereo}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue