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:
6
.changeset/controller-finish-flag.md
Normal file
6
.changeset/controller-finish-flag.md
Normal 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.
|
||||||
@@ -208,6 +208,7 @@
|
|||||||
export const goto = (timeOffset: number, play?: boolean) => {
|
export const goto = (timeOffset: number, play?: boolean) => {
|
||||||
currentTime = timeOffset;
|
currentTime = timeOffset;
|
||||||
pauseAt = false;
|
pauseAt = false;
|
||||||
|
finished = false;
|
||||||
const resumePlaying =
|
const resumePlaying =
|
||||||
typeof play === 'boolean' ? play : playerState === 'playing';
|
typeof play === 'boolean' ? play : playerState === 'playing';
|
||||||
if (resumePlaying) {
|
if (resumePlaying) {
|
||||||
@@ -250,7 +251,6 @@
|
|||||||
percent = 1;
|
percent = 1;
|
||||||
}
|
}
|
||||||
const timeOffset = meta.totalTime * percent;
|
const timeOffset = meta.totalTime * percent;
|
||||||
finished = false;
|
|
||||||
goto(timeOffset);
|
goto(timeOffset);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user