Skip to content

Commit

Permalink
Be wait for seek to show video player
Browse files Browse the repository at this point in the history
  • Loading branch information
NickM-27 committed Mar 15, 2024
1 parent 4b30c55 commit 872dcb2
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions web/src/components/player/dynamic/DynamicVideoController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,27 @@ export class DynamicVideoController {
this.playerController.currentTime = seekSeconds;

if (play) {
// use timeout to avoid race condition with other data loading
setTimeout(() => this.playerController.play()), 1;
this.waitAndPlay();
} else {
this.playerController.pause();
}
}
}

waitAndPlay() {
return new Promise((resolve) => {
const onSeekedHandler = () => {
this.playerController.removeEventListener("seeked", onSeekedHandler);
this.playerController.play();
resolve(undefined);
};

this.playerController.addEventListener("seeked", onSeekedHandler, {
once: true,
});
});
}

seekToTimelineItem(timeline: Timeline) {
this.playerController.pause();
this.seekToTimestamp(timeline.timestamp + this.annotationOffset);
Expand Down

0 comments on commit 872dcb2

Please sign in to comment.