Skip to content

Commit

Permalink
Merge pull request #59 from Juice10/goto-play
Browse files Browse the repository at this point in the history
Allow goto to specify if it should play or pause
  • Loading branch information
Juice10 authored Jul 21, 2021
2 parents fc7d804 + aee3c16 commit 4e04bb6
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 @@ -110,8 +110,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 4e04bb6

Please sign in to comment.