fix: Set finished=false in goto instead of handleProgressClick (#1198)

* Reset the finished flag in goto

If the player finishes a replaying a video the `finished` boolean is set to true. This allows the video to be restarted at the beginning if the controller is toggled again. If a user clicks on the progress bar the `finished` boolean is reset so if the `toggle` API is called it starts at the right place. If a user programatically calls `goto` which is the underlying API that handling the progress click calls the next invocation of `toggle` will start the video at the beginning instead of the proper location.

* Create controller-finish-flag.md

* Update controller-finish-flag.md
This commit is contained in:
Charlie Gracie
2026-04-01 12:00:00 +08:00
committed by GitHub
parent 6360042d33
commit 781ca8de91
2 changed files with 7 additions and 1 deletions

View File

@@ -0,0 +1,6 @@
---
'rrweb-player': patch
'rrweb': patch
---
Reset the finished flag in Controller `goto` instead of `handleProgressClick` so that it is properly handled if `goto` is called directly.

View File

@@ -208,6 +208,7 @@
export const goto = (timeOffset: number, play?: boolean) => {
currentTime = timeOffset;
pauseAt = false;
finished = false;
const resumePlaying =
typeof play === 'boolean' ? play : playerState === 'playing';
if (resumePlaying) {
@@ -250,7 +251,6 @@
percent = 1;
}
const timeOffset = meta.totalTime * percent;
finished = false;
goto(timeOffset);
};