-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoriginaltunawidget.html
327 lines (275 loc) · 26.4 KB
/
originaltunawidget.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
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
<!DOCTYPE html>
<html>
<style>
body {
margin: 0px;
overflow: hidden;
}
.info {
overflow: hidden;
padding-left: 10px;
padding-right: 10px;
}
.widget {
padding: 8px;
background-color: rgb(44, 44, 44);
border-radius: 4px;
border-color: rgb(22, 22, 22);
height: 120px;
box-shadow: 0px 0px 5px black;
margin: 8px;
position: relative;
z-index: -2;
}
#cover {
height: 100%;
transition: background-image 0.8s ease-in-out;
aspect-ratio: 1;
background-size: cover;
border-radius: 4px;
box-shadow: 0 0 4px 4px rgba(0, 0, 0, 0.5) inset;
background-position: center;
background-repeat: no-repeat;
}
.image-box {
border-radius: 4px;
border-width: 1px;
height: 100%;
float: left;
}
.image-box img {
position: relative;
z-index: -1;
border-radius: 4px;
}
#title {
font-size: x-large;
font-weight: bold;
}
p {
font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
color: white;
margin: 0px;
padding-bottom: 2px;
}
#artist {
font-size: large;
}
#progressbar,
#progress {
background-color: gray;
height: 6px;
width: 100%;
margin-top: 5px;
border-radius: 2px;
transition: background-color 0.8s ease-in-out;
}
#progressbar {
position: relative;
margin-bottom: 4px;
}
#progress {
background-color: rgb(223, 253, 179);
width: 50%;
position: absolute;
top: -80%;
}
#timeline {
display: grid;
grid-template-columns: 1fr 20fr 1fr;
align-items: center;
place-items: center;
}
#length {
margin-left: 5px;
font-size: medium;
}
#time-passed {
margin-right: 5px;
font-size: medium;
}
</style>
<body>
<div class="widget">
<div class="image-box">
<div id="cover"></div>
</div>
<div class="info">
<p id="title"> </p>
<p id="artist"> </p>
<div id="timeline">
<div>
<p id="time-passed">0:00</p>
</div>
<div id="progressbar">
<div id="progress"></div>
</div>
<div>
<p id="length">0:00</p>
</div>
</div>
</div>
</div>
</body>
<script>
const PAUSED_PLACEHOLDER = "Nothing playing";
const REFRESH_INTERVAL_MS = 200;
const FETCH_URL = "http://localhost:1608/";
const placeholder = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAgAAAAIACAMAAADDpiTIAAAAAXNSR0IB2cksfwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAhBQTFRFUVFRUFBQUlJSU1NTVFRUVVVVVlZWV1dXWFhYWVlZWlpaW1tbXFxcXV1dXl5eX19fYGBgYWFhYmJiY2NjZGRkZWVlZmZmZ2dnaGhoaWlpampqa2trbGxsbW1tbm5ub29vcHBwcXFxcnJyc3NzdHR0dXV1dnZ2d3d3eHh4eXl5enp6e3t7fHx8fX19fn5+f39/gICAgYGBgoKCg4ODhISEhYWFhoaGh4eHiIiIiYmJioqKi4uLjIyMjY2Njo6Oj4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KAAIYBhAAoQAw0CqzIpHyw0Hs0Hx5+bT89/ue0/1AAiABwyA3AnoOHj6gyAAm4mwiAICAQUAxICIAC4sAyYWANV9oAtCMtzVfuC/vh8Sf/7yb/ZQFw5PDBPT0AHPIiAIIARgEIA8iAgAApQA7SigVWRJImkCNJMB/dFw8/Pv0U/nv9P9QLwAEk4BgWgooAEwFggCCQFCgOWNEL7UDv0Xxw37Tf8P/EsWPo/wE3ALv3CwKOSAKwDqAgQAhALSAZAAgQA+BAKsmKRLYDU2Q9mC/dp+Av7KfHn/I/+X9E+L9/txuAfUTA0WOQBcwggAhQGCAIgALCQLPAikq2DxPoPZmPD7+03378If6LCQD6v88NwK69+w4cEIUgxIDjKg0YCAADEgJBAWAgSSBNsoYue/TJjQfIezAf3bftV+H/OD7/hw8eOLBv7y43AHv27pcEHJUEKAQMBhACiQGCIHWeFYHs8ZeGgDdgvu2+sl/6f1T6v3/vnl4AiIBDmgAMAogAhAFgACAgCogDGwVWhJJWgCvk/WfvRffFw4/2y/Av/T9E/vcAcOvuPXv2IQE4G3QiQGGAIEAKkAOJAitqkRfky73SfHz4nfbL+Z/wf9+ePbtvdQOwSxCAdQAQgEFAIgCJABiQEAgKAAMFAms0hJacI+/BfHRfBH9pPz7+0v994vnfvcsNgCJgPxKgggAioBkQEAgKCAPgAHUvK1IpH+6R1gvvhfnKfbRfPf7o//4+/n/GJqAHAWIAIJAUAAaaBFb0Ij/u0t5D5Af3e+y3/f+MGwDxL2699dZdu3YLDPbs3btPSLBw4KDQIaHDoCNKt7l1lDV09Zig7UGzwDVw7wC4LrRXOL9n9+5du4TN5DeLxWKxWCwWi8ViseKn/w8vkBus+WX7kAAAAABJRU5ErkJggg==";
var last_cover = "";
var last_artist = "";
var last_title = "";
function format_ms(s) {
if (!s) return "0:00";
var ms = s % 1000;
s = Math.floor((s - ms) / 1000);
var secs = s % 60;
s = (s - secs) / 60;
var mins = s % 60;
var hrs = (s - mins) / 60;
if (secs < 10) secs = "0" + secs;
if (hrs > 0) {
if (mins < 10) mins = "0" + mins;
return hrs + ":" + mins + ":" + secs;
}
return mins + ":" + secs;
}
function calculate_brightness(packed_rgb) {
let rgb = unpack_rgb(packed_rgb);
const r = rgb[0] / 255;
const g = rgb[1] / 255;
const b = rgb[2] / 255;
const luminance = 0.2126 * r + 0.7152 * g + 0.0722 * b;
return luminance;
}
function unpack_rgb(packed) {
const r = (packed >> 16) & 0xff;
const g = (packed >> 8) & 0xff;
const b = packed & 0xff;
return [r, g, b];
}
function pack_rgb(r, g, b) {
return (r << 16) | (g << 8) | b;
}
function increase_brightness(rgb, amount) {
const [r, g, b] = rgb;
// Calculate luminance
const luminance = 0.299 * r + 0.587 * g + 0.114 * b;
// Increase brightness based on luminance
const increasedR = Math.min(r + (amount * (255 - luminance)) / 255, 255);
const increasedG = Math.min(g + (amount * (255 - luminance)) / 255, 255);
const increasedB = Math.min(b + (amount * (255 - luminance)) / 255, 255);
return [increasedR, increasedG, increasedB];
}
function extract_color_palette(url, num_colors) {
return new Promise((resolve, reject) => {
const img = new Image();
img.crossOrigin = "Anonymous";
img.onload = function () {
const canvas = document.createElement("canvas");
const ctx = canvas.getContext("2d");
const colorCounts = {};
// Set the canvas dimensions to match the image
canvas.width = img.width;
canvas.height = img.height;
// Draw the image onto the canvas
ctx.drawImage(img, 0, 0);
// Get the image data
const imageData = ctx.getImageData(0, 0, canvas.width, canvas.height).data;
// Loop through each pixel in the image
for (let i = 0; i < imageData.length; i += 4) {
const r = imageData[i];
const g = imageData[i + 1];
const b = imageData[i + 2];
const color = pack_rgb(r, g, b);
// Count the occurrences of each color
colorCounts[color] = (colorCounts[color] || 0) + 1;
}
// Sort the colors by count in descending order
const sortedColors = Object.keys(colorCounts).sort((a, b) => colorCounts[b] - colorCounts[a]);
// Return the top 'numColors' colors from the palette
resolve(sortedColors.slice(0, num_colors));
};
img.onerror = function () {
reject(new Error("Failed to load image."));
};
// Start loading the image
img.src = url;
});
}
function fetch_data() {
fetch(FETCH_URL)
.then((response) => response.json())
.then((data) => {
// data now contains the json object with song metadata
// artist list
var artists = "";
var array = data["artists"] || []; // in some cases no artist is known/submitted
for (var i = 0; i < array.length; i++) {
artists += array[i];
if (i < array.length - 1) artists += ", ";
}
if (data["title"] != last_title) {
if (!data["title"]) document.getElementById("title").innerText = PAUSED_PLACEHOLDER;
else document.getElementById("title").innerText = data["title"];
}
if (data["cover_url"] == undefined || data["cover_url"] == "") {
document.getElementById("cover").style.backgroundImage = `url(${placeholder}})`;
} else if (
data["cover_url"] !== last_cover || // Refresh only if meta data suggests that the cover changed
data["title"] !== last_title || // When using MPD the path is always the cover path configured in tuna
artists !== last_artist
) {
// which means it won't change so we check against other data
// Random number at the end is to prevent caching
setTimeout(() => {
document.getElementById("cover").style.backgroundImage = `url(${data["cover_url"] + "?" + new Date().getTime()})`;
last_cover = data["cover_url"];
}, 700);
extract_color_palette(data["cover_url"], 10).then((palette) => {
var brightest_value = 0;
var packed_rgb = palette[0];
for (var i = 0; i < palette.length; i++) {
let b = calculate_brightness(palette[i]);
if (b > brightest_value && b < 0.85) {
// find the brigest color, but don't use colors that are too bright
console.log(b);
packed_rgb = palette[i];
brightest_value = b;
}
}
let rgb = unpack_rgb(packed_rgb);
if (brightest_value < 0.4) {
// brighten the color, if it's too dark
rgb = increase_brightness(rgb, 0.2);
}
document.getElementById("progress").style.backgroundColor = `rgb(${rgb[0]}, ${rgb[1]}, ${rgb[2]})`;
});
}
if (artists != last_artist) {
var artistLine = "";
if (artists != "") artistLine += "<i>by</i> " + artists + " ";
// sometimes there is an album with no artist, we can still allow that
if (data["album"] != undefined && data["album"] != artists)
// Some singles have the artist as the album, which looks strange with the other subtitle
artistLine += "<i>on</i> " + data["album"];
// use in case we have neither artist nor album
// space is considered empty element, is not
artistLine == "" ? (document.getElementById("artist").innerHTML = " ") : (document.getElementById("artist").innerHTML = artistLine);
}
var length = data["duration"];
var progress = data["progress"];
document.getElementById("progress").style.width = (progress / length) * 100 + "%";
// Timestamps
document.getElementById("length").innerText = format_ms(length);
document.getElementById("time-passed").innerText = format_ms(progress);
last_artist = artists;
last_title = data["title"];
})
.catch(function () {
// Do nothing
});
}
setInterval(fetch_data, REFRESH_INTERVAL_MS);
</script>
</html>