Skip to content

Commit

Permalink
fix: Set finished=false in goto instead of handleProgressClick (rrweb…
Browse files Browse the repository at this point in the history
…-io#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
  • Loading branch information
charliegracie authored Apr 8, 2023
1 parent aa79db7 commit b5e30cf
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions .changeset/controller-finish-flag.md
Original file line number Diff line number Diff line change
@@ -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.
2 changes: 1 addition & 1 deletion packages/rrweb-player/src/Controller.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -250,7 +251,6 @@
percent = 1;
}
const timeOffset = meta.totalTime * percent;
finished = false;
goto(timeOffset);
};
Expand Down

0 comments on commit b5e30cf

Please sign in to comment.