Skip to content

Commit 7c82f56

Browse files
committed
fix: updated video's ratio
1 parent 1e8dd59 commit 7c82f56

File tree

2 files changed

+19
-8
lines changed

2 files changed

+19
-8
lines changed
2.01 MB
Binary file not shown.

apps/website/src/sections/Spotlight.astro

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,18 @@ import PlayButton from "../assets/videos/play-button.svg";
5353
filter: brightness(0.2);
5454
}
5555

56-
.playButton {
56+
/* 隐藏所有浏览器的原生播放按钮 */
57+
video::-webkit-media-controls-play-button,
58+
video::-webkit-media-controls-start-playback-button,
59+
video::-moz-media-controls-play-button {
60+
display: none !important;
61+
opacity: 0 !important;
62+
pointer-events: none !important;
63+
width: 0 !important;
64+
height: 0 !important;
65+
}
66+
67+
.play-button {
5768
background: none;
5869
position: absolute;
5970
border: none;
@@ -64,15 +75,15 @@ import PlayButton from "../assets/videos/play-button.svg";
6475
visibility: visible;
6576
}
6677

67-
.playButton-invisible {
78+
.play-button-invisible {
6879
visibility: hidden;
6980
}
7081

71-
.playButton :hover {
82+
.play-button :hover {
7283
transform: scale(1.1);
7384
}
7485

75-
.playButton img {
86+
.play-button img {
7687
width: clamp(3rem, 10vw, 6rem);
7788
}
7889

@@ -105,22 +116,22 @@ import PlayButton from "../assets/videos/play-button.svg";
105116
<script>
106117
document.addEventListener("DOMContentLoaded", () => {
107118
const video = document.querySelector("video") as HTMLVideoElement;
108-
const playButton = document.getElementsByClassName("playButton")[0] as HTMLButtonElement;
119+
const playButton = document.getElementsByClassName("play-button")[0] as HTMLButtonElement;
109120
let isPlaying = false;
110121

111122
video.classList.add("video-not-interactive");
112123

113124
playButton.addEventListener("click", () => {
114125
video.play();
115126
isPlaying = true;
116-
playButton.classList.add("playButton-invisible");
127+
playButton.classList.add("play-button-invisible");
117128
video.classList.remove("video-not-interactive");
118129
});
119130

120131
video.addEventListener("pause", () => {
121132
if (isPlaying) {
122133
isPlaying = false;
123-
playButton.classList.remove("playButton-invisible");
134+
playButton.classList.remove("play-button-invisible");
124135
video.classList.add("video-not-interactive");
125136
}
126137
});
@@ -136,7 +147,7 @@ import PlayButton from "../assets/videos/play-button.svg";
136147
<video controls poster={Poster.src} muted playsinline>
137148
<source src={videoUrl} type="video/mp4" />
138149
</video>
139-
<button class="playButton">
150+
<button class="play-button">
140151
<Image src={PlayButton} alt="Play button" />
141152
</button>
142153
</div>

0 commit comments

Comments
 (0)