mirror of
https://github.com/iv-org/invidious.git
synced 2024-12-18 20:24:36 -05:00
Reload player instead of removing invalid source
This commit is contained in:
parent
ff09a7255a
commit
1e214aae7c
@ -115,7 +115,7 @@ var player = videojs("player", options, function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
player.on('error', function(event) {
|
player.on('error', function(event) {
|
||||||
if (player.error().code === 2) {
|
if (player.error().code === 2 || player.error().code === 4) {
|
||||||
console.log("An error occured in the player, reloading...");
|
console.log("An error occured in the player, reloading...");
|
||||||
|
|
||||||
var currentTime = player.currentTime();
|
var currentTime = player.currentTime();
|
||||||
@ -126,25 +126,6 @@ player.on('error', function(event) {
|
|||||||
}
|
}
|
||||||
player.currentTime(currentTime);
|
player.currentTime(currentTime);
|
||||||
player.playbackRate(playbackRate);
|
player.playbackRate(playbackRate);
|
||||||
player.play()
|
|
||||||
} else if (player.error().code === 4) {
|
|
||||||
console.log("Detected invalid source, removing...");
|
|
||||||
var currentTime = player.currentTime();
|
|
||||||
var sources = player.options().sources;
|
|
||||||
|
|
||||||
for (var i = 0; i < sources.length; i++) {
|
|
||||||
if (sources[i].src === player.currentSource().src) {
|
|
||||||
sources.splice(i, 1);
|
|
||||||
break
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
player.load();
|
|
||||||
if (currentTime > 0.5) {
|
|
||||||
currentTime -= 0.5;
|
|
||||||
}
|
|
||||||
player.currentTime(currentTime);
|
|
||||||
player.src(sources);
|
|
||||||
player.play();
|
player.play();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user