try twice when the first play fails from a timeout
This commit is contained in:
parent
b61907ad22
commit
c9f5813b81
1 changed files with 11 additions and 3 deletions
|
@ -120,12 +120,20 @@ function VideoViewer(props: Props) {
|
||||||
if (shouldPlay) {
|
if (shouldPlay) {
|
||||||
const playPromise = player.play();
|
const playPromise = player.play();
|
||||||
const timeoutPromise = new Promise((resolve, reject) => {
|
const timeoutPromise = new Promise((resolve, reject) => {
|
||||||
setTimeout(() => reject(PLAY_TIMEOUT_ERROR), 2500);
|
setTimeout(() => reject(PLAY_TIMEOUT_ERROR), 2000);
|
||||||
});
|
});
|
||||||
|
|
||||||
Promise.race([playPromise, timeoutPromise]).catch(error => {
|
Promise.race([playPromise, timeoutPromise]).catch(error => {
|
||||||
setIsLoading(false);
|
if (PLAY_TIMEOUT_ERROR) {
|
||||||
setIsPlaying(false);
|
const retryPlayPromise = player.play();
|
||||||
|
Promise.race([retryPlayPromise, timeoutPromise]).catch(error => {
|
||||||
|
setIsLoading(false);
|
||||||
|
setIsPlaying(false);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
setIsLoading(false);
|
||||||
|
setIsPlaying(false);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue