Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 26 additions & 8 deletions chrome/player/ui/menus/LoopMenu.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -165,19 +165,29 @@ export class LoopMenu extends EventEmitter {
this.loopStart = this.timecodeToSeconds(this.loopTimeSettings.start);
this.loopEnd = this.timecodeToSeconds(this.loopTimeSettings.end);

if (this.loopEnd <= 0) {
this.loopEnd = this.client.duration;
}
// When both start and end are 0 (defaults), loop the full video
// using native video.loop without custom seeking
this.isFullVideoLoop = (this.loopStart <= 0 && this.loopEnd <= 0);

if (this.loopStart >= this.loopEnd || this.loopStart >= this.client.duration) {
this.loopEnabled = false;
if (this.isFullVideoLoop) {
this.loopStart = 0;
this.loopEnd = this.client.duration || Infinity;
} else {
this.loopStart = Utils.clamp(this.loopStart, 0, this.client.duration);
this.loopEnd = Utils.clamp(this.loopEnd, 0, this.client.duration);
if (this.loopEnd <= 0) {
this.loopEnd = this.client.duration;
}

if (this.loopStart >= this.loopEnd || this.loopStart >= this.client.duration) {
this.loopEnabled = false;
} else {
this.loopStart = Utils.clamp(this.loopStart, 0, this.client.duration);
this.loopEnd = Utils.clamp(this.loopEnd, 0, this.client.duration);
}
}
} else {
this.loopStart = null;
this.loopEnd = null;
this.isFullVideoLoop = false;
}

this.toggleLoopButton.textContent = Localize.getMessage('loop_menu_toggle_' + (this.loopEnabled ? 'enabled' : 'disabled'));
Expand All @@ -189,7 +199,9 @@ export class LoopMenu extends EventEmitter {

if (this.loopEnabled) {
player.getVideo().loop = true;
this.startLoopLoop();
if (!this.isFullVideoLoop) {
this.startLoopLoop();
}
} else {
player.getVideo().loop = false;
}
Expand Down Expand Up @@ -353,6 +365,12 @@ export class LoopMenu extends EventEmitter {
return;
}

// Full video loop is handled by native video.loop, no custom seeking needed
if (this.isFullVideoLoop) {
this.loopLoopRunning = false;
return;
}

requestAnimationFrame(this.loopHandler);

const currentTime = this.client.currentTime;
Expand Down