Skip to content

Commit

Permalink
Always clear existing listener
Browse files Browse the repository at this point in the history
  • Loading branch information
NickM-27 committed Mar 7, 2024
1 parent 581f292 commit c7c91e1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
18 changes: 9 additions & 9 deletions web/src/components/player/DynamicVideoPlayer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -471,25 +471,25 @@ export class DynamicVideoController {
}

onPlayerTimeUpdate(listener: ((timestamp: number) => void) | undefined) {
if (this.playerProgressListener) {
this.playerRef.off("timeupdate", this.playerProgressListener);
}

if (listener) {
this.playerProgressListener = () =>
listener(this.getProgress(this.playerRef.currentTime() || 0));
this.playerRef.on("timeupdate", this.playerProgressListener);
} else {
if (this.playerProgressListener) {
this.playerRef.off("timeupdate", this.playerProgressListener);
}
}
}

onClipChangedEvent(listener: (dir: "forward") => void) {
onClipChangedEvent(listener: ((dir: "forward") => void) | undefined) {
if (this.playerEndedListener) {
this.playerRef.off("ended", this.playerEndedListener);
}

if (listener) {
this.playerEndedListener = () => listener("forward");
this.playerRef.on("ended", this.playerEndedListener);
} else {
if (this.playerEndedListener) {
this.playerRef.off("ended", this.playerEndedListener);
}
}
}

Expand Down
1 change: 1 addition & 0 deletions web/src/views/events/RecordingView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ export function DesktopRecordingView({
const lastController = videoPlayersRef.current[mainCamera];
const newController = videoPlayersRef.current[newCam];
lastController.onPlayerTimeUpdate(undefined);
lastController.onClipChangedEvent(undefined);
lastController.scrubToTimestamp(currentTime);
newController.onCanPlay(() => {
newController.seekToTimestamp(currentTime, true);
Expand Down

0 comments on commit c7c91e1

Please sign in to comment.