Skip to content

Commit

Permalink
allow goto to specify if it should play or pause
Browse files Browse the repository at this point in the history
  • Loading branch information
Juice10 committed Feb 19, 2021
1 parent 2982a55 commit aee3c16
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
13 changes: 7 additions & 6 deletions src/Controller.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
};
Expand Down
4 changes: 2 additions & 2 deletions src/Player.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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(() => {
Expand Down
2 changes: 1 addition & 1 deletion typings/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

0 comments on commit aee3c16

Please sign in to comment.