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,13 +120,21 @@ function VideoViewer(props: Props) {
|
|||
if (shouldPlay) {
|
||||
const playPromise = player.play();
|
||||
const timeoutPromise = new Promise((resolve, reject) => {
|
||||
setTimeout(() => reject(PLAY_TIMEOUT_ERROR), 2500);
|
||||
setTimeout(() => reject(PLAY_TIMEOUT_ERROR), 2000);
|
||||
});
|
||||
|
||||
Promise.race([playPromise, timeoutPromise]).catch(error => {
|
||||
if (PLAY_TIMEOUT_ERROR) {
|
||||
const retryPlayPromise = player.play();
|
||||
Promise.race([retryPlayPromise, timeoutPromise]).catch(error => {
|
||||
setIsLoading(false);
|
||||
setIsPlaying(false);
|
||||
});
|
||||
} else {
|
||||
setIsLoading(false);
|
||||
setIsPlaying(false);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
setIsLoading(shouldPlay); // if we are here outside of an embed, we're playing
|
||||
|
|
Loading…
Reference in a new issue