diff --git a/src/mixer/state.ts b/src/mixer/state.ts index 9c4cf08..331ca4f 100644 --- a/src/mixer/state.ts +++ b/src/mixer/state.ts @@ -498,7 +498,17 @@ export const load = ( const itsChannel = getState() .showplan.plan!.filter((x) => x.channel === item.channel) .sort((x, y) => x.weight - y.weight); - const itsIndex = itsChannel.indexOf(item); + // Sadly, we can't just do .indexOf() item directly, + // since the player's idea of an item may be changed over it's lifecycle (setting intro/cue/outro etc.) + // Therefore we'll find the updated item from the plan and match that. + const itsChannelItem = itsChannel.filter( + (x) => itemId(x) === itemId(item) + ); + if (itsChannelItem.length !== 1) { + // Somehow we've got 0 or multiple identical timeslotitems (or ghosts), bail out! + return; + } + const itsIndex = itsChannel.indexOf(itsChannelItem[0]); if (itsIndex > -1 && itsIndex !== itsChannel.length - 1) { dispatch(load(player, itsChannel[itsIndex + 1])); } @@ -585,14 +595,12 @@ export const stop = (player: number): AppThunk => (dispatch, getState) => { let cueTime = 0; - console.log(Math.round(playerInstance.currentTime)); if ( state.loadedItem && "cue" in state.loadedItem && Math.round(playerInstance.currentTime) !== Math.round(state.loadedItem.cue) ) { cueTime = state.loadedItem.cue; - console.log(cueTime); } playerInstance.stop(); diff --git a/src/showplanner/Player.tsx b/src/showplanner/Player.tsx index bc463e2..8d09f0d 100644 --- a/src/showplanner/Player.tsx +++ b/src/showplanner/Player.tsx @@ -67,6 +67,8 @@ const setTrackIntro = ( player: number ): AppThunk => async (dispatch, getState) => { try { + // Api only deals with whole seconds. + secs = Math.round(secs); dispatch(MixerState.setLoadedItemIntro(player, secs)); if (getState().settings.saveShowPlanChanges) { await api.setTrackIntro(track.trackid, secs); @@ -84,6 +86,8 @@ const setTrackOutro = ( player: number ): AppThunk => async (dispatch, getState) => { try { + // Api only deals with whole seconds. + secs = Math.round(secs); dispatch(MixerState.setLoadedItemOutro(player, secs)); if (getState().settings.saveShowPlanChanges) { await api.setTrackOutro(track.trackid, secs); @@ -101,6 +105,8 @@ const setTrackCue = ( player: number ): AppThunk => async (dispatch, getState) => { try { + // Api only deals with whole seconds. + secs = Math.round(secs); dispatch(MixerState.setLoadedItemCue(player, secs)); if (getState().settings.saveShowPlanChanges) { await api.setTimeslotItemCue(item.timeslotitemid, secs);