CPU usage fix since nudging didn't stop properly

This commit is contained in:
Josh Patra
2025-07-22 12:17:54 -04:00
parent 3fed3b425e
commit 893c811802

View File

@@ -249,6 +249,7 @@ function defineVideoController() {
} }
} else if (event.type === "pause" || event.type === "ended") { } else if (event.type === "pause" || event.type === "ended") {
this.stopSubtitleNudge(); this.stopSubtitleNudge();
tc.isNudging = false;
} }
// For seek events, don't mess with speed // For seek events, don't mess with speed
@@ -369,17 +370,27 @@ function defineVideoController() {
this.stopSubtitleNudge(); this.stopSubtitleNudge();
return; return;
} }
// Additional check to not start if paused
if (this.video.paused) {
return;
}
log(`Nudge: Starting interval: ${tc.settings.subtitleNudgeInterval}ms.`, 5); log(`Nudge: Starting interval: ${tc.settings.subtitleNudgeInterval}ms.`, 5);
this.nudgeIntervalId = setInterval(() => { this.nudgeIntervalId = setInterval(() => {
if ( if (
!this.video || !this.video ||
this.video.paused || this.video.paused ||
this.video.ended ||
this.video.playbackRate === 1.0 || this.video.playbackRate === 1.0 ||
tc.isNudging tc.isNudging
) { ) {
this.stopSubtitleNudge(); this.stopSubtitleNudge();
return; return;
} }
// Double-check pause state before nudging
if (this.video.paused) {
this.stopSubtitleNudge();
return;
}
const currentRate = this.video.playbackRate; const currentRate = this.video.playbackRate;
const nudgeAmount = tc.settings.subtitleNudgeAmount; const nudgeAmount = tc.settings.subtitleNudgeAmount;
tc.isNudging = true; tc.isNudging = true;