Lock out playback controls while loading (fixes #20)
This commit is contained in:
parent
5dad5e2384
commit
d6bc4fd301
1 changed files with 15 additions and 3 deletions
|
@ -370,19 +370,27 @@ export const load = (
|
|||
wavesurfers[player] = wavesurfer;
|
||||
};
|
||||
|
||||
export const play = (player: number): AppThunk => dispatch => {
|
||||
export const play = (player: number): AppThunk => (dispatch, getState) => {
|
||||
if (typeof wavesurfers[player] === "undefined") {
|
||||
console.log("nothing loaded");
|
||||
return;
|
||||
}
|
||||
if (getState().mixer.players[player].loading) {
|
||||
console.log("not ready");
|
||||
return;
|
||||
}
|
||||
wavesurfers[player].play();
|
||||
};
|
||||
|
||||
export const pause = (player: number): AppThunk => dispatch => {
|
||||
export const pause = (player: number): AppThunk => (dispatch, getState) => {
|
||||
if (typeof wavesurfers[player] === "undefined") {
|
||||
console.log("nothing loaded");
|
||||
return;
|
||||
}
|
||||
if (getState().mixer.players[player].loading) {
|
||||
console.log("not ready");
|
||||
return;
|
||||
}
|
||||
if (wavesurfers[player].isPlaying()) {
|
||||
wavesurfers[player].pause();
|
||||
} else {
|
||||
|
@ -390,11 +398,15 @@ export const pause = (player: number): AppThunk => dispatch => {
|
|||
}
|
||||
};
|
||||
|
||||
export const stop = (player: number): AppThunk => dispatch => {
|
||||
export const stop = (player: number): AppThunk => (dispatch, getState) => {
|
||||
if (typeof wavesurfers[player] === "undefined") {
|
||||
console.log("nothing loaded");
|
||||
return;
|
||||
}
|
||||
if (getState().mixer.players[player].loading) {
|
||||
console.log("not ready");
|
||||
return;
|
||||
}
|
||||
wavesurfers[player].stop();
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue