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;
@@ -54,28 +57,23 @@ import PlayButton from "../assets/videos/play-button.svg";
54
57
}
55
58
56
59
.play-button {
57
- background: none;
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
- .play-button-invisible {
69
+ .play-button.hidden {
68
70
visibility: hidden;
69
71
}
70
72
71
- .play-button :hover {
73
+ .play-button:hover {
72
74
transform: scale(1.1);
73
75
}
74
76
75
- .play-button 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,38 +97,26 @@ 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("play-button")[0] as HTMLButtonElement;
109
- let isUserPause = false;
110
-
111
- video.removeAttribute("controls");
112
- video.classList.add("video-not-interactive");
113
-
114
- playButton.addEventListener("click", () => {
115
- video.play();
116
- playButton.classList.add("play-button-invisible");
117
- video.classList.remove("video-not-interactive");
118
- video.setAttribute("controls", "true");
119
- isUserPause = true;
120
- });
121
-
122
- video.addEventListener("pause", () => {
123
- if (isUserPause == true) {
124
- playButton.classList.remove("play-button-invisible");
125
- video.classList.add("video-not-interactive");
126
- video.removeAttribute("controls");
127
- }
128
- });
129
-
130
- video.addEventListener("click", (e) => {
131
- const target = e.target as HTMLVideoElement;
132
- if (target === video && video.hasAttribute("controls")) {
133
- isUserPause = true;
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
+ if (video.getAttribute("controls")) {
107
+ video.removeAttribute("controls");
108
+ } else {
109
+ video.setAttribute("controls", "true");
110
+ }
111
+ } else {
112
+ wasSeeking = !wasSeeking;
134
113
}
135
- }) ;
114
+ };
136
115
137
- video.addEventListener("seeking", () => {
138
- isUserPause = false;
139
- });
116
+ playButton.addEventListener("click", () => video.play());
117
+ video.addEventListener("play", togglePlayButton);
118
+ video.addEventListener("pause", togglePlayButton);
119
+ video.addEventListener("click", togglePlayButton);
140
120
});
141
121
</script >
142
122
@@ -145,13 +125,11 @@ import PlayButton from "../assets/videos/play-button.svg";
145
125
<h1 >Gather language exposure data</h1 >
146
126
<p >Efficient documenting <strong >children's</strong > language exposure by carer, language and time.</p >
147
127
</div >
148
- <div class =" quassel- video" >
149
- <video controls poster ={ Poster .src } muted playsinline >
150
- <source src ={ videoUrl } type =" video/mp4" />
128
+ <div class =" video-wrapper " >
129
+ <video poster ={ Poster .src } muted playsinline >
130
+ <source src ={ Video } type =" video/mp4" />
151
131
</video >
152
- <button class =" play-button" >
153
- <Image src ={ PlayButton } alt =" Play button" />
154
- </button >
132
+ <Image class =" play-button" src ={ PlayButtonSymbol } alt =" Play button symbol" />
155
133
</div >
156
134
<div class =" used-by" >
157
135
<h2 >Used by</h2 >
0 commit comments