Automate play on PFL and disable on fader.

This commit is contained in:
Matthew Stratford 2021-01-05 23:41:14 +00:00
parent 67be4cde7d
commit e5358c7cff
No known key found for this signature in database
GPG key ID: 9E53C8B3F0B57395

View file

@ -663,7 +663,8 @@ export const { setTracklistItemID } = mixerState.actions;
const FADE_TIME_SECONDS = 1;
export const setVolume = (
player: number,
level: VolumePresetEnum
level: VolumePresetEnum,
fade: boolean = true
): AppThunk => (dispatch, getState) => {
let volume: number;
let uiLevel: number;
@ -701,6 +702,18 @@ export const setVolume = (
}
}
// If we're fading up the volume, disable the PFL.
if (level !== "off") {
dispatch(setChannelPFL(player, false));
}
// If not fading, just do it.
if (!fade) {
dispatch(mixerState.actions.setPlayerVolume({ player, volume: uiLevel }));
dispatch(mixerState.actions.setPlayerGain({ player, gain: volume }));
return;
}
const state = getState().mixer.players[player];
const currentLevel = state.volume;
@ -747,6 +760,12 @@ export const setChannelPFL = (
player: number,
enabled: boolean
): AppThunk => async (dispatch) => {
if (typeof audioEngine.players[player] !== "undefined") {
if (!audioEngine.players[player]?.isPlaying) {
dispatch(setVolume(player, "off", false));
dispatch(play(player));
}
}
dispatch(mixerState.actions.setPlayerPFL({ player, enabled }));
audioEngine.setPFL(player, enabled);
};