1
1
---
2
2
import { Image } from " astro:assets" ;
3
3
import UzhLogo from " ../assets/logos/uzh-logo.svg" ;
4
- import videoUrl from " ../assets/videos/quassel.mp4" ;
4
+ import Video from " ../assets/videos/quassel.mp4" ;
5
5
import Poster from " ../assets/videos/poster.png" ;
6
- import PlayButton from " ../assets/videos/play-button.svg" ;
6
+ import PlayButtonSymbol from " ../assets/videos/play-button-symbol .svg" ;
7
7
---
8
8
9
9
<style >
@@ -12,14 +12,17 @@ import PlayButton from "../assets/videos/play-button.svg";
12
12
flex-direction: column;
13
13
align-items: center;
14
14
background: radial-gradient(50% 50% at 50% 50%, var(--color-primary) 60%, transparent 100%);
15
+ font-size: var(--font-size-lg);
15
16
}
16
17
17
18
h1 {
18
19
font-size: var(--font-size-xxxl);
19
20
}
20
21
21
- p {
22
+ h2 {
22
23
font-size: var(--font-size-lg);
24
+ font-weight: var(--font-weight-medium);
25
+ align-self: center;
23
26
}
24
27
25
28
.intro {
@@ -29,7 +32,7 @@ import PlayButton from "../assets/videos/play-button.svg";
29
32
max-width: 37rem;
30
33
}
31
34
32
- .quassel- video {
35
+ .video-wrapper {
33
36
display: flex;
34
37
align-items: center;
35
38
justify-content: center;
@@ -53,29 +56,24 @@ import PlayButton from "../assets/videos/play-button.svg";
53
56
filter: brightness(0.2);
54
57
}
55
58
56
- .playButton {
57
- background: none;
59
+ .play-button {
58
60
position: absolute;
59
- border: none;
60
61
cursor: pointer;
61
62
top: 50%;
62
63
left: 50%;
63
- transform: translate(-50%, -50%);
64
- visibility: visible;
64
+ translate: -50% -50%;
65
+ transform-origin: center center;
66
+ width: clamp(3rem, 10vw, 6rem);
65
67
}
66
68
67
- .playButton-invisible {
69
+ .play-button.hidden {
68
70
visibility: hidden;
69
71
}
70
72
71
- .playButton :hover {
73
+ .play-button :hover {
72
74
transform: scale(1.1);
73
75
}
74
76
75
- .playButton img {
76
- width: clamp(3rem, 10vw, 6rem);
77
- }
78
-
79
77
.used-by {
80
78
margin-top: var(--spacing-xl);
81
79
display: flex;
@@ -87,12 +85,6 @@ import PlayButton from "../assets/videos/play-button.svg";
87
85
}
88
86
}
89
87
90
- .used-by h2 {
91
- font-size: var(--font-size-lg);
92
- font-weight: var(--font-weight-medium);
93
- align-self: center;
94
- }
95
-
96
88
.used-by img {
97
89
max-height: 4rem;
98
90
}
@@ -105,25 +97,22 @@ import PlayButton from "../assets/videos/play-button.svg";
105
97
<script >
106
98
document.addEventListener("DOMContentLoaded", () => {
107
99
const video = document.querySelector("video") as HTMLVideoElement;
108
- const playButton = document.getElementsByClassName("playButton")[0] as HTMLButtonElement;
109
- let isPlaying = false;
110
-
111
- video.classList.add("video-not-interactive");
112
-
113
- playButton.addEventListener("click", () => {
114
- video.play();
115
- isPlaying = true;
116
- playButton.classList.add("playButton-invisible");
117
- video.classList.remove("video-not-interactive");
118
- });
119
-
120
- video.addEventListener("pause", () => {
121
- if (isPlaying) {
122
- isPlaying = false;
123
- playButton.classList.remove("playButton-invisible");
124
- video.classList.add("video-not-interactive");
100
+ const playButton = document.querySelector(".play-button") as HTMLButtonElement;
101
+ let wasSeeking = false;
102
+
103
+ const togglePlayButton = () => {
104
+ if (!video.seeking && !wasSeeking) {
105
+ playButton.classList.toggle("hidden");
106
+ video.toggleAttribute("controls");
107
+ } else {
108
+ wasSeeking = !wasSeeking;
125
109
}
126
- });
110
+ };
111
+
112
+ playButton.addEventListener("click", () => video.play());
113
+ video.addEventListener("play", togglePlayButton);
114
+ video.addEventListener("pause", togglePlayButton);
115
+ video.addEventListener("click", togglePlayButton);
127
116
});
128
117
</script >
129
118
@@ -132,13 +121,11 @@ import PlayButton from "../assets/videos/play-button.svg";
132
121
<h1 >Gather language exposure data</h1 >
133
122
<p >Efficient documenting <strong >children's</strong > language exposure by carer, language and time.</p >
134
123
</div >
135
- <div class =" quassel- video" >
136
- <video controls poster ={ Poster .src } muted playsinline >
137
- <source src ={ videoUrl } type =" video/mp4" />
124
+ <div class =" video-wrapper " >
125
+ <video poster ={ Poster .src } muted playsinline >
126
+ <source src ={ Video } type =" video/mp4" />
138
127
</video >
139
- <button class =" playButton" >
140
- <Image src ={ PlayButton } alt =" Play button" />
141
- </button >
128
+ <Image class =" play-button" src ={ PlayButtonSymbol } alt =" Play button symbol" />
142
129
</div >
143
130
<div class =" used-by" >
144
131
<h2 >Used by</h2 >
0 commit comments