mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-08 20:47:11 +03:00
Potential fix for video replaying after browser stutters on Firefox.
Hopefully resolves #525
This commit is contained in:
@@ -53,6 +53,9 @@ let durationListenerSetUp = false;
|
|||||||
// Is the video currently being switched
|
// Is the video currently being switched
|
||||||
let switchingVideos = null;
|
let switchingVideos = null;
|
||||||
|
|
||||||
|
// Made true every videoID change
|
||||||
|
let firstEvent = false;
|
||||||
|
|
||||||
// Used by the play and playing listeners to make sure two aren't
|
// Used by the play and playing listeners to make sure two aren't
|
||||||
// called at the same time
|
// called at the same time
|
||||||
let lastCheckTime = 0;
|
let lastCheckTime = 0;
|
||||||
@@ -244,6 +247,8 @@ function resetValues() {
|
|||||||
switchingVideos = true;
|
switchingVideos = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
firstEvent = true;
|
||||||
|
|
||||||
// Reset advert playing flag
|
// Reset advert playing flag
|
||||||
isAdPlaying = false;
|
isAdPlaying = false;
|
||||||
}
|
}
|
||||||
@@ -410,7 +415,7 @@ function createPreviewBar(): void {
|
|||||||
* Triggered every time the video duration changes.
|
* Triggered every time the video duration changes.
|
||||||
* This happens when the resolution changes or at random time to clear memory.
|
* This happens when the resolution changes or at random time to clear memory.
|
||||||
*/
|
*/
|
||||||
function durationChangeListener() {
|
function durationChangeListener(): void {
|
||||||
updateAdFlag();
|
updateAdFlag();
|
||||||
updatePreviewBar();
|
updatePreviewBar();
|
||||||
}
|
}
|
||||||
@@ -545,6 +550,12 @@ async function sponsorsLookup(id: string) {
|
|||||||
video.addEventListener('play', () => {
|
video.addEventListener('play', () => {
|
||||||
switchingVideos = false;
|
switchingVideos = false;
|
||||||
|
|
||||||
|
// If it is not the first event, then the only way to get to 0 is if there is a seek event
|
||||||
|
// This check makes sure that changing the video resolution doesn't cause the extension to think it
|
||||||
|
// gone back to the begining
|
||||||
|
if (!firstEvent && video.currentTime === 0) return;
|
||||||
|
firstEvent = false;
|
||||||
|
|
||||||
// Check if an ad is playing
|
// Check if an ad is playing
|
||||||
updateAdFlag();
|
updateAdFlag();
|
||||||
|
|
||||||
@@ -804,7 +815,7 @@ function updatePreviewBarPositionMobile(parent: Element) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function updatePreviewBar() {
|
function updatePreviewBar(): void {
|
||||||
if(isAdPlaying) {
|
if(isAdPlaying) {
|
||||||
previewBar.set([], [], 0);
|
previewBar.set([], [], 0);
|
||||||
return;
|
return;
|
||||||
@@ -1595,7 +1606,7 @@ function sendRequestToCustomServer(type, fullAddress, callback) {
|
|||||||
/**
|
/**
|
||||||
* Update the isAdPlaying flag and hide preview bar/controls if ad is playing
|
* Update the isAdPlaying flag and hide preview bar/controls if ad is playing
|
||||||
*/
|
*/
|
||||||
function updateAdFlag() {
|
function updateAdFlag(): void {
|
||||||
const wasAdPlaying = isAdPlaying;
|
const wasAdPlaying = isAdPlaying;
|
||||||
isAdPlaying = document.getElementsByClassName('ad-showing').length > 0;
|
isAdPlaying = document.getElementsByClassName('ad-showing').length > 0;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user