aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAjay <[email protected]>2023-08-22 15:22:03 -0400
committerAjay <[email protected]>2023-08-22 15:22:03 -0400
commit9a18e70e34ea067ca15b6f776d39ae61bafab323 (patch)
tree731b289b5003bfc3ac78c8c8bdfcd9ae27b84eac
parent64ece9cb733864924b1457e4a181662134b00a51 (diff)
downloadSponsorBlock-9a18e70e34ea067ca15b6f776d39ae61bafab323.tar.gz
SponsorBlock-9a18e70e34ea067ca15b6f776d39ae61bafab323.zip
Fix rate change listener not set up properly
Fixes #1820
-rw-r--r--src/content.ts21
1 files changed, 10 insertions, 11 deletions
diff --git a/src/content.ts b/src/content.ts
index f71e5ddd..46eeda10 100644
--- a/src/content.ts
+++ b/src/content.ts
@@ -838,6 +838,16 @@ function setupVideoListeners() {
let startedWaiting = false;
let lastPausedAtZero = true;
+ const rateChangeListener = () => {
+ updateVirtualTime();
+ clearWaitingTime();
+
+ startSponsorSchedule();
+ };
+ getVideo().addEventListener('ratechange', rateChangeListener);
+ // Used by videospeed extension (https://github.com/igrigorik/videospeed/pull/740)
+ getVideo().addEventListener('videoSpeed_ratechange', rateChangeListener);
+
const playListener = () => {
// 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
@@ -868,7 +878,6 @@ function setupVideoListeners() {
startSponsorSchedule();
}
-
};
getVideo().addEventListener('play', playListener);
@@ -928,16 +937,6 @@ function setupVideoListeners() {
};
getVideo().addEventListener('seeking', seekingListener);
- const rateChangeListener = () => {
- updateVirtualTime();
- clearWaitingTime();
-
- startSponsorSchedule();
- };
- getVideo().addEventListener('ratechange', () => rateChangeListener);
- // Used by videospeed extension (https://github.com/igrigorik/videospeed/pull/740)
- getVideo().addEventListener('videoSpeed_ratechange', rateChangeListener);
-
const stoppedPlayback = () => {
// Reset lastCheckVideoTime
lastCheckVideoTime = -1;