From def58ff11f226f6d8f6cafc7b743e8ba2434fd72 Mon Sep 17 00:00:00 2001 From: Omar Roth Date: Thu, 31 Jan 2019 09:09:00 -0600 Subject: [PATCH] Add interval and timeout for errors in player --- src/invidious/views/components/player.ecr | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/invidious/views/components/player.ecr b/src/invidious/views/components/player.ecr index b165985f..9efe04fc 100644 --- a/src/invidious/views/components/player.ecr +++ b/src/invidious/views/components/player.ecr @@ -116,17 +116,19 @@ var player = videojs("player", options, function() { player.on('error', function(event) { if (player.error().code === 2 || player.error().code === 4) { - console.log("An error occured in the player, reloading..."); + setInterval(setTimeout(function (event) { + console.log("An error occured in the player, reloading..."); - var currentTime = player.currentTime(); - var playbackRate = player.playbackRate(); - player.load(); - if (currentTime > 0.5) { - currentTime -= 0.5; - } - player.currentTime(currentTime); - player.playbackRate(playbackRate); - player.play(); + var currentTime = player.currentTime(); + var playbackRate = player.playbackRate(); + player.load(); + if (currentTime > 0.5) { + currentTime -= 0.5; + } + player.currentTime(currentTime); + player.playbackRate(playbackRate); + player.play(); + }, 5000), 5000); } });