|
8 | 8 | href="https://fonts.googleapis.com/css?family=Fira+Mono"
|
9 | 9 | rel="stylesheet"
|
10 | 10 | />
|
| 11 | + <link rel="stylesheet" href="./main.css" /> |
11 | 12 | <title>Musacorneri</title>
|
12 |
| - <style> |
13 |
| - html, |
14 |
| - body { |
15 |
| - margin: 0; |
16 |
| - padding: 0; |
17 |
| - font-family: "Fira Mono", monospace; |
18 |
| - } |
19 |
| - |
20 |
| - body { |
21 |
| - display: flex; |
22 |
| - flex-direction: column; |
23 |
| - align-items: center; |
24 |
| - height: 100vh; |
25 |
| - background: black; |
26 |
| - overflow: hidden; |
27 |
| - cursor: none; |
28 |
| - } |
29 |
| - |
30 |
| - h1 { |
31 |
| - width: 100%; |
32 |
| - padding: 30px; |
33 |
| - margin: 0; |
34 |
| - text-align: center; |
35 |
| - /* background: #292929; */ |
36 |
| - background: rgba(0, 0, 0, 0.5); |
37 |
| - color: #1ed760; |
38 |
| - font-size: 90px; |
39 |
| - text-transform: uppercase; |
40 |
| - } |
41 |
| - |
42 |
| - .trackinfo { |
43 |
| - display: flex; |
44 |
| - flex-direction: column; |
45 |
| - width: 100%; |
46 |
| - flex: 1; |
47 |
| - justify-content: center; |
48 |
| - align-items: center; |
49 |
| - color: white; |
50 |
| - } |
51 |
| - |
52 |
| - .artist { |
53 |
| - /* margin-top: 20px; */ |
54 |
| - font-size: 56px; |
55 |
| - } |
56 |
| - |
57 |
| - .track { |
58 |
| - font-size: 36px; |
59 |
| - margin-bottom: 20px; |
60 |
| - } |
61 |
| - |
62 |
| - .albumart { |
63 |
| - height: 500px; |
64 |
| - width: 500px; |
65 |
| - border: 15px solid #292929; |
66 |
| - } |
67 |
| - |
68 |
| - .timebar { |
69 |
| - width: 500px; |
70 |
| - margin-left: 10px; |
71 |
| - margin-right: 10px; |
72 |
| - height: 10px; |
73 |
| - background: #999; |
74 |
| - border-radius: 5px; |
75 |
| - overflow: hidden; |
76 |
| - } |
77 |
| - |
78 |
| - .timehead { |
79 |
| - width: 0%; |
80 |
| - height: 10px; |
81 |
| - background: #1ed760; |
82 |
| - } |
83 |
| - |
84 |
| - .timeContainer { |
85 |
| - display: flex; |
86 |
| - align-items: center; |
87 |
| - } |
88 |
| - |
89 |
| - .dj { |
90 |
| - text-align: right; |
91 |
| - align-self: flex-end; |
92 |
| - color: #777777; |
93 |
| - padding: 5px 15px; |
94 |
| - } |
95 |
| - |
96 |
| - .party { |
97 |
| - background: rgb(224, 9, 189); |
98 |
| - background: linear-gradient( |
99 |
| - 45deg, |
100 |
| - rgba(224, 9, 189, 1) 0%, |
101 |
| - rgba(0, 212, 255, 1) 100% |
102 |
| - ); |
103 |
| - } |
104 |
| - |
105 |
| - .parrot { |
106 |
| - height: 60px; |
107 |
| - } |
108 |
| - |
109 |
| - .eqcontainer { |
110 |
| - position: absolute; |
111 |
| - top: 30%; |
112 |
| - bottom: 0; |
113 |
| - left: 0; |
114 |
| - right: 0; |
115 |
| - z-index: -1; |
116 |
| - opacity: .7; |
117 |
| - } |
118 |
| - |
119 |
| - svg { |
120 |
| - display: block; |
121 |
| - width: 100%; |
122 |
| - height: 100%; |
123 |
| - padding: 0; |
124 |
| - margin: 0; |
125 |
| - position: absolute; |
126 |
| - } |
127 |
| - |
128 |
| - path { |
129 |
| - stroke-linecap: square; |
130 |
| - stroke: white; |
131 |
| - stroke-width: 0.5px; |
132 |
| - } |
133 |
| - |
134 |
| - .bgBlurri { |
135 |
| - position: absolute; |
136 |
| - top: -480px; |
137 |
| - bottom: 0; |
138 |
| - left: 0; |
139 |
| - right: 0; |
140 |
| - width: 100%; |
141 |
| - height: auto; |
142 |
| - opacity: 0.9; |
143 |
| - border: none; |
144 |
| - filter: blur(20px); |
145 |
| - z-index: 0; |
146 |
| - } |
147 |
| - |
148 |
| - .c { |
149 |
| - z-index: 1; |
150 |
| - position: absolute; |
151 |
| - top: 0; |
152 |
| - left: 0; |
153 |
| - right: 0; |
154 |
| - bottom: 0; |
155 |
| - |
156 |
| - display: flex; |
157 |
| - flex-direction: column; |
158 |
| - } |
159 |
| - |
160 |
| - .juttu { |
161 |
| - position: fixed; |
162 |
| - bottom: 0; |
163 |
| - background: rgba(0,0,0,.5); |
164 |
| - left: 0; |
165 |
| - right: 0; |
166 |
| - display: flex; |
167 |
| - flex-direction: inherit; |
168 |
| - align-items: center; |
169 |
| - padding: 20px; |
170 |
| - } |
171 |
| - |
172 |
| - .beercontainer { |
173 |
| - color: white; |
174 |
| - font-size: 40px; |
175 |
| - padding-top: 20px; |
176 |
| - text-align: center; |
177 |
| -} |
178 |
| - |
179 |
| - |
180 |
| - </style> |
181 | 13 | </head>
|
182 | 14 |
|
183 | 15 | <body>
|
184 | 16 | <div class="c">
|
185 |
| - <div class="beercontainer"> |
186 |
| - Kaljat ~<span id="beertemp" /> |
187 |
| - </div> |
| 17 | + <div class="beercontainer">Kaljat ~<span id="beertemp" /></div> |
| 18 | + <div class="silence" style="display: none;">🙉</div> |
188 | 19 | <div class="trackinfo">
|
189 |
| - <img class="albumart" src="https://giphy.com/embed/5nsiFjdgylfK3csZ5T" alt="" /> |
| 20 | + <img |
| 21 | + class="albumart" |
| 22 | + src="https://giphy.com/embed/5nsiFjdgylfK3csZ5T" |
| 23 | + alt="" |
| 24 | + /> |
190 | 25 | <div class="juttu">
|
191 | 26 | <div class="artist"></div>
|
192 | 27 | <div class="track"></div>
|
|
198 | 33 | </div>
|
199 | 34 | </div>
|
200 | 35 | </div>
|
201 |
| - |
202 | 36 | </div>
|
203 | 37 | <!-- EQ no work with raspberry... -->
|
204 | 38 | <div class="eqcontainer">
|
|
234 | 68 |
|
235 | 69 | <script>
|
236 | 70 | const e = {
|
| 71 | + trackinfo: document.querySelector(".trackinfo"), |
| 72 | + silence: document.querySelector(".silence"), |
237 | 73 | track: document.querySelector(".track"),
|
238 | 74 | artist: document.querySelector(".artist"),
|
239 | 75 | albumart: document.querySelectorAll(".albumart"),
|
|
245 | 81 | beertemp: document.querySelector("#beertemp")
|
246 | 82 | };
|
247 | 83 |
|
248 |
| - async function getBeerTemp(){ |
249 |
| - const res = await fetch("https://zclvxxpogl.execute-api.eu-west-1.amazonaws.com/dev/isbeercold"); |
250 |
| - const json = await res.json(); |
| 84 | + async function getBeerTemp() { |
| 85 | + const res = await fetch( |
| 86 | + "https://zclvxxpogl.execute-api.eu-west-1.amazonaws.com/dev/isbeercold" |
| 87 | + ); |
| 88 | + const json = await res.json(); |
251 | 89 |
|
252 |
| - e.beertemp.innerHTML = json.values[json.values.length -1] + " °C" |
| 90 | + e.beertemp.innerHTML = json.values[json.values.length - 1] + " °C"; |
253 | 91 |
|
254 |
| - json.values[json.values.length - 1] |
255 |
| - |
| 92 | + json.values[json.values.length - 1]; |
256 | 93 | }
|
257 | 94 |
|
258 | 95 | getBeerTemp();
|
259 | 96 | setInterval(async () => {
|
260 | 97 | getBeerTemp();
|
261 |
| - }, 1000 * 60) |
| 98 | + }, 1000 * 60); |
262 | 99 |
|
263 | 100 | const socket = io();
|
264 | 101 |
|
| 102 | + socket.on("show-image", function({ image, text }) { |
| 103 | + if (!image) return; |
265 | 104 |
|
266 |
| - |
267 |
| - socket.on("show-image", function({image, text}){ |
268 |
| - if(!image) return; |
269 |
| - |
270 |
| - console.log("got image", {image, text}); |
271 |
| - |
272 |
| - const ifrm = document.createElement("iframe"); |
| 105 | + const ifrm = document.createElement("iframe"); |
273 | 106 | ifrm.setAttribute("src", image);
|
274 | 107 | ifrm.setAttribute("id", "giphy");
|
275 | 108 |
|
276 | 109 | const dim = Math.min(window.innerHeight, window.innerWidth) - 200;
|
277 | 110 |
|
278 | 111 | ifrm.style.width = `${dim}px`;
|
279 | 112 | ifrm.style.height = `${dim}px`;
|
280 |
| - |
281 | 113 |
|
282 |
| - ifrm.style.zIndex = 100 |
| 114 | + ifrm.style.zIndex = 100; |
283 | 115 | ifrm.style.border = "none";
|
284 |
| - ifrm.style.margin = "auto" |
285 |
| - |
286 |
| - ifrm.style.bottom = 0 |
287 |
| - ifrm.style.top = 0 |
288 |
| - ifrm.style.left = 0 |
289 |
| - ifrm.style.right = 0 |
290 |
| - |
291 |
| - |
| 116 | + ifrm.style.margin = "auto"; |
| 117 | + |
| 118 | + ifrm.style.bottom = 0; |
| 119 | + ifrm.style.top = 0; |
| 120 | + ifrm.style.left = 0; |
| 121 | + ifrm.style.right = 0; |
| 122 | + |
292 | 123 | const gText = document.createElement("div");
|
293 | 124 | gText.setAttribute("id", "gText");
|
294 | 125 | gText.innerText = text;
|
|
297 | 128 | gText.style.background = "black";
|
298 | 129 | gText.style.fontSize = "100px";
|
299 | 130 | gText.style.zIndex = 101;
|
300 |
| - gText.style.padding = "40px" |
| 131 | + gText.style.padding = "40px"; |
301 | 132 |
|
302 |
| - |
303 |
| - document.body.appendChild(gText) |
304 |
| - document.body.appendChild(ifrm) |
| 133 | + document.body.appendChild(gText); |
| 134 | + document.body.appendChild(ifrm); |
305 | 135 |
|
306 | 136 | setTimeout(() => {
|
307 |
| - |
308 |
| - document.body.removeChild(document.getElementById("giphy")) |
309 |
| - document.body.removeChild(document.getElementById("gText")) |
310 |
| - }, 10000) |
311 |
| - |
312 |
| - }) |
313 |
| - |
314 |
| - |
| 137 | + document.body.removeChild(document.getElementById("giphy")); |
| 138 | + document.body.removeChild(document.getElementById("gText")); |
| 139 | + }, 10000); |
| 140 | + }); |
315 | 141 |
|
316 | 142 | socket.on("track-update", function(track) {
|
317 |
| - updateTrackData(e, track); |
| 143 | + updateTrackData(e, track); |
318 | 144 | });
|
319 | 145 |
|
320 | 146 | function secondsToTime(s) {
|
|
342 | 168 | const parrot = `<img class="parrot" src="https://cultofthepartyparrot.com/parrots/parrot.gif" />`;
|
343 | 169 |
|
344 | 170 | function updateTrackData(e, track) {
|
345 |
| - if (currentUri !== track.uri || currentTitle !== track.title) { |
| 171 | + if (track.position === null && track.duration === null) { |
| 172 | + // Undefined track! |
| 173 | + |
| 174 | + e.trackinfo.style.display = "none"; |
| 175 | + e.silence.style.display = "flex"; |
| 176 | + |
| 177 | + e.albumart.forEach(x => { |
| 178 | + x.src = "/jungle.jpg"; |
| 179 | + }); |
| 180 | + } else if (currentUri !== track.uri || currentTitle !== track.title) { |
| 181 | + e.trackinfo.style.display = "flex"; |
| 182 | + e.silence.style.display = "none"; |
346 | 183 | currentUri = track.uri;
|
347 | 184 | currentTitle = track.title;
|
348 | 185 | e.track.innerHTML = track.title;
|
|
351 | 188 | x.src = track.albumArtURL;
|
352 | 189 | });
|
353 | 190 | e.totalTime.innerHTML = secondsToTime(track.duration);
|
354 |
| - |
355 | 191 |
|
356 | 192 | // Friday
|
357 | 193 | if (track.isFridaySong) {
|
|
377 | 213 | var report = 0;
|
378 | 214 |
|
379 | 215 | var soundAllowed = function(stream) {
|
380 |
| - console.log("Sound"); |
381 | 216 | //Audio stops listening in FF without // window.persistAudioStream = stream;
|
382 | 217 | //https://bugzilla.mozilla.org/show_bug.cgi?id=965483
|
383 | 218 | //https://support.mozilla.org/en-US/questions/984179
|
|
422 | 257 | h.innerHTML = "You must allow your microphone.";
|
423 | 258 | console.log(error);
|
424 | 259 | };
|
425 |
| - navigator.getUserMedia = ( navigator.getUserMedia || |
426 |
| - navigator.webkitGetUserMedia || |
427 |
| - navigator.mozGetUserMedia || |
428 |
| - navigator.msGetUserMedia); |
| 260 | + navigator.getUserMedia = |
| 261 | + navigator.getUserMedia || |
| 262 | + navigator.webkitGetUserMedia || |
| 263 | + navigator.mozGetUserMedia || |
| 264 | + navigator.msGetUserMedia; |
429 | 265 |
|
430 | 266 | navigator.getUserMedia({ audio: true }, soundAllowed, soundNotAllowed);
|
431 | 267 | };
|
|
0 commit comments