Skip to content

Commit fede677

Browse files
committed
Merge fixes / tidies from BAPS3 to Webstudio
1 parent 1e53ede commit fede677

File tree

13 files changed

+128
-109
lines changed

13 files changed

+128
-109
lines changed

.env

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,4 @@ REACT_APP_MYRADIO_NONAPI_BASE=https://ury.org.uk/myradio-staging
44
REACT_APP_MYRADIO_BASE=https://ury.org.uk/api-staging/v2
55
REACT_APP_BROADCAST_API_BASE=https://ury.org.uk/webstudio/api/v1
66
REACT_APP_WS_URL=wss://ury.org.uk/webstudio/api/stream
7-
REACT_APP_BAPSICLE_INTERFACE=true
87
REACT_APP_SENTRY_PUBLIC_DSN=https://[email protected]/5734903

public/index.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@
3838
3939
To begin the development, run `npm start` or `yarn start`.
4040
To create a production bundle, use `npm run build` or `yarn build`.
41+
42+
TODO: Ideally we shouldn't rely on CDN's during runtime.
4143
-->
4244
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css"
4345
integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">

src/App.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ $number-of-channels: 3;
1717
.logo {
1818
height: 50px;
1919
}
20-
.logo-big {
20+
.logo-big-bapsicle {
2121
height: 30vh;
2222
}
2323
}

src/api.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -205,14 +205,13 @@ export function searchForTracks(
205205
artist,
206206
title,
207207
});
208-
} else {
209-
return myradioApiRequest("/track/search", "GET", {
210-
artist,
211-
title,
212-
limit: 100,
213-
digitised: true,
214-
});
215208
}
209+
return myradioApiRequest("/track/search", "GET", {
210+
artist,
211+
title,
212+
limit: 100,
213+
digitised: true,
214+
});
216215
}
217216

218217
export function getTimeslots(): Promise<Array<Timeslot>> {

src/bapsiclesession/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export function ConnectionDialogue({ error }: { error: String | null }) {
1212
return (
1313
<div className="loading-dialogue">
1414
<div className="logo-container">
15-
<img className="logo-big mb-2" src={appLogo} alt="BAPS Logo" />
15+
<img className="logo-big-bapsicle mb-2" src={appLogo} alt="BAPS Logo" />
1616
</div>
1717

1818
<span className="inner">

src/index.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import "./index.css";
44
import App from "./App";
55
import * as serviceWorker from "./serviceWorkerLoader";
66

7-
87
import * as Sentry from "@sentry/react";
98
import { Integrations } from "@sentry/tracing";
109

src/mixer/audio.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,8 @@ class Player extends ((PlayerEmitter as unknown) as { new (): EventEmitter }) {
289289
instance.emit("pause");
290290
});
291291
wavesurfer.on("seek", () => {
292+
// This is used to prevent infinite loops when bapsicle tells wavesurfer to change position,
293+
// since otherwise it would send an change update back to the bapsicle server again (as if the user seeked intentionally).
292294
if (instance.ignore_next_seek) {
293295
instance.ignore_next_seek = false;
294296
} else {

src/mixer/state.ts

Lines changed: 49 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,7 @@ export const setLoadedItemOutro = (
379379
};
380380

381381
export const seek = (player: number, time_s: number): AppThunk => async () => {
382+
// Used only by Bapsicle to update the wavesurfer seek position.
382383
const playerInstance = await audioEngine.getPlayer(player);
383384

384385
if (playerInstance) {
@@ -426,6 +427,7 @@ export const load = (
426427
const currentItem = getState().mixer.players[player].loadedItem;
427428
if (currentItem !== null && itemId(currentItem) === itemId(item)) {
428429
if (process.env.REACT_APP_BAPSICLE_INTERFACE) {
430+
// In BAPS, another client could have updated the audio markers etc, so we have to still check and update them.
429431
// The cue/intro/outro point(s) have changed.
430432
if (
431433
"cue" in currentItem &&
@@ -567,6 +569,7 @@ export const load = (
567569
dispatch(mixerState.actions.itemLoadComplete({ player }));
568570

569571
if (!process.env.REACT_APP_BAPSICLE_INTERFACE) {
572+
// BAPS server will give these values already on load based on it's own calculation, not wavesurfer's.
570573
dispatch(
571574
mixerState.actions.setTimeLength({
572575
player,
@@ -585,6 +588,7 @@ export const load = (
585588
const state = getState().mixer.players[player];
586589

587590
if (!process.env.REACT_APP_BAPSICLE_INTERFACE) {
591+
// Client doesn't do any audio playing in BAPS.
588592
if (state.playOnLoad) {
589593
playerInstance.play();
590594
}
@@ -603,16 +607,18 @@ export const load = (
603607
});
604608

605609
if (process.env.REACT_APP_BAPSICLE_INTERFACE) {
610+
// If user manually seeks on the waveform, just direct that to the webserver.
606611
playerInstance.on("timeChangeSeek", (time) => {
607-
if (
608-
Math.abs(time - getState().mixer.players[player].timeCurrent) > 0.5
609-
) {
610-
sendBAPSicleChannel({
611-
channel: player,
612-
command: "SEEK",
613-
time: time,
614-
});
615-
}
612+
// Limit
613+
//if (
614+
// Math.abs(time - getState().mixer.players[player].timeCurrent) > 0.5
615+
//) {
616+
sendBAPSicleChannel({
617+
channel: player,
618+
command: "SEEK",
619+
time: time,
620+
});
621+
//}
616622
});
617623
} else {
618624
playerInstance.on("play", () => {
@@ -1261,10 +1267,40 @@ export const mixerKeyboardShortcutsMiddleware: Middleware<
12611267
store.dispatch(handleKeyboardShortcut(store, 2, "STOP"));
12621268
});
12631269

1264-
Keys("x", () => {
1265-
const state = store.getState().mixer.mic;
1266-
store.dispatch(setMicVolume(state.volume === 1 ? "off" : "full"));
1267-
});
1270+
if (!process.env.REACT_APP_BAPSICLE_INTERFACE) {
1271+
Keys("a", () => {
1272+
store.dispatch(setVolume(0, "off"));
1273+
});
1274+
Keys("s", () => {
1275+
store.dispatch(setVolume(0, "bed"));
1276+
});
1277+
Keys("d", () => {
1278+
store.dispatch(setVolume(0, "full"));
1279+
});
1280+
Keys("f", () => {
1281+
store.dispatch(setVolume(1, "off"));
1282+
});
1283+
Keys("g", () => {
1284+
store.dispatch(setVolume(1, "bed"));
1285+
});
1286+
Keys("h", () => {
1287+
store.dispatch(setVolume(1, "full"));
1288+
});
1289+
Keys("j", () => {
1290+
store.dispatch(setVolume(2, "off"));
1291+
});
1292+
Keys("k", () => {
1293+
store.dispatch(setVolume(2, "bed"));
1294+
});
1295+
Keys("l", () => {
1296+
store.dispatch(setVolume(2, "full"));
1297+
});
1298+
1299+
Keys("x", () => {
1300+
const state = store.getState().mixer.mic;
1301+
store.dispatch(setMicVolume(state.volume === 1 ? "off" : "full"));
1302+
});
1303+
}
12681304

12691305
return (next) => (action) => next(action);
12701306
};

src/showplanner/Item.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,7 @@ export const Item = memo(function Item({
5050

5151
function triggerClick() {
5252
if (column > -1) {
53-
console.log("Clicking to load:", x);
54-
53+
// TODO: move this into mixer state if we can.
5554
if (process.env.REACT_APP_BAPSICLE_INTERFACE) {
5655
sendBAPSicleChannel({
5756
channel: column,

src/showplanner/Player.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ const setTrackIntro = (
8181
secs: number,
8282
player: number
8383
): AppThunk => async (dispatch, getState) => {
84+
// TODO Move into MixerState
8485
if (process.env.REACT_APP_BAPSICLE_INTERFACE) {
8586
let marker = {
8687
name: "Intro",

src/showplanner/index.tsx

Lines changed: 6 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,6 @@ import Modal from "react-modal";
5050
import { Sidebar } from "./sidebar";
5151
import { PLAYER_ID_PREVIEW } from "../mixer/audio";
5252

53-
import { sendBAPSicleChannel } from "../bapsicle";
54-
5553
function Channel({ id, data }: { id: number; data: PlanItem[] }) {
5654
return (
5755
<div className="channel" id={"channel-" + id}>
@@ -112,6 +110,7 @@ const Showplanner: React.FC<{ timeslotId: number }> = function({ timeslotId }) {
112110

113111
useEffect(() => {
114112
if (!process.env.REACT_APP_BAPSICLE_INTERFACE) {
113+
// In BAPS, we'll load in the show plan from a async message from server.
115114
dispatch(getShowplan(timeslotId));
116115
}
117116
}, [dispatch, timeslotId]);
@@ -148,15 +147,7 @@ const Showplanner: React.FC<{ timeslotId: number }> = function({ timeslotId }) {
148147
cue: 0,
149148
...data,
150149
};
151-
if (process.env.REACT_APP_BAPSICLE_INTERFACE) {
152-
sendBAPSicleChannel({
153-
channel: newItem.channel,
154-
command: "ADD",
155-
newItem: newItem,
156-
});
157-
} else {
158-
dispatch(addItem(timeslotId, newItem));
159-
}
150+
dispatch(addItem(timeslotId, newItem));
160151
increment(null);
161152
} else if (result.draggableId[0] === "A") {
162153
// this is an aux resource
@@ -171,15 +162,7 @@ const Showplanner: React.FC<{ timeslotId: number }> = function({ timeslotId }) {
171162
cue: 0,
172163
...data,
173164
} as any;
174-
if (process.env.REACT_APP_BAPSICLE_INTERFACE) {
175-
sendBAPSicleChannel({
176-
channel: newItem.channel,
177-
command: "ADD",
178-
newItem: newItem,
179-
});
180-
} else {
181-
dispatch(addItem(timeslotId, newItem));
182-
}
165+
dispatch(addItem(timeslotId, newItem));
183166
increment(null);
184167
} else {
185168
// this is a normal move (ghosts aren't draggable)
@@ -204,28 +187,6 @@ const Showplanner: React.FC<{ timeslotId: number }> = function({ timeslotId }) {
204187
}
205188
}
206189

207-
async function onCtxRemoveClick(
208-
e: any,
209-
data: { id: string; column: number; index: number }
210-
) {
211-
if (process.env.REACT_APP_BAPSICLE_INTERFACE) {
212-
sendBAPSicleChannel({
213-
channel: data.column,
214-
command: "REMOVE",
215-
weight: data.index,
216-
});
217-
} else {
218-
dispatch(removeItem(timeslotId, data.id));
219-
}
220-
}
221-
222-
async function onCtxUnPlayedClick(
223-
e: any,
224-
data: { id: string; column: number; index: number }
225-
) {
226-
dispatch(setItemPlayed(data.id.toString(), false, data.column));
227-
}
228-
229190
// Add support for reloading the show plan from the iFrames.
230191
// There is a similar listener in showplanner/ImporterModal.tsx to handle closing the iframe.
231192
useEffect(() => {
@@ -275,9 +236,9 @@ const Showplanner: React.FC<{ timeslotId: number }> = function({ timeslotId }) {
275236
<FaTrash /> Remove
276237
</CtxMenuItem>
277238
<CtxMenuItem
278-
onClick={(args) =>
279-
dispatch(setItemPlayed((args.props as any).id, false))
280-
}
239+
onClick={(args) => {
240+
dispatch(setItemPlayed((args.props as any).id, false));
241+
}}
281242
>
282243
<FaCircleNotch /> Mark Unplayed
283244
</CtxMenuItem>

0 commit comments

Comments
 (0)