Fix auto advance after timing markers change

This commit is contained in:
Matthew Stratford 2020-10-27 20:40:34 +00:00
parent 529f86bcc6
commit 716c3d516e
No known key found for this signature in database
GPG key ID: 9E53C8B3F0B57395
2 changed files with 17 additions and 3 deletions

View file

@ -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();

View file

@ -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);