Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
mamayaya1
GitHub Repository: mamayaya1/game
Path: blob/main/projects/chill-radio/js/main.js
4626 views
1
// Made by 3kh0
2
// https://github.com/3kh0/chill-radio
3
4
(this.webpackJsonpcoderadio = this.webpackJsonpcoderadio || []).push([
5
[0],
6
{
7
88: function (t, e, a) {},
8
89: function (t, e, a) {
9
"use strict";
10
a.r(e);
11
var n = a(3),
12
r = a.n(n),
13
i = a(51),
14
s = a.n(i),
15
o = a(92),
16
l = a(58),
17
c = a(18),
18
u = a(34),
19
d = a.n(u),
20
h = a(42),
21
p = a(25),
22
g = a(13),
23
f = a(14),
24
m = a(17),
25
b = a(16),
26
v = a(15),
27
y = a(52),
28
j = a.n(y),
29
O = a(53),
30
x = a(11),
31
S = a(43),
32
w = a.n(S),
33
C = a(23),
34
V = a(59),
35
k = a(1);
36
function _() {
37
var t = Object(n.useState)(!1),
38
e = Object(V.a)(t, 2),
39
a = e[0],
40
r = e[1];
41
return Object(k.jsxs)("nav", {
42
className: "site-nav" + (a ? " expand-nav" : ""),
43
id: "site-nav",
44
children: [
45
Object(k.jsx)("div", { className: "site-nav-left" }),
46
Object(k.jsx)("div", {
47
className: "site-nav-middle",
48
children: Object(k.jsx)("a", {
49
className: "site-nav-logo",
50
href: "/chill-radio",
51
children: Object(k.jsx)("img", { alt: "Chill Radio", src: "img/chill-logo.png" }),
52
}),
53
}),
54
Object(k.jsx)("div", {
55
className: "site-nav-right main-nav",
56
children: Object(k.jsx)("div", {
57
className: "main-nav-group",
58
children: Object(k.jsx)("ul", {
59
className: "nav" + (a ? " show-main-nav-items" : ""),
60
id: "nav",
61
children: [
62
{ href: "/", text: "Home" },
63
{ href: "https://github.com/3kh0/chill-radio", text: "GitHub" },
64
].map(function (t, e) {
65
return Object(k.jsx)("li", { children: Object(k.jsx)("a", { href: t.href, rel: "noopener noreferrer", target: "_blank", children: t.text }) }, e);
66
}),
67
}),
68
}),
69
}),
70
Object(k.jsx)("button", {
71
className: "site-nav-right toggle-button-nav" + (a ? " reverse-toggle-color" : ""),
72
id: "toggle-button-nav",
73
onClick: function () {
74
r(!a);
75
},
76
children: "Menu",
77
}),
78
],
79
});
80
}
81
var E,
82
T,
83
P = a(39),
84
N = (function (t) {
85
Object(b.a)(a, t);
86
var e = Object(v.a)(a);
87
function a(t) {
88
var n;
89
return (
90
Object(g.a)(this, a),
91
((n = e.call(this, t)).rafId = null),
92
(n.timerId = null),
93
(n.reset = function () {
94
n.rafId = null;
95
}),
96
(n.startDrawing = function () {
97
n.rafId || (n.rafId = window.requestAnimationFrame(n.drawingLoop));
98
}),
99
(n.stopDrawing = function () {
100
window.cancelAnimationFrame(n.rafId), clearTimeout(n.timerId);
101
}),
102
(n.drawingLoop = function () {
103
var t =
104
0 !==
105
n.state.eq.bands.reduce(function (t, e) {
106
return t + e;
107
}, 0);
108
n.updateEQBands(), n.drawVisualizer(), t ? (n.rafId = window.requestAnimationFrame(n.drawingLoop)) : (n.timerId = setTimeout(n.drawingLoop, 250));
109
}),
110
(n.handleVisibilityChange = function (t) {
111
n.setState({ isTabVisible: t });
112
}),
113
(n.state = { eq: {}, config: { baseColour: "rgb(10, 10, 35)", translucent: "rgba(10, 10, 35, 0.6)", multiplier: 0.7529 }, isTabVisible: !0 }),
114
n
115
);
116
}
117
return (
118
Object(f.a)(a, [
119
{
120
key: "componentDidUpdate",
121
value: function (t, e) {
122
var a = this;
123
(t.playing === this.props.playing && e.isTabVisible === this.state.isTabVisible) ||
124
(this.props.playing && this.state.isTabVisible
125
? (this.state.eq.context || this.initiateEQ(), this.createVisualizer(), this.startDrawing())
126
: setTimeout(function () {
127
a.stopDrawing(), a.reset();
128
}, 500));
129
},
130
},
131
{
132
key: "initiateEQ",
133
value: function () {
134
var t = this.state.eq,
135
e = window.AudioContext || window.webkitAudioContext;
136
(t.context = new e()),
137
(t.src = t.context.createMediaElementSource(this.props.player)),
138
(t.analyser = t.context.createAnalyser()),
139
t.src.connect(t.analyser),
140
t.analyser.connect(t.context.destination),
141
(t.analyser.fftSize = 256),
142
(t.bands = new Uint8Array(t.analyser.frequencyBinCount - 32)),
143
this.setState({ eq: t });
144
},
145
},
146
{
147
key: "updateEQBands",
148
value: function () {
149
var t = this.state.eq;
150
t.analyser.getByteFrequencyData(t.bands), this.setState({ eq: Object(c.a)({}, t) });
151
},
152
},
153
{
154
key: "createVisualizer",
155
value: function () {
156
(this._canvas.width = this._canvas.parentNode.offsetWidth),
157
(this._canvas.height = this._canvas.parentNode.offsetHeight),
158
(this.visualizer = { ctx: this._canvas.getContext("2d"), height: this._canvas.height, width: this._canvas.width, barWidth: this._canvas.width / this.state.eq.bands.length });
159
},
160
},
161
{
162
key: "drawVisualizer",
163
value: function () {
164
var t,
165
e = this,
166
a = 0;
167
this.visualizer.ctx.clearRect(0, 0, this.visualizer.width, this.visualizer.height),
168
this.visualizer.ctx.beginPath(),
169
this.visualizer.ctx.moveTo(a, 0),
170
(this.visualizer.ctx.fillStyle = this.state.config.translucent),
171
this.state.eq.bands.forEach(function (n) {
172
(t = e.state.config.multiplier * n), e.visualizer.ctx.lineTo(a, t), e.visualizer.ctx.lineTo(a + e.visualizer.barWidth, t), (a += e.visualizer.barWidth);
173
}),
174
this.visualizer.ctx.lineTo(a, 0),
175
this.visualizer.ctx.fill();
176
},
177
},
178
{
179
key: "render",
180
value: function () {
181
var t = this;
182
return Object(k.jsx)(P.a, {
183
onChange: this.handleVisibilityChange,
184
children: Object(k.jsx)("div", {
185
className: "visualizer",
186
children: Object(k.jsx)("canvas", {
187
"aria-label": "visualizer",
188
ref: function (e) {
189
return (t._canvas = e);
190
},
191
}),
192
}),
193
});
194
},
195
},
196
]),
197
a
198
);
199
})(r.a.PureComponent),
200
I = function (t) {
201
return Object(k.jsxs)("main", {
202
children: [
203
Object(k.jsxs)("div", {
204
className: "under-header-content",
205
children: [Object(k.jsx)("h1", { className: "site-title", children: "Welcome to Chill Radio." }), Object(k.jsx)("h2", { className: "site-description", children: "24/7 music designed for studying/reading/relaxing." })],
206
}),
207
C.isBrowser &&
208
Object(k.jsxs)(k.Fragment, {
209
children: [
210
Object(k.jsx)("div", { className: "animation" }),
211
Object(k.jsx)(N, { player: t.player, playing: t.playing }),
212
Object(k.jsxs)("details", {
213
children: [
214
Object(k.jsx)("summary", { children: "Keyboard Controls" }),
215
Object(k.jsxs)("dl", {
216
children: [
217
Object(k.jsx)("dt", { children: "Play/Pause:" }),
218
Object(k.jsx)("dd", { children: 'Spacebar or "k"' }),
219
Object(k.jsx)("dt", { children: "Volume:" }),
220
Object(k.jsx)("dd", { children: "Up Arrow / Down Arrow" }),
221
],
222
}),
223
],
224
}),
225
],
226
}),
227
],
228
});
229
},
230
L = function (t) {
231
return Object(k.jsxs)("div", {
232
className: t.playing ? "meta-display thumb meta-display-visible" : "meta-display thumb",
233
children: [
234
Object(k.jsx)("img", { alt: "album art", "data-meta": "picture", src: t.fastConnection ? t.currentSong.art : "img/cover_placeholder.gif" }),
235
Object(k.jsxs)("div", {
236
className: "now-playing",
237
children: [
238
Object(k.jsx)("div", { className: "progress-container", children: Object(k.jsx)("progress", { "data-meta": "duration", max: t.songDuration, value: t.progressVal }) }),
239
Object(k.jsx)("div", { "data-meta": "title", children: t.currentSong.title }),
240
Object(k.jsx)("div", { "data-meta": "artist", children: t.currentSong.artist }),
241
Object(k.jsx)("div", { "data-meta": "album", children: t.currentSong.album }),
242
Object(k.jsxs)("div", { "data-meta": "listeners", children: ["Listeners: ", t.listeners] }),
243
t.mountOptions,
244
],
245
}),
246
],
247
});
248
},
249
M = function (t) {
250
var e = t.currentVolume,
251
a = t.setTargetVolume,
252
n = 100 * e;
253
return Object(k.jsx)("div", {
254
className: "slider-container",
255
children: Object(k.jsx)("input", {
256
"aria-label": "slider",
257
className: "slider",
258
max: 100,
259
min: "0",
260
onChange: function (t) {
261
var e = t.target.value;
262
a(e / 100);
263
},
264
type: "range",
265
value: n,
266
}),
267
});
268
},
269
D = ["title", "titleId"];
270
function A() {
271
return (A =
272
Object.assign ||
273
function (t) {
274
for (var e = 1; e < arguments.length; e++) {
275
var a = arguments[e];
276
for (var n in a) Object.prototype.hasOwnProperty.call(a, n) && (t[n] = a[n]);
277
}
278
return t;
279
}).apply(this, arguments);
280
}
281
function U(t, e) {
282
if (null == t) return {};
283
var a,
284
n,
285
r = (function (t, e) {
286
if (null == t) return {};
287
var a,
288
n,
289
r = {},
290
i = Object.keys(t);
291
for (n = 0; n < i.length; n++) (a = i[n]), e.indexOf(a) >= 0 || (r[a] = t[a]);
292
return r;
293
})(t, e);
294
if (Object.getOwnPropertySymbols) {
295
var i = Object.getOwnPropertySymbols(t);
296
for (n = 0; n < i.length; n++) (a = i[n]), e.indexOf(a) >= 0 || (Object.prototype.propertyIsEnumerable.call(t, a) && (r[a] = t[a]));
297
}
298
return r;
299
}
300
function F(t, e) {
301
var a = t.title,
302
r = t.titleId,
303
i = U(t, D);
304
return n.createElement(
305
"svg",
306
A({ viewBox: "0 0 640 640", fill: "currentColor", ref: e, "aria-labelledby": r }, i),
307
void 0 === a ? n.createElement("title", { id: r }, "Pause Button") : a ? n.createElement("title", { id: r }, a) : null,
308
E || (E = n.createElement("path", { d: "M0 0L235.67 0L235.67 640L0 640L0 0Z" })),
309
T || (T = n.createElement("path", { d: "M404.33 0L640 0L640 640L404.33 640L404.33 0Z" }))
310
);
311
}
312
var z,
313
R = n.forwardRef(F),
314
q = (a.p, ["title", "titleId"]);
315
function B() {
316
return (B =
317
Object.assign ||
318
function (t) {
319
for (var e = 1; e < arguments.length; e++) {
320
var a = arguments[e];
321
for (var n in a) Object.prototype.hasOwnProperty.call(a, n) && (t[n] = a[n]);
322
}
323
return t;
324
}).apply(this, arguments);
325
}
326
function H(t, e) {
327
if (null == t) return {};
328
var a,
329
n,
330
r = (function (t, e) {
331
if (null == t) return {};
332
var a,
333
n,
334
r = {},
335
i = Object.keys(t);
336
for (n = 0; n < i.length; n++) (a = i[n]), e.indexOf(a) >= 0 || (r[a] = t[a]);
337
return r;
338
})(t, e);
339
if (Object.getOwnPropertySymbols) {
340
var i = Object.getOwnPropertySymbols(t);
341
for (n = 0; n < i.length; n++) (a = i[n]), e.indexOf(a) >= 0 || (Object.prototype.propertyIsEnumerable.call(t, a) && (r[a] = t[a]));
342
}
343
return r;
344
}
345
function K(t, e) {
346
var a = t.title,
347
r = t.titleId,
348
i = H(t, q);
349
return n.createElement(
350
"svg",
351
B({ viewBox: "0 0 640 640", fill: "#fff", ref: e, "aria-labelledby": r }, i),
352
void 0 === a ? n.createElement("title", { id: r }, "Play Button") : a ? n.createElement("title", { id: r }, a) : null,
353
z || (z = n.createElement("path", { d: "M0 0L649.1 320L0 640L0 0Z" }))
354
);
355
}
356
var W = n.forwardRef(K),
357
G =
358
(a.p,
359
(function (t) {
360
Object(b.a)(a, t);
361
var e = Object(v.a)(a);
362
function a() {
363
var t;
364
Object(g.a)(this, a);
365
for (var n = arguments.length, r = new Array(n), i = 0; i < n; i++) r[i] = arguments[i];
366
return (
367
((t = e.call.apply(e, [this].concat(r))).state = { initialLoad: !0 }),
368
(t.handleOnClick = function () {
369
return C.isBrowser && t.props.togglePlay();
370
}),
371
(t.handleOnTouchEnd = function () {
372
return !C.isBrowser && t.props.togglePlay();
373
}),
374
(t.handleKeyDown = function (e) {
375
13 === e.keyCode && t.handleOnClick();
376
}),
377
t
378
);
379
}
380
return (
381
Object(f.a)(
382
a,
383
[
384
{
385
key: "render",
386
value: function () {
387
return Object(k.jsx)("button", {
388
"aria-label": this.props.playing ? "Pause" : "Play",
389
className: this.state.initialLoad ? "play-container-cta play-container" : "play-container",
390
id: "playContainer",
391
onClick: this.handleOnClick,
392
onKeyDown: this.handleKeyDown,
393
onTouchEnd: this.handleOnTouchEnd,
394
children: this.props.playing ? Object(k.jsx)(R, {}) : Object(k.jsx)(W, {}),
395
});
396
},
397
},
398
],
399
[
400
{
401
key: "getDerivedStateFromProps",
402
value: function (t, e) {
403
return e.initialLoad && t.playing ? { initialLoad: !1 } : null;
404
},
405
},
406
]
407
),
408
a
409
);
410
})(r.a.Component)),
411
Q = a(54),
412
J = a(55),
413
Y = (function (t) {
414
Object(b.a)(a, t);
415
var e = Object(v.a)(a);
416
function a(t) {
417
var n;
418
return (
419
Object(g.a)(this, a),
420
((n = e.call(this, t)).toggleDisplay = function () {
421
n.setState({ displayList: !n.state.displayList });
422
}),
423
(n.state = { displayList: !1 }),
424
n
425
);
426
}
427
return (
428
Object(f.a)(a, [
429
{
430
key: "render",
431
value: function () {
432
var t = this.props,
433
e = t.songHistory,
434
a = t.fastConnection,
435
n = e
436
.map(function (t) {
437
return t.song;
438
})
439
.reverse();
440
return Object(k.jsxs)("button", {
441
"aria-label": "Recent Song History",
442
className: "recent-song-history",
443
onClick: this.toggleDisplay,
444
children: [
445
this.state.displayList &&
446
Object(k.jsx)("div", {
447
className: "recent-song-list",
448
children: n.map(function (t) {
449
return Object(k.jsxs)(
450
"div",
451
{
452
className: "recent-song-info",
453
children: [
454
Object(k.jsx)("img", { alt: "", role: "presentation", src: a ? t.art : "img/cover_placeholder.gif" }),
455
Object(k.jsxs)("div", {
456
className: "recent-song-meta",
457
children: [Object(k.jsx)("p", { children: t.title }), Object(k.jsxs)("p", { children: [" ", t.artist] }), Object(k.jsxs)("p", { children: [" ", t.album] })],
458
}),
459
],
460
},
461
t.id
462
);
463
}),
464
}),
465
Object(k.jsx)(Q.a, { className: "recently-played-icon", icon: J.a }),
466
],
467
});
468
},
469
},
470
]),
471
a
472
);
473
})(n.Component),
474
Z = (function (t) {
475
Object(b.a)(a, t);
476
var e = Object(v.a)(a);
477
function a(t) {
478
var n;
479
return (
480
Object(g.a)(this, a),
481
((n = e.call(this, t)).handleVisibilityChange = function (t) {
482
n.setState({ isTabVisible: t }, function () {
483
n.toggleInterval();
484
});
485
}),
486
(n.state = { progressVal: 0, currentSong: {}, progressInterval: null, alternativeMounts: null, isTabVisible: !0 }),
487
(n.updateProgress = n.updateProgress.bind(Object(m.a)(n))),
488
n
489
);
490
}
491
return (
492
Object(f.a)(a, [
493
{
494
key: "componentDidUpdate",
495
value: function (t) {
496
this.state.currentSong.id !== t.currentSong.id && this.props.songStartedAt && this.props.playing
497
? (this.setState({ currentSong: this.props.currentSong, alternativeMounts: [].concat(this.props.remotes, this.props.mounts) }), this.toggleInterval())
498
: t.playing !== this.props.playing && this.toggleInterval();
499
},
500
},
501
{
502
key: "startInterval",
503
value: function () {
504
this.stopCurrentInterval(), this.setState({ progressInterval: setInterval(this.updateProgress, 100) });
505
},
506
},
507
{
508
key: "stopCurrentInterval",
509
value: function () {
510
this.state.progressInterval && clearInterval(this.state.progressInterval);
511
},
512
},
513
{
514
key: "toggleInterval",
515
value: function () {
516
this.props.playing && this.state.isTabVisible ? this.startInterval() : this.stopCurrentInterval();
517
},
518
},
519
{
520
key: "updateProgress",
521
value: function () {
522
var t = parseInt(((new Date().valueOf() - this.props.songStartedAt) / 1e3).toFixed(2), 10);
523
this.setState({ progressVal: t });
524
},
525
},
526
{
527
key: "handleChange",
528
value: function (t) {
529
var e = t.target.value;
530
this.props.setUrl(e);
531
},
532
},
533
{
534
key: "getMountOptions",
535
value: function () {
536
var t = "",
537
e = this.state.alternativeMounts;
538
return (
539
e &&
540
this.props.url &&
541
(t = Object(k.jsx)("select", {
542
"aria-label": "Select Stream",
543
"data-meta": "stream-select",
544
onChange: this.handleChange.bind(this),
545
value: this.props.url,
546
children: e.map(function (t, e) {
547
return Object(k.jsx)("option", { value: t.url, children: t.name }, e);
548
}),
549
})),
550
t
551
);
552
},
553
},
554
{
555
key: "render",
556
value: function () {
557
var t = this.state,
558
e = t.progressVal,
559
a = t.currentSong,
560
n = t.isTabVisible,
561
r = this.props,
562
i = r.playing,
563
s = r.songDuration,
564
o = r.togglePlay,
565
l = r.currentVolume,
566
c = r.setTargetVolume,
567
u = r.listeners,
568
d = r.fastConnection;
569
return Object(k.jsx)(P.a, {
570
onChange: this.handleVisibilityChange,
571
children: Object(k.jsxs)("footer", {
572
children: [
573
n && Object(k.jsx)(Y, { songHistory: this.props.songHistory, fastConnection: d }),
574
Object(k.jsx)(L, { currentSong: a, progressVal: e, fastConnection: d, listeners: u, mountOptions: this.getMountOptions(), playing: i, songDuration: s }),
575
Object(k.jsx)(G, { playing: i, togglePlay: o }),
576
Object(k.jsx)(M, { currentVolume: l, setTargetVolume: c }),
577
],
578
}),
579
});
580
},
581
},
582
]),
583
a
584
);
585
})(r.a.PureComponent),
586
X = (a(88), new j.a("wss://coderadio-admin.freecodecamp.org/api/live/nowplaying/coderadio")),
587
$ = "coderadio-volume";
588
X.on("error", function (t, e) {
589
x.a({ message: "Error! NchanSubscriber error: " + e }), x.b(t);
590
});
591
var tt = (function (t) {
592
Object(b.a)(a, t);
593
var e = Object(v.a)(a);
594
function a(t) {
595
var n;
596
return (
597
Object(g.a)(this, a),
598
((n = e.call(this, t)).sortStreams = function (t) {
599
var e = arguments.length > 1 && void 0 !== arguments[1] && arguments[1],
600
a = arguments.length > 2 && void 0 !== arguments[2] && arguments[2];
601
if (a) {
602
var n = t.map(function (t) {
603
return t.bitrate;
604
}),
605
r = Math.max.apply(Math, Object(p.a)(n));
606
return t
607
.filter(function (t) {
608
return e ? t.bitrate !== r : t.bitrate === r;
609
})
610
.sort(function () {
611
return Math.random() - 0.5;
612
});
613
}
614
return t.sort(function (t, a) {
615
if (e) {
616
if (parseFloat(t.bitrate) < parseFloat(a.bitrate)) return -1;
617
if (parseFloat(t.bitrate) > parseFloat(a.bitrate)) return 1;
618
} else {
619
if (parseFloat(t.bitrate) < parseFloat(a.bitrate)) return 1;
620
if (parseFloat(t.bitrate) > parseFloat(a.bitrate)) return -1;
621
}
622
return t.listeners.current < a.listeners.current ? -1 : t.listeners.current > a.listeners.current ? 1 : 0;
623
});
624
}),
625
(n.getStreamUrl = function (t, e) {
626
return n.sortStreams(t, e, !0)[0].url;
627
}),
628
(n.increaseVolume = function () {
629
return n.setTargetVolume(Math.min(n.state.audioConfig.maxVolume + n.state.audioConfig.volumeSteps, 1));
630
}),
631
(n.decreaseVolume = function () {
632
return n.setTargetVolume(Math.max(n.state.audioConfig.maxVolume - n.state.audioConfig.volumeSteps, 0));
633
}),
634
(n.onPlayerError = Object(h.a)(
635
d.a.mark(function t() {
636
var e, a, r, i, s, o, l, c, u, h;
637
return d.a.wrap(function (t) {
638
for (;;)
639
switch ((t.prev = t.next)) {
640
case 0:
641
if (n.state.playing || n._player.src) {
642
t.next = 2;
643
break;
644
}
645
return t.abrupt("return");
646
case 2:
647
if (
648
((e = n.state),
649
(a = e.mounts),
650
(r = e.remotes),
651
(i = e.erroredStreams),
652
(s = e.url),
653
(o = n.sortStreams([].concat(Object(p.a)(r), Object(p.a)(a)))),
654
(l = o.find(function (t) {
655
return t.url === s;
656
})),
657
(c = i.some(function (t) {
658
return t.url === s;
659
})),
660
(u = c ? i : [].concat(Object(p.a)(i), [l])).length !== o.length)
661
) {
662
t.next = 11;
663
break;
664
}
665
return (t.next = 10), n.pause();
666
case 10:
667
return t.abrupt("return");
668
case 11:
669
(h = o
670
.filter(function (t) {
671
return !u.some(function (e) {
672
return e.url === t.url;
673
});
674
})
675
.map(function (t) {
676
return t.url;
677
})),
678
c
679
? n.setUrl(h[0])
680
: n.setState({ erroredStreams: u }, function () {
681
return n.setUrl(h[0]);
682
});
683
case 13:
684
case "end":
685
return t.stop();
686
}
687
}, t);
688
})
689
)),
690
(n.state = {
691
config: { metadataTimer: 1e3 },
692
fastConnection: !!navigator.connection && navigator.connection.downlink > 1.5,
693
eq: {},
694
visualizer: {},
695
audioConfig: { targetVolume: 0, maxVolume: 0.5, volumeSteps: 0.01, currentVolume: 0.5, volumeTransitionSpeed: 10 },
696
url: "",
697
mounts: [],
698
remotes: [],
699
playing: null,
700
captions: null,
701
pausing: null,
702
pullMeta: !1,
703
erroredStreams: [],
704
currentSong: {},
705
songStartedAt: 0,
706
songDuration: 0,
707
listeners: 0,
708
songHistory: [],
709
}),
710
(n.keyMap = { TOGGLE_PLAY: ["space", "k"], INCREASE_VOLUME: "up", DECREASE_VOLUME: "down" }),
711
(n.handlers = {
712
TOGGLE_PLAY: function () {
713
return n.togglePlay();
714
},
715
INCREASE_VOLUME: function () {
716
return n.increaseVolume();
717
},
718
DECREASE_VOLUME: function () {
719
return n.decreaseVolume();
720
},
721
}),
722
(n.togglePlay = n.togglePlay.bind(Object(m.a)(n))),
723
(n.setUrl = n.setUrl.bind(Object(m.a)(n))),
724
(n.setTargetVolume = n.setTargetVolume.bind(Object(m.a)(n))),
725
(n.getNowPlaying = n.getNowPlaying.bind(Object(m.a)(n))),
726
(n.updateVolume = n.updateVolume.bind(Object(m.a)(n))),
727
n
728
);
729
}
730
return (
731
Object(f.a)(a, [
732
{
733
key: "setPlayerInitial",
734
value: function () {
735
var t = this,
736
e = w.a.get($) || this.state.audioConfig.maxVolume;
737
this.setState({ audioConfig: Object(c.a)(Object(c.a)({}, this.state.audioConfig), {}, { maxVolume: e, currentVolume: e }) }, function () {
738
t._player.volume = e;
739
});
740
},
741
},
742
{
743
key: "componentDidMount",
744
value: function () {
745
this.setPlayerInitial(), this.getNowPlaying();
746
},
747
},
748
{
749
key: "setUrl",
750
value: (function () {
751
var t = Object(h.a)(
752
d.a.mark(function t() {
753
var e,
754
a = arguments;
755
return d.a.wrap(
756
function (t) {
757
for (;;)
758
switch ((t.prev = t.next)) {
759
case 0:
760
if ((e = a.length > 0 && void 0 !== a[0] && a[0])) {
761
t.next = 3;
762
break;
763
}
764
return t.abrupt("return");
765
case 3:
766
if (!this.state.playing) {
767
t.next = 6;
768
break;
769
}
770
return (t.next = 6), this.pause();
771
case 6:
772
(this._player.src = e), this.setState({ url: e }), null !== this.state.playing && this.play();
773
case 9:
774
case "end":
775
return t.stop();
776
}
777
},
778
t,
779
this
780
);
781
})
782
);
783
return function () {
784
return t.apply(this, arguments);
785
};
786
})(),
787
},
788
{
789
key: "play",
790
value: function () {
791
var t = this,
792
e = this.state,
793
a = e.mounts,
794
n = e.remotes;
795
e.playing ||
796
(X.running || X.start(),
797
Array.from([].concat(Object(p.a)(a), Object(p.a)(n)), function (t) {
798
return t.url;
799
}).includes(this._player.src) || ((this._player.src = this.state.url), this._player.load()),
800
(this._player.volume = 0),
801
this._player.play().then(function () {
802
t.setState(function (t) {
803
return { audioConfig: Object(c.a)(Object(c.a)({}, t.audioConfig), {}, { currentVolume: 0 }), playing: !0, pullMeta: !0 };
804
}),
805
t.fadeUp();
806
}));
807
},
808
},
809
{
810
key: "pause",
811
value: function () {
812
var t = this;
813
return this.state.playing
814
? new Promise(function (e) {
815
t._player.pause(),
816
t._player.load(),
817
t.setState({ playing: !1, pausing: !1 }, function () {
818
X.stop(), e();
819
});
820
})
821
: Promise.resolve();
822
},
823
},
824
{
825
key: "togglePlay",
826
value: function () {
827
this._player.src && (this.state.playing ? this.fadeDown() : this.play());
828
},
829
},
830
{
831
key: "setTargetVolume",
832
value: function (t) {
833
var e = Object(c.a)({}, this.state.audioConfig),
834
a = parseFloat(Math.max(0, Math.min(1, t).toFixed(2)));
835
(e.maxVolume = a),
836
(e.currentVolume = a),
837
(this._player.volume = e.maxVolume),
838
this.setState({ audioConfig: e }, function () {
839
w.a.set($, a);
840
});
841
},
842
},
843
{
844
key: "fade",
845
value: function (t) {
846
var e = Object(c.a)({}, this.state.audioConfig);
847
(e.targetVolume = "up" === t.toLowerCase() ? this.state.audioConfig.maxVolume : 0), this.setState({ audioConfig: e, pausing: "down" === t }, this.updateVolume);
848
},
849
},
850
{
851
key: "fadeUp",
852
value: function () {
853
this.fade("up");
854
},
855
},
856
{
857
key: "fadeDown",
858
value: function () {
859
this.fade("down");
860
},
861
},
862
{
863
key: "updateVolume",
864
value: function () {
865
if (parseFloat(this._player.volume.toFixed(2)) === this.state.audioConfig.targetVolume || C.isIOS) 0 === this.state.audioConfig.targetVolume && this.state.pausing && this.pause();
866
else {
867
var t = Math.min(this.state.audioConfig.volumeSteps, Math.abs(this.state.audioConfig.targetVolume - this._player.volume)),
868
e = this.state.audioConfig.targetVolume > this._player.volume ? t : -t;
869
this._player.volume += e;
870
var a = this.state.audioConfig;
871
(a.currentVolume += e), this.setState({ audioConfig: a }), setTimeout(this.updateVolume, this.state.audioConfig.volumeTransitionSpeed);
872
}
873
},
874
},
875
{
876
key: "setMountToConnection",
877
value: function () {
878
var t = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : [],
879
e = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : [],
880
a = null;
881
(a =
882
!1 === this.state.fastConnection && e.length > 0
883
? this.getStreamUrl(e, !0)
884
: this.state.fastConnection && e.length > 0
885
? this.getStreamUrl(e)
886
: !1 === this.state.fastConnection
887
? this.getStreamUrl(t, !0)
888
: this.getStreamUrl(t)),
889
(this._player.src = a),
890
this.setState({ url: a });
891
},
892
},
893
{
894
key: "getNowPlaying",
895
value: function () {
896
var t = this;
897
X.on("message", function (e) {
898
var a = JSON.parse(e);
899
"" === t.state.url && (t.setState({ mounts: a.station.mounts, remotes: a.station.remotes }), t.setMountToConnection(a.station.mounts, a.station.remotes)),
900
t.state.listeners !== a.listeners.current && t.setState({ listeners: a.listeners.current }),
901
(a.now_playing.song.id !== t.state.currentSong.id || t.state.pullMeta) &&
902
t.setState({ currentSong: a.now_playing.song, songStartedAt: 1e3 * a.now_playing.played_at, songDuration: a.now_playing.duration, pullMeta: !1, songHistory: a.song_history });
903
}),
904
(X.reconnectTimeout = this.state.config.metadataTimer),
905
X.start();
906
},
907
},
908
{
909
key: "render",
910
value: function () {
911
var t = this;
912
return Object(k.jsx)(O.GlobalHotKeys, {
913
handlers: this.handlers,
914
keyMap: this.keyMap,
915
children: Object(k.jsxs)("div", {
916
className: "App",
917
children: [
918
Object(k.jsx)(_, {}),
919
Object(k.jsx)(I, { fastConnection: this.state.fastConnection, player: this._player, playing: this.state.playing }),
920
Object(k.jsx)("audio", {
921
"aria-label": "audio",
922
crossOrigin: "anonymous",
923
onError: this.onPlayerError,
924
ref: function (e) {
925
return (t._player = e);
926
},
927
children: Object(k.jsx)("track", Object(c.a)({ kind: "captions" }, this.state.captions)),
928
}),
929
Object(k.jsx)(Z, {
930
currentSong: this.state.currentSong,
931
currentVolume: this.state.audioConfig.currentVolume,
932
fastConnection: this.state.fastConnection,
933
listeners: this.state.listeners,
934
mounts: this.state.mounts,
935
playing: this.state.playing,
936
remotes: this.state.remotes,
937
setTargetVolume: this.setTargetVolume,
938
setUrl: this.setUrl,
939
songDuration: this.state.songDuration,
940
songHistory: this.state.songHistory,
941
songStartedAt: this.state.songStartedAt,
942
togglePlay: this.togglePlay,
943
url: this.state.url,
944
}),
945
],
946
}),
947
});
948
},
949
},
950
]),
951
a
952
);
953
})(r.a.Component);
954
o.a({
955
dsn: Object({ NODE_ENV: "production", PUBLIC_URL: "", WDS_SOCKET_HOST: void 0, WDS_SOCKET_PATH: void 0, WDS_SOCKET_PORT: void 0, FAST_REFRESH: !0 }).REACT_APP_SENTRY_DSN,
956
integrations: [new l.a.BrowserTracing()],
957
tracesSampleRate: 1,
958
}),
959
s.a.render(Object(k.jsx)(tt, {}), document.getElementById("root"));
960
},
961
},
962
[[89, 1, 2]],
963
]);
964
965