allow goto to specify if it should play or pause

This commit is contained in:
Justin Halsall
2026-04-01 12:00:00 +08:00
parent 2744b59e29
commit 45bfc12bcf
3 changed files with 10 additions and 9 deletions

View File

@@ -141,13 +141,14 @@
replayer.pause();
};
export const goto = (timeOffset: number) => {
export const goto = (timeOffset: number, play?: boolean) => {
currentTime = timeOffset;
const isPlaying = playerState === 'playing';
replayer.pause();
replayer.play(timeOffset);
if (!isPlaying) {
replayer.pause();
const resumePlaying =
typeof play === 'boolean' ? play : playerState === 'playing';
if (resumePlaying) {
replayer.play(timeOffset);
} else {
replayer.pause(timeOffset);
}
};

View File

@@ -109,8 +109,8 @@
export const pause = () => {
controller.pause();
};
export const goto = (timeOffset: number) => {
controller.goto(timeOffset);
export const goto = (timeOffset: number, play?: boolean) => {
controller.goto(timeOffset, play);
};
onMount(() => {

2
typings/index.d.ts vendored
View File

@@ -32,5 +32,5 @@ export default class rrwebPlayer extends SvelteComponent {
triggerResize: () => void;
play: () => void;
pause: () => void;
goto: (timeOffset: number) => void;
goto: (timeOffset: number, play?: boolean) => void;
}