Skip to content

Commit 6f0eaa6

Browse files
committed
Show audio markers on load, send cue set to server.
1 parent e0ff8bd commit 6f0eaa6

File tree

5 files changed

+44
-11
lines changed

5 files changed

+44
-11
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,5 @@ venv/
3232

3333
serverconfig.ini
3434

35-
.idea/
35+
.idea/
36+
.vscode/settings.json

src/api.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,7 @@ export function loadPlaylistLibrary(libraryId: string): Promise<Track[]> {
258258
//return myradioApiRequest("/playlist/" + libraryId + "/tracks", "GET", {});
259259
}
260260

261+
/*
261262
export function setTimeslotItemCue(
262263
timeslotItemId: string,
263264
secs: number
@@ -278,6 +279,7 @@ export function setTrackOutro(trackId: number, secs: number): Promise<null> {
278279
duration: secs,
279280
});
280281
}
282+
*/
281283

282284
export type UpdateOp =
283285
| {

src/bapsicle.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,9 @@ export const bapsicleMiddleware: Middleware<{}, RootState, Dispatch<any>> = (
145145

146146
export function sendBAPSicleChannel(message: any): void {
147147
if (BAPSicleWS) {
148-
BAPSicleWS.send(JSON.stringify(message));
148+
message = JSON.stringify(message);
149+
console.log("Sending message to BAPSicle:", message);
150+
BAPSicleWS.send(message);
149151
}
150152
}
151153

src/mixer/state.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,21 @@ export const load = (
376376
dispatch(mixerState.actions.itemLoadComplete({ player }));
377377
});
378378

379+
// Add the audio marker regions
380+
const state = getState().mixer.players[player];
381+
379382
// TODO: This needs to happen without wavesurfer
383+
384+
if (state.loadedItem && "intro" in state.loadedItem) {
385+
playerInstance.setIntro(state.loadedItem.intro);
386+
}
387+
if (state.loadedItem && "cue" in state.loadedItem) {
388+
playerInstance.setCue(state.loadedItem.cue);
389+
playerInstance.setCurrentTime(state.loadedItem.cue);
390+
}
391+
if (state.loadedItem && "outro" in state.loadedItem) {
392+
playerInstance.setOutro(state.loadedItem.outro);
393+
}
380394
playerInstance.on("timeChangeSeek", (time) => {
381395
if (Math.abs(time - getState().mixer.players[player].timeCurrent) > 0.5) {
382396
sendBAPSicleChannel({ channel: player, command: "SEEK", time: time });

src/showplanner/Player.tsx

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import * as ShowPlanState from "../showplanner/state";
1616
import { HHMMTosec, secToHHMM, timestampToHHMM } from "../lib/utils";
1717
import * as api from "../api";
1818
import { AppThunk } from "../store";
19+
import { sendBAPSicleChannel } from "../bapsicle";
1920

2021
export const USE_REAL_GAIN_VALUE = false;
2122

@@ -96,15 +97,28 @@ const setTrackCue = (
9697
secs: number,
9798
player: number
9899
): AppThunk => async (dispatch, getState) => {
99-
try {
100-
// Api only deals with whole seconds.
101-
secs = Math.round(secs);
102-
dispatch(MixerState.setLoadedItemCue(player, secs));
103-
dispatch(ShowPlanState.setItemTimings({ item, cue: secs }));
104-
} catch (e) {
105-
dispatch(ShowPlanState.planSaveError("Failed saving track cue."));
106-
console.error("Failed to set track cue: " + e);
107-
}
100+
console.log("Setting Cue to " + secs);
101+
let marker = {
102+
name: "Cue",
103+
time: secs,
104+
position: "mid",
105+
section: null,
106+
};
107+
sendBAPSicleChannel({
108+
channel: player,
109+
command: "SETMARKER",
110+
timeslotitemid: item.timeslotitemid,
111+
marker: marker,
112+
});
113+
//try {
114+
// Api only deals with whole seconds.
115+
//secs = Math.round(secs);
116+
//dispatch(MixerState.setLoadedItemCue(player, secs));
117+
//dispatch(ShowPlanState.setItemTimings({ item, cue: secs }));
118+
//} catch (e) {
119+
//dispatch(ShowPlanState.planSaveError("Failed saving track cue."));
120+
//console.error("Failed to set track cue: " + e);
121+
//}
108122
};
109123

110124
function TimingButtons({ id }: { id: number }) {

0 commit comments

Comments
 (0)