Skip to content

Commit

Permalink
fix: Pause for touch on video (BL-13957)
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnThomson committed Oct 14, 2024
1 parent 8ebaf6a commit bad62f4
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/video.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export class Video {
}
this.getVideoElements().forEach(videoElement => {
videoElement.removeAttribute("controls");
videoElement.addEventListener("click", this.handleVideoClick);
const playButton = this.wrapVideoIcon(
videoElement,
// Alternatively, we could import the Material UI icon, make this file a TSX, and use
Expand All @@ -68,7 +69,6 @@ export class Video {
"videoPlayIcon"
);
playButton.addEventListener("click", this.handlePlayClick);
videoElement.addEventListener("click", this.handlePlayClick);
const pauseButton = this.wrapVideoIcon(
videoElement,
getPauseIcon("#ffffff"),
Expand Down Expand Up @@ -156,6 +156,15 @@ export class Video {
}
};

private handleVideoClick = (ev: MouseEvent) => {
const video = ev.currentTarget as HTMLVideoElement;
if (video.paused) {
this.handlePlayClick(ev);
} else {
this.handlePauseClick(ev);
}
};

private handleReplayClick = (ev: MouseEvent) => {
ev.stopPropagation(); // we don't want the navigation bar to toggle on and off
ev.preventDefault();
Expand Down

0 comments on commit bad62f4

Please sign in to comment.