@@ -53,16 +53,6 @@ import PlayButton from "../assets/videos/play-button.svg";
53
53
filter: brightness(0.2);
54
54
}
55
55
56
- video::-webkit-media-controls-play-button,
57
- video::-webkit-media-controls-start-playback-button,
58
- video::-moz-media-controls-play-button {
59
- display: none !important;
60
- opacity: 0 !important;
61
- pointer-events: none !important;
62
- width: 0 !important;
63
- height: 0 !important;
64
- }
65
-
66
56
.play-button {
67
57
background: none;
68
58
position: absolute;
@@ -116,24 +106,37 @@ import PlayButton from "../assets/videos/play-button.svg";
116
106
document.addEventListener("DOMContentLoaded", () => {
117
107
const video = document.querySelector("video") as HTMLVideoElement;
118
108
const playButton = document.getElementsByClassName("play-button")[0] as HTMLButtonElement;
119
- let isPlaying = false;
109
+ let isUserPause = false;
120
110
111
+ video.removeAttribute("controls");
121
112
video.classList.add("video-not-interactive");
122
113
123
114
playButton.addEventListener("click", () => {
124
115
video.play();
125
- isPlaying = true;
126
116
playButton.classList.add("play-button-invisible");
127
117
video.classList.remove("video-not-interactive");
118
+ video.setAttribute("controls", "true");
119
+ isUserPause = true;
128
120
});
129
121
130
122
video.addEventListener("pause", () => {
131
- if (isPlaying) {
132
- isPlaying = false;
123
+ if (isUserPause == true) {
133
124
playButton.classList.remove("play-button-invisible");
134
125
video.classList.add("video-not-interactive");
126
+ video.removeAttribute("controls");
135
127
}
136
128
});
129
+
130
+ video.addEventListener("click", (e) => {
131
+ const target = e.target as HTMLVideoElement;
132
+ if (target === video && video.hasAttribute("controls")) {
133
+ isUserPause = true;
134
+ }
135
+ });
136
+
137
+ video.addEventListener("seeking", () => {
138
+ isUserPause = false;
139
+ });
137
140
});
138
141
</script >
139
142
0 commit comments