-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
311 lines (270 loc) · 10.6 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Get low</title>
<meta name="description" content="Get low" />
<meta
name="viewport"
content="width=device-width, height=device-height, initial-scale=1"
/>
<link rel="stylesheet" type="text/css" href="./reset.css" />
<link rel="stylesheet" type="text/css" href="./button.css" />
<link rel="icon" type="image/png" href="favicon.png" />
<link rel="apple-touch-icon" href="favicon.png" />
<style>
body {
background-color: black;
}
#start-container {
position: absolute;
top: calc(50% - 50px);
left: calc(50% - 50px);
z-index: 2;
}
#button-container {
position: relative;
height: 100px;
width: 100px;
cursor: pointer;
}
#vid {
width: 100%;
height: auto;
z-index: 1;
}
.button1 {
display: flex;
justify-content: center;
width: 100px;
height: 100px;
-webkit-appearance: none;
box-shadow: 0 0 5px 1px lightgray;
border-radius: 100%;
background-repeat: no-repeat;
background-size: 100%;
background-clip: padding-box;
background-image: linear-gradient(90deg, #000000, #2d3436);
position: relative;
color: #fff;
}
.button1:before {
content: "";
width: 100%;
height: 100%;
position: absolute;
top: 5px;
left: 5px;
border-radius: 50px;
z-index: -1;
filter: blur(14px);
}
.button1:after {
content: "";
width: 100%;
height: 100%;
position: absolute;
top: 5px;
right: 5px;
border-radius: 50px;
z-index: -1;
filter: blur(14px);
}
#video-container {
position: relative;
display: flex;
justify-content: center;
align-items: flex-start;
height: 100%;
background-size: contain;
background-repeat: no-repeat;
}
</style>
</head>
<body>
<div id="video-container">
<div id="start-container">
<div id="button-container">
<div class="rings-container"></div>
<div id="button1" class="button1">
<svg
aria-hidden="true"
focusable="false"
data-prefix="fas"
data-icon="volume-up"
class="svg-inline--fa fa-volume-up fa-w-18"
role="img"
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 576 512"
style="width: 65%"
>
<path
fill="currentColor"
d="M215.03 71.05L126.06 160H24c-13.26 0-24 10.74-24 24v144c0 13.25 10.74 24 24 24h102.06l88.97 88.95c15.03 15.03 40.97 4.47 40.97-16.97V88.02c0-21.46-25.96-31.98-40.97-16.97zm233.32-51.08c-11.17-7.33-26.18-4.24-33.51 6.95-7.34 11.17-4.22 26.18 6.95 33.51 66.27 43.49 105.82 116.6 105.82 195.58 0 78.98-39.55 152.09-105.82 195.58-11.17 7.32-14.29 22.34-6.95 33.5 7.04 10.71 21.93 14.56 33.51 6.95C528.27 439.58 576 351.33 576 256S528.27 72.43 448.35 19.97zM480 256c0-63.53-32.06-121.94-85.77-156.24-11.19-7.14-26.03-3.82-33.12 7.46s-3.78 26.21 7.41 33.36C408.27 165.97 432 209.11 432 256s-23.73 90.03-63.48 115.42c-11.19 7.14-14.5 22.07-7.41 33.36 6.51 10.36 21.12 15.14 33.12 7.46C447.94 377.94 480 319.54 480 256zm-141.77-76.87c-11.58-6.33-26.19-2.16-32.61 9.45-6.39 11.61-2.16 26.2 9.45 32.61C327.98 228.28 336 241.63 336 256c0 14.38-8.02 27.72-20.92 34.81-11.61 6.41-15.84 21-9.45 32.61 6.43 11.66 21.05 15.8 32.61 9.45 28.23-15.55 45.77-45 45.77-76.88s-17.54-61.32-45.78-76.86z"
></path>
</svg>
</div>
</div>
</div>
<video id="vid" muted autoplay playsinline loop>
<!-- Source is created by the javacsript -->
Your browser does not support the video tag.
</video>
</div>
<script>
const video = document.getElementById("vid");
const startContainer = document.getElementById("start-container");
const ringsContainer = document.querySelector(".rings-container");
const videoContainer = document.getElementById("video-container");
const button1 = document.getElementById("button1");
let videoIsReadyToBePlayed = false;
let videoUnMuted = false;
var source = document.createElement("source");
const width =
window.innerWidth ||
document.documentElement.clientWidth ||
document.body.clientWidth;
if (width < 960) {
source.setAttribute("src", "./assets/kanye_all_day_960x540.mp4");
video.setAttribute("width", "960");
video.style.aspectRatio = "960/540";
videoContainer.style.backgroundImage =
'url("./assets/first_frame_960x540.jpg")';
} else if (width < 1280) {
source.setAttribute("src", "./assets/kanye_all_day_1280x720.mp4");
video.setAttribute("width", "1280");
video.style.aspectRatio = "1280/720";
videoContainer.style.backgroundImage =
'url("./assets/first_frame_1280x720.jpg")';
} else {
source.setAttribute("src", "./assets/kanye_all_day_1920x1080.mp4");
video.setAttribute("width", "1920");
video.style.aspectRatio = "1920/1080";
videoContainer.style.backgroundImage =
'url("./assets/first_frame_1920x1080.jpg")';
}
video.appendChild(source);
video.play();
video.oncanplay = () => {
videoIsReadyToBePlayed = true;
};
let firstTimeClick = true;
const clickListener = () => {
handleContinuationOfVideo();
if (firstTimeClick === true && videoIsReadyToBePlayed === true) {
button1.style.display = "none";
video.muted = false;
video.currentTime = 0;
firstTimeClick = false;
videoUnMuted = true;
}
};
const handleContinuationOfVideo = () => {
if (firstTimeClick === false) {
if (video.paused === false) {
video.pause();
} else {
video.play();
}
}
};
document.addEventListener("click", clickListener);
function handleIntersect(entries, observer) {
entries.forEach((entry) => {
if (entry.intersectionRatio === 0) {
video.pause();
video.muted = true;
button1.style.display = "flex";
firstTimeClick = true;
}
if (entry.intersectionRatio >= 0.8) {
video.play();
}
});
}
window.addEventListener(
"load",
(event) => {
videoElement = document.querySelector("#vid");
let options = {
root: null,
rootMargin: "0px",
threshold: [0, 0.5, 1],
};
const observer = new IntersectionObserver(handleIntersect, options);
observer.observe(videoElement);
},
false
);
</script>
<script>
/*
MIT License
Copyright (c) 2019 Jacob Filipp
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
// Add this script into the page that will appear <b>inside an iFrame</b>
// This code monitors the page for changes in size. When change is detected, it sends send the latest size to the parent page using postMessage
// determine height of content on this page
function getMyHeight() {
//https://stackoverflow.com/a/11864824
const video = document.getElementById("vid");
return video.scrollHeight;
}
// send the latest page dimensions to the parent page on which this iframe is embedded
function sendDimensionsToParent() {
var iframeDimensions_New = {
width: window.innerWidth, //supported from IE9 onwards
height: getMyHeight(),
};
if (
iframeDimensions_New.width != iframeDimensions_Old.width ||
iframeDimensions_New.height != iframeDimensions_Old.height
) {
// if old width is not equal new width, or old height is not equal new height, then...
window.parent.postMessage(iframeDimensions_New, "*");
iframeDimensions_Old = iframeDimensions_New;
}
}
// on load - send the page dimensions. (we do this on load because then all images have loaded...)
window.addEventListener("load", function () {
iframeDimensions_Old = {
width: window.innerWidth, //supported from IE9 onwards
height: getMyHeight(),
};
window.parent.postMessage(iframeDimensions_Old, "*"); //send our dimensions once, initially - so the iFrame is initialized to the correct size
if (window.MutationObserver) {
// if mutationobserver is supported by this browser
//https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver
var observer = new MutationObserver(sendDimensionsToParent);
config = {
attributes: true,
attributeOldValue: false,
characterData: true,
characterDataOldValue: false,
childList: true,
subtree: true,
};
observer.observe(document.body, config);
} // if mutationobserver is NOT supported
else {
//check for changes on a timed interval, every 1/3 of a second
window.setInterval(sendDimensionsToParent, 300);
}
}); // end of window.onload
</script>
</body>
</html>