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;
|
wavesurfers[player] = wavesurfer;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const play = (player: number): AppThunk => dispatch => {
|
export const play = (player: number): AppThunk => (dispatch, getState) => {
|
||||||
if (typeof wavesurfers[player] === "undefined") {
|
if (typeof wavesurfers[player] === "undefined") {
|
||||||
console.log("nothing loaded");
|
console.log("nothing loaded");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (getState().mixer.players[player].loading) {
|
||||||
|
console.log("not ready");
|
||||||
|
return;
|
||||||
|
}
|
||||||
wavesurfers[player].play();
|
wavesurfers[player].play();
|
||||||
};
|
};
|
||||||
|
|
||||||
export const pause = (player: number): AppThunk => dispatch => {
|
export const pause = (player: number): AppThunk => (dispatch, getState) => {
|
||||||
if (typeof wavesurfers[player] === "undefined") {
|
if (typeof wavesurfers[player] === "undefined") {
|
||||||
console.log("nothing loaded");
|
console.log("nothing loaded");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (getState().mixer.players[player].loading) {
|
||||||
|
console.log("not ready");
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (wavesurfers[player].isPlaying()) {
|
if (wavesurfers[player].isPlaying()) {
|
||||||
wavesurfers[player].pause();
|
wavesurfers[player].pause();
|
||||||
} else {
|
} 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") {
|
if (typeof wavesurfers[player] === "undefined") {
|
||||||
console.log("nothing loaded");
|
console.log("nothing loaded");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (getState().mixer.players[player].loading) {
|
||||||
|
console.log("not ready");
|
||||||
|
return;
|
||||||
|
}
|
||||||
wavesurfers[player].stop();
|
wavesurfers[player].stop();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue