From 612c7d2c4790205778f644b2c8ce72a69ec0d279 Mon Sep 17 00:00:00 2001 From: Matthew Stratford Date: Sun, 31 Jan 2021 17:24:25 +0000 Subject: [PATCH 1/2] If we reload the channel, tracklist the end. --- src/mixer/state.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/mixer/state.ts b/src/mixer/state.ts index 0e7b604..fb96026 100644 --- a/src/mixer/state.ts +++ b/src/mixer/state.ts @@ -382,6 +382,13 @@ export const load = ( } } + // If somehow we've managed to re-load the channel without ending tracklisting. + // This could happen if they paused it at the end, or if Wavesurfer forgot somehow. + const tracklistItemID = getState().mixer.players[player].tracklistItemID; + if (tracklistItemID !== -1) { + dispatch(BroadcastState.tracklistEnd(tracklistItemID)); + } + // Can't really load a ghost, it'll break setting cues etc. Do nothing. if (item.type === "ghost") { return; From 14c47a243b336b1bc46d1d011b5e07c853370024 Mon Sep 17 00:00:00 2001 From: Matthew Stratford Date: Sun, 31 Jan 2021 17:48:18 +0000 Subject: [PATCH 2/2] Trigger tracklist ends on closing the window. --- src/showplanner/Player.tsx | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/showplanner/Player.tsx b/src/showplanner/Player.tsx index 543bd0f..03bee9e 100644 --- a/src/showplanner/Player.tsx +++ b/src/showplanner/Player.tsx @@ -16,6 +16,7 @@ import * as ShowPlanState from "../showplanner/state"; import { HHMMTosec, secToHHMM, timestampToHHMM } from "../lib/utils"; import ProModeButtons from "./ProModeButtons"; import { VUMeter } from "../optionsMenu/helpers/VUMeter"; +import * as BroadcastState from "../broadcast/state"; import * as api from "../api"; import { AppThunk } from "../store"; import { @@ -24,6 +25,7 @@ import { PLAYER_COUNT, PLAYER_ID_PREVIEW, } from "../mixer/audio"; +import { useBeforeunload } from "react-beforeunload"; export const USE_REAL_GAIN_VALUE = false; @@ -269,6 +271,15 @@ export function Player({ omit(b, "timeCurrent", "timeRemaining") ) ); + + useBeforeunload((event) => { + console.log("Checking player " + id + " for un-ended tracklists."); + const tracklistItemID = playerState.tracklistItemID; + if (tracklistItemID !== -1) { + dispatch(BroadcastState.tracklistEnd(tracklistItemID)); + } + }); + const settings = useSelector((state: RootState) => state.settings); const customOutput = settings.channelOutputIds[id] !== INTERNAL_OUTPUT_ID; const dispatch = useDispatch();