Only play automatically on enabling PFL.

This commit is contained in:
Matthew Stratford 2021-01-05 23:47:32 +00:00
parent e5358c7cff
commit 658ef5f1eb
No known key found for this signature in database
GPG key ID: 9E53C8B3F0B57395

View file

@ -760,11 +760,13 @@ export const setChannelPFL = (
player: number, player: number,
enabled: boolean enabled: boolean
): AppThunk => async (dispatch) => { ): AppThunk => async (dispatch) => {
if (typeof audioEngine.players[player] !== "undefined") { if (
if (!audioEngine.players[player]?.isPlaying) { enabled &&
dispatch(setVolume(player, "off", false)); typeof audioEngine.players[player] !== "undefined" &&
dispatch(play(player)); !audioEngine.players[player]?.isPlaying
} ) {
dispatch(setVolume(player, "off", false));
dispatch(play(player));
} }
dispatch(mixerState.actions.setPlayerPFL({ player, enabled })); dispatch(mixerState.actions.setPlayerPFL({ player, enabled }));
audioEngine.setPFL(player, enabled); audioEngine.setPFL(player, enabled);