mirror of
https://gitea.invidious.io/iv-org/invidious.git
synced 2024-08-15 00:53:41 +00:00
Add handling to remove invalid sources
This commit is contained in:
parent
26b7200360
commit
ff09a7255a
1 changed files with 30 additions and 9 deletions
|
@ -115,10 +115,11 @@ var player = videojs("player", options, function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
player.on('error', function(event) {
|
player.on('error', function(event) {
|
||||||
|
if (player.error().code === 2) {
|
||||||
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();
|
||||||
var playbackRate = player.playbackRate()
|
var playbackRate = player.playbackRate();
|
||||||
player.load();
|
player.load();
|
||||||
if (currentTime > 0.5) {
|
if (currentTime > 0.5) {
|
||||||
currentTime -= 0.5;
|
currentTime -= 0.5;
|
||||||
|
@ -126,6 +127,26 @@ player.on('error', function(event) {
|
||||||
player.currentTime(currentTime);
|
player.currentTime(currentTime);
|
||||||
player.playbackRate(playbackRate);
|
player.playbackRate(playbackRate);
|
||||||
player.play()
|
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.share(shareOptions);
|
player.share(shareOptions);
|
||||||
|
|
Loading…
Reference in a new issue