-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
769 lines (683 loc) · 54.8 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
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>μ</title>
<link href='https://fonts.googleapis.com/css?family=Open+Sans' rel='stylesheet' type='text/css'>
<style>
body {
margin-bottom: 2.5em;
margin-top: 2.25em;
background: #313C47;
color: white;
font-family: "Open Sans", sans-serif;
overflow-x: hidden;
}
.ulFolder:hover {
background: rgba(255, 175, 34, 0.8);
}
.ulFolder {
transition: background 0.25s ease;
z-index: 50;
padding: 0.1em 0.45em;
top: 0.1em;
right: 0.1em;
margin: 0.2em;
margin-right: 0.5em;
border-radius: 2px;
box-shadow: 0 0 2px 0 black;
background: rgba(46, 130, 209, 0.5);
cursor: pointer;
display: inline-block;
position: absolute;
right: 0;
}
.ulFolder input {
position: fixed;
top: -1000px;
}
p.playing:hover {
background: #8bd85f;
}
body .loader {
display: none;
position: fixed;
top: 0;
bottom: 0;
left: 0;
right: 0;
background-image: url(data:image/gif;base64,R0lGODlhKAAoAIABAH2u3v///yH/C05FVFNDQVBFMi4wAwEAAAAh/…RomCYaqCXrnmgMaHQa23m7Yzfv0gVnvdDv59shL8ciaPl0fqBTqYfKymq33K73Cw6LvwUAOw==);
background-repeat: no-repeat;
background-color: rgba(0,0,0,0.5);
background-position: center center;
}
body.loading .loader {
display: block;
}
.spectrumOverlay {
content: "";
box-shadow: 0em -0.6em 0.471em 0em #313c47 inset;
z-index: 2;
margin: -0.5em;
top: 0;
left: 0;
right:0;
bottom: 0;
position: absolute;
}
.header {
overflow: hidden;
box-shadow: 0 0 0.471em 0 #313c47;
background: #313C47;
text-align: center;
position: fixed;
height: 2em;
left: 0;
right: 0;
top: 0;
}
.spectrum {
opacity: 1;
position: absolute;
height: 100%;
width: 100%;
z-index: -5;
margin: 0 auto;
left: 0;
right: 0;
}
p:hover {
background: #FFAF22;
}
p.playing {
background: #39cdee;
padding: 0.5em;
}
p {
cursor: pointer;
word-wrap: break-word;
transition: background 0.25s ease, padding 0.25s ease;
text-shadow: 0 0 0.471em black;
border-radius: 1px;
background: #2e82d1;
box-shadow: 0 0 0.1em 0 black;
margin: 0.25em 0;
padding: 0.25em;
}
.nowPlaying {
margin: 0.35em;
display: inline-block;
z-index: 20;
text-shadow: 0 0 0.3em black, 0 0 0.5em black;
}
.nowPlaying .fa {
animation: pulse;
animation-duration: 0.75s;
animation-iteration-count: infinite;
position: relative;
animation-timing-function: cubic-bezier(0.51, 0.26, 0.56, 1.05);
animation-direction: alternate;
}
@keyframes pulse {
from {
transform: translateX(0em);
}
to {
transform: translateX(0.1em)
}
}
input {
margin: 0.1em;
margin-bottom: 0.25em
}
audio {
vertical-align: middle;
}
/* custom audio player styles begin */
.audioPlayer,
.audioPlayer span,
.msPlayer,
.msPlayer * {
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
.audioPlayer {
box-shadow: 0 0 0.471em 0 #313c47;
position: fixed;
bottom: 0;
left: 0;
width: 100%;
background: #A3AEB7;
height: 2em;
text-align: center;
font-family: "Open Sans", sans-serif;
cursor: pointer;
margin-top: 0.25em;
overflow: hidden;
}
.audioPlayer .button {
width: 2em;
height: 100%;
background: #313C47;
position: absolute;
}
.playPause {
left: 0em;
}
.prevButton, .nextButton {
color: #2E82D1;
transition: color ease 0.25s;
}
.prevButton .fa, .nextButton .fa {
top: 0.339em;
font-size: 1.2em;
display: inline-block;
text-align: center;
position: relative;
}
.prevButton:hover, .nextButton:hover {
color: #FFAF22;
}
.prevButton {
left: 2em;
}
.nextButton {
left: 4em;
}
.audioPlayer .elapsedTime {
margin-left: 0.5em;
margin-right: 0.5em;
color: white;
text-align: center;
position: relative;
font-size: 1em;
display: inline-block;
top: 50%;
transform: translateY(-50%);
}
.audioPlayer .fileLength {
color: white;
position: relative;
font-size: 1em;
display: inline-block;
top: 50%;
transform: translateY(-50%);
margin-right: 0.5em;
}
.audioPlayer .playPause .icon {
top: 0.5em;
left: 0.5em;
position: relative;
height: 1em;
width: 1em;
transform: rotate(0deg);
transition: transform ease 0.5s;
}
.audioPlayer.paused .playPause .icon {
top: 0.5em;
left: 0.5em;
position: relative;
height: 1em;
width: 1em;
transform: rotate(90deg);
}
.audioPlayer .playPause .icon .top,
.audioPlayer .playPause .icon .bottom {
transition: transform ease 0.5s, background ease 0.25s;
background: #2E82D1;
}
.audioPlayer .playPause:hover .icon .top,
.audioPlayer .playPause:hover .icon .bottom {
background: #FFAF22;
}
.audioPlayer.paused .playPause .icon .top,
.audioPlayer.paused .playPause .icon .bottom {
border-top-left-radius: 5em;
border-top-right-radius: 5em;
border-bottom-left-radius: 5em;
border-bottom-right-radius: 5em;
}
.audioPlayer .playPause .icon .top {
position: absolute;
margin: auto;
width: auto;
height: auto;
left: 0;
top: 0;
bottom: 0;
right: 70%;
}
.audioPlayer .playPause .icon .bottom {
position: absolute;
margin: auto;
width: auto;
height: auto;
left: 70%;
top: 0;
bottom: 0;
right: 0;
}
.audioPlayer.paused .playPause .icon .top {
position: absolute;
margin: auto;
width: auto;
height: auto;
left: 0;
top: 0;
bottom: 0;
right: 70%;
transform: rotate(23deg);
transform-origin: 100% 100%;
}
.audioPlayer.paused .playPause .icon .bottom {
position: absolute;
margin: auto;
width: auto;
height: auto;
left: 70%;
top: 0;
bottom: 0;
right: 0;
transform: rotate(-23deg);
transform-origin: 0% 100%;
}
.audioPlayer .volume.bar {
top: 0;
left: 81%;
right: 0;
height: 100%;
position: absolute;
background: #313C47;
overflow: hidden;
}
.audioPlayer .bar .stateIndicator {
width: 0%;
position: absolute;
left: 0;
background: #2E82D1;
height: 100%;
text-align: center;
transition: width 0.25s ease;
}
.audioPlayer .bar:hover .seekIndicator {
display: block;
}
.audioPlayer .bar .seekIndicator {
display: none;
width: 2px;
position: absolute;
left: 0;
background: gray;
height: 100%;
text-align: center;
}
.audioPlayer .volume.bar .fa {
color: #FFFFFF;
position: absolute;
top: 0.5em;
font-size: 1em;
display: block;
width: 100%;
z-index: 5;
}
.audioPlayer .bar:hover .stateIndicator {
background: #FFAF22;
}
.audioPlayer .progress.bar {
top: 0;
left: 6em;
right: 20%;
height: 100%;
position: absolute;
background: #313C47;
text-align: right;
overflow: hidden;
}
/* custom audio player styles end */
</style>
</head>
<body>
<link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<div class="header"><div class="spectrumOverlay"></div>
<canvas class="spectrum" width="600" height="100"></canvas><span class="nowPlaying">Welcome to μ! Please set music directory <i class="fa fa-arrow-right" aria-hidden="true"></i></span><label class="ulFolder"><input type="file" id="input" webkitdirectory directory multiple><i class="fa fa-folder-open" aria-hidden="true"></i></label></div>
<audio controls></audio>
<div class="loader"></div>
<script>(function(v){"object"===typeof exports&&"undefined"!==typeof module?module.exports=v():"function"===typeof define&&define.amd?define([],v):("undefined"!==typeof window?window:"undefined"!==typeof global?global:"undefined"!==typeof self?self:this).jsmediatags=v()})(function(){return function f(h,m,k){function l(b,a){if(!m[b]){if(!h[b]){var e="function"==typeof require&&require;if(!a&&e)return e(b,!0);if(d)return d(b,!0);e=Error("Cannot find module '"+b+"'");throw e.code="MODULE_NOT_FOUND",e;}e=m[b]=
{exports:{}};h[b][0].call(e.exports,function(a){var e=h[b][1][a];return l(e?e:a)},e,e.exports,f,h,m,k)}return m[b].exports}for(var d="function"==typeof require&&require,c=0;c<k.length;c++)l(k[c]);return l}({1:[function(f,h,m){},{}],2:[function(f,h,m){h.exports=XMLHttpRequest},{}],3:[function(f,h,m){function k(d,c){if("function"!==typeof c&&null!==c)throw new TypeError("Super expression must either be null or a function, not "+typeof c);d.prototype=Object.create(c&&c.prototype,{constructor:{value:d,
enumerable:!1,writable:!0,configurable:!0}});c&&(Object.setPrototypeOf?Object.setPrototypeOf(d,c):d.__proto__=c)}var l=function(){function d(c,b){for(var a=0;a<b.length;a++){var e=b[a];e.enumerable=e.enumerable||!1;e.configurable=!0;"value"in e&&(e.writable=!0);Object.defineProperty(c,e.key,e)}}return function(c,b,a){b&&d(c.prototype,b);a&&d(c,a);return c}}();f=function(d){function c(b){if(!(this instanceof c))throw new TypeError("Cannot call a class as a function");var a;a=Object.getPrototypeOf(c).call(this);
if(!this)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");a=!a||"object"!==typeof a&&"function"!==typeof a?this:a;a._array=b;a._size=b.length;a._isInitialized=!0;return a}k(c,d);l(c,[{key:"init",value:function(b){setTimeout(b.onSuccess,0)}},{key:"loadRange",value:function(b,a){setTimeout(a.onSuccess,0)}},{key:"getByteAt",value:function(b){return this._array[b]}}],[{key:"canReadFile",value:function(b){return Array.isArray(b)||"function"===typeof Buffer&&Buffer.isBuffer(b)}}]);
return c}(f("./MediaFileReader"));h.exports=f},{"./MediaFileReader":10}],4:[function(f,h,m){function k(c,b){if("function"!==typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function, not "+typeof b);c.prototype=Object.create(b&&b.prototype,{constructor:{value:c,enumerable:!1,writable:!0,configurable:!0}});b&&(Object.setPrototypeOf?Object.setPrototypeOf(c,b):c.__proto__=b)}var l=function(){function c(b,a){for(var e=0;e<a.length;e++){var g=a[e];g.enumerable=g.enumerable||
!1;g.configurable=!0;"value"in g&&(g.writable=!0);Object.defineProperty(b,g.key,g)}}return function(b,a,e){a&&c(b.prototype,a);e&&c(b,e);return b}}(),d=f("./ChunkedFileData");f=function(c){function b(a){if(!(this instanceof b))throw new TypeError("Cannot call a class as a function");var e;e=Object.getPrototypeOf(b).call(this);if(!this)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");e=!e||"object"!==typeof e&&"function"!==typeof e?this:e;e._blob=a;e._fileData=
new d;return e}k(b,c);l(b,[{key:"_init",value:function(a){this._size=this._blob.size;setTimeout(a.onSuccess,1)}},{key:"loadRange",value:function(a,b){var g=this,c=(this._blob.slice||this._blob.mozSlice||this._blob.webkitSlice).call(this._blob,a[0],a[1]+1),d=new FileReader;d.onloadend=function(c){c=new Uint8Array(d.result);g._fileData.addData(a[0],c);b.onSuccess()};d.onerror=d.onabort=function(a){if(b.onError)b.onError({type:"blob",info:d.error})};d.readAsArrayBuffer(c)}},{key:"getByteAt",value:function(a){return this._fileData.getByteAt(a)}}],
[{key:"canReadFile",value:function(a){return"undefined"!==typeof Blob&&a instanceof Blob||"undefined"!==typeof File&&a instanceof File}}]);return b}(f("./MediaFileReader"));h.exports=f},{"./ChunkedFileData":5,"./MediaFileReader":10}],5:[function(f,h,m){var k=function(){function f(d,c){for(var b=0;b<c.length;b++){var a=c[b];a.enumerable=a.enumerable||!1;a.configurable=!0;"value"in a&&(a.writable=!0);Object.defineProperty(d,a.key,a)}}return function(d,c,b){c&&f(d.prototype,c);b&&f(d,b);return d}}();
f=function(){function f(){if(!(this instanceof f))throw new TypeError("Cannot call a class as a function");this._fileData=[]}k(f,null,[{key:"NOT_FOUND",get:function(){return-1}}]);k(f,[{key:"addData",value:function(d,c){var b=d+c.length-1,a=this._getChunkRange(d,b);if(-1===a.startIx)this._fileData.splice(a.insertIx||0,0,{offset:d,data:c});else{var e=this._fileData[a.startIx],g=this._fileData[a.endIx],b=b<g.offset+g.data.length-1,p={offset:Math.min(d,e.offset),data:c};d>e.offset&&(e=this._sliceData(e.data,
0,d-e.offset),p.data=this._concatData(e,c));b&&(e=this._sliceData(p.data,0,g.offset-p.offset),p.data=this._concatData(e,g.data));this._fileData.splice(a.startIx,a.endIx-a.startIx+1,p)}}},{key:"_concatData",value:function(d,c){if("undefined"!==typeof ArrayBuffer&&ArrayBuffer.isView(d)){var b=new d.constructor(d.length+c.length);b.set(d,0);b.set(c,d.length);return b}return d.concat(c)}},{key:"_sliceData",value:function(d,c,b){return d.slice?d.slice(c,b):d.subarray(c,b)}},{key:"_getChunkRange",value:function(d,
c){for(var b=-1,a=-1,e=0,g=0;g<this._fileData.length;g++,e=g){var p=this._fileData[g].offset,q=p+this._fileData[g].data.length;if(c<p-1)break;if(d<=q+1&&c>=p-1){b=g;break}}if(-1===b)return{startIx:-1,endIx:-1,insertIx:e};for(g=b;g<this._fileData.length&&!(p=this._fileData[g].offset,q=p+this._fileData[g].data.length,c>=p-1&&(a=g),c<=q+1);g++);-1===a&&(a=b);return{startIx:b,endIx:a}}},{key:"hasDataRange",value:function(d,c){for(var b=0;b<this._fileData.length;b++){var a=this._fileData[b];if(c<a.offset)break;
if(d>=a.offset&&c<a.offset+a.data.length)return!0}return!1}},{key:"getByteAt",value:function(d){for(var c,b=0;b<this._fileData.length;b++){var a=this._fileData[b].offset,e=a+this._fileData[b].data.length-1;if(d>=a&&d<=e){c=this._fileData[b];break}}if(c)return c.data[d-c.offset];throw Error("Offset "+d+" hasn't been loaded yet.");}}]);return f}();h.exports=f},{}],6:[function(f,h,m){function k(c,b){if("function"!==typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function, not "+
typeof b);c.prototype=Object.create(b&&b.prototype,{constructor:{value:c,enumerable:!1,writable:!0,configurable:!0}});b&&(Object.setPrototypeOf?Object.setPrototypeOf(c,b):c.__proto__=b)}var l=function(){function c(b,a){for(var e=0;e<a.length;e++){var g=a[e];g.enumerable=g.enumerable||!1;g.configurable=!0;"value"in g&&(g.writable=!0);Object.defineProperty(b,g.key,g)}}return function(b,a,e){a&&c(b.prototype,a);e&&c(b,e);return b}}();m=f("./MediaTagReader");f("./MediaFileReader");f=function(c){function b(){if(!(this instanceof
b))throw new TypeError("Cannot call a class as a function");var a=Object.getPrototypeOf(b).apply(this,arguments);if(!this)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!a||"object"!==typeof a&&"function"!==typeof a?this:a}k(b,c);l(b,[{key:"_loadData",value:function(a,b){var g=a.getSize();a.loadRange([g-128,g-1],b)}},{key:"_parseData",value:function(a,b){var g=a.getSize()-128,c=a.getStringWithCharsetAt(g+3,30).toString(),q=a.getStringWithCharsetAt(g+33,
30).toString(),r=a.getStringWithCharsetAt(g+63,30).toString(),f=a.getStringWithCharsetAt(g+93,4).toString(),u=a.getByteAt(g+97+28),n=a.getByteAt(g+97+29);if(0==u&&0!=n)var u="1.1",x=a.getStringWithCharsetAt(g+97,28).toString();else u="1.0",x=a.getStringWithCharsetAt(g+97,30).toString(),n=0;g=a.getByteAt(g+97+30);c={type:"ID3",version:u,tags:{title:c,artist:q,album:r,year:f,comment:x,genre:255>g?d[g]:""}};n&&(c.tags.track=n);return c}}],[{key:"getTagIdentifierByteRange",value:function(){return{offset:-128,
length:128}}},{key:"canReadTagFormat",value:function(a){return"TAG"===String.fromCharCode.apply(String,a.slice(0,3))}}]);return b}(m);var d="Blues;Classic Rock;Country;Dance;Disco;Funk;Grunge;Hip-Hop;Jazz;Metal;New Age;Oldies;Other;Pop;R&B;Rap;Reggae;Rock;Techno;Industrial;Alternative;Ska;Death Metal;Pranks;Soundtrack;Euro-Techno;Ambient;Trip-Hop;Vocal;Jazz+Funk;Fusion;Trance;Classical;Instrumental;Acid;House;Game;Sound Clip;Gospel;Noise;AlternRock;Bass;Soul;Punk;Space;Meditative;Instrumental Pop;Instrumental Rock;Ethnic;Gothic;Darkwave;Techno-Industrial;Electronic;Pop-Folk;Eurodance;Dream;Southern Rock;Comedy;Cult;Gangsta;Top 40;Christian Rap;Pop/Funk;Jungle;Native American;Cabaret;New Wave;Psychadelic;Rave;Showtunes;Trailer;Lo-Fi;Tribal;Acid Punk;Acid Jazz;Polka;Retro;Musical;Rock & Roll;Hard Rock;Folk;Folk-Rock;National Folk;Swing;Fast Fusion;Bebob;Latin;Revival;Celtic;Bluegrass;Avantgarde;Gothic Rock;Progressive Rock;Psychedelic Rock;Symphonic Rock;Slow Rock;Big Band;Chorus;Easy Listening;Acoustic;Humour;Speech;Chanson;Opera;Chamber Music;Sonata;Symphony;Booty Bass;Primus;Porn Groove;Satire;Slow Jam;Club;Tango;Samba;Folklore;Ballad;Power Ballad;Rhythmic Soul;Freestyle;Duet;Punk Rock;Drum Solo;Acapella;Euro-House;Dance Hall".split(";");
h.exports=f},{"./MediaFileReader":10,"./MediaTagReader":11}],7:[function(f,h,m){function k(b){var a;switch(b){case 0:a="iso-8859-1";break;case 1:a="utf-16";break;case 2:a="utf-16be";break;case 3:a="utf-8"}return a}function l(b,a,e,g){g=e.getStringWithCharsetAt(b+1,a-1,g);b=e.getStringWithCharsetAt(b+1+g.bytesReadCount,a-1-g.bytesReadCount);return{user_description:g.toString(),data:b.toString()}}f("./MediaFileReader");var d={APIC:function(b,a,e,g,p){p=p||"3";g=b;var d=k(e.getByteAt(b));switch(p){case "2":p=
e.getStringAt(b+1,3);b+=4;break;case "3":case "4":p=e.getStringWithCharsetAt(b+1,a-1);b+=1+p.bytesReadCount;break;default:throw Error("Couldn't read ID3v2 major version.");}var r=e.getByteAt(b,1),r=c[r],d=e.getStringWithCharsetAt(b+1,a-(b-g)-1,d);b+=1+d.bytesReadCount;return{format:p.toString(),type:r,description:d.toString(),data:e.getBytesAt(b,g+a-b)}},COMM:function(b,a,e,g,c){var d=b,r=k(e.getByteAt(b));g=e.getStringAt(b+1,3);c=e.getStringWithCharsetAt(b+4,a-4,r);b+=4+c.bytesReadCount;b=e.getStringWithCharsetAt(b,
d+a-b,r);return{language:g,short_description:c.toString(),text:b.toString()}}};d.COM=d.COMM;d.PIC=function(b,a,e,g,c){return d.APIC(b,a,e,g,"2")};d.PCNT=function(b,a,e,g,c){return e.getLongAt(b,!1)};d.CNT=d.PCNT;d["T*"]=function(b,a,e,g,c){g=k(e.getByteAt(b));return e.getStringWithCharsetAt(b+1,a-1,g).toString()};d.TXXX=function(b,a,e,g,c){g=k(e.getByteAt(b));return l(b,a,e,g)};d["W*"]=function(b,a,e,g,c){g=k(e.getByteAt(b));return void 0!==g?l(b,a,e,g):e.getStringWithCharsetAt(b,a,g).toString()};
d.TCON=function(b,a,e,g){return d["T*"].apply(this,arguments).replace(/^\(\d+\)/,"")};d.TCO=d.TCON;d.USLT=function(b,a,e,g,c){var d=b,r=k(e.getByteAt(b));g=e.getStringAt(b+1,3);c=e.getStringWithCharsetAt(b+4,a-4,r);b+=4+c.bytesReadCount;b=e.getStringWithCharsetAt(b,d+a-b,r);return{language:g,descriptor:c.toString(),lyrics:b.toString()}};d.ULT=d.USLT;var c="Other;32x32 pixels 'file icon' (PNG only);Other file icon;Cover (front);Cover (back);Leaflet page;Media (e.g. label side of CD);Lead artist/lead performer/soloist;Artist/performer;Conductor;Band/Orchestra;Composer;Lyricist/text writer;Recording Location;During recording;During performance;Movie/video screen capture;A bright coloured fish;Illustration;Band/artist logotype;Publisher/Studio logotype".split(";");
h.exports={getFrameReaderFunction:function(b){return b in d?d[b]:"T"===b[0]?d["T*"]:"W"===b[0]?d["W*"]:null}}},{"./MediaFileReader":10}],8:[function(f,h,m){function k(a,b){if("function"!==typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function, not "+typeof b);a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});b&&(Object.setPrototypeOf?Object.setPrototypeOf(a,b):a.__proto__=b)}var l=function(){function a(b,
e){for(var c=0;c<e.length;c++){var d=e[c];d.enumerable=d.enumerable||!1;d.configurable=!0;"value"in d&&(d.writable=!0);Object.defineProperty(b,d.key,d)}}return function(b,c,d){c&&a(b.prototype,c);d&&a(b,d);return b}}();m=f("./MediaTagReader");f("./MediaFileReader");var d=f("./ArrayFileReader"),c=f("./ID3v2FrameReader");f=function(e){function g(){if(!(this instanceof g))throw new TypeError("Cannot call a class as a function");var a=Object.getPrototypeOf(g).apply(this,arguments);if(!this)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
return!a||"object"!==typeof a&&"function"!==typeof a?this:a}k(g,e);l(g,[{key:"_loadData",value:function(a,b){a.loadRange([6,9],{onSuccess:function(){a.loadRange([0,10+a.getSynchsafeInteger32At(6)-1],b)},onError:b.onError})}},{key:"_parseData",value:function(b,e){var c=0,g=b.getByteAt(c+3);if(4<g)return{type:"ID3",version:">2.4",tags:{}};var d=b.getByteAt(c+4),n=b.isBitSetAt(c+5,7),f=b.isBitSetAt(c+5,6),l=b.isBitSetAt(c+5,5),t=b.getSynchsafeInteger32At(c+6),c=c+10;if(f)var k=b.getLongAt(c,!0),c=c+
(k+4);var g={type:"ID3",version:"2."+g+"."+d,major:g,revision:d,flags:{unsynchronisation:n,extended_header:f,experimental_indicator:l,footer_present:!1},size:t,tags:{}},c=this._readFrames(c,t+10,b,g,e),h;for(h in a)a.hasOwnProperty(h)&&(t=this._getFrameData(c,a[h]))&&(g.tags[h]=t);for(var m in c)c.hasOwnProperty(m)&&(g.tags[m]=c[m]);return g}},{key:"_getUnsyncFileReader",value:function(a,b,c){a=a.getBytesAt(b,c);for(b=0;b<a.length-1;b++)255===a[b]&&0===a[b+1]&&a.splice(b+1,1);return new d(a)}},{key:"_readFrames",
value:function(a,b,e,g,d){var n={};for(d&&(d=this._expandShortcutTags(d));a<b;){var f=this._readFrameHeader(e,a,g),l=f.id;if(!l)break;var t=f.flags,h=f.size,k=a+f.headerSize,m=e;a+=f.headerSize+f.size;if(!d||-1!==d.indexOf(l)){if(g.flags.unsynchronisation||t&&t.format.unsynchronisation)m=this._getUnsyncFileReader(m,k,h),k=0,h=m.getSize();t&&t.format.data_length_indicator&&(k+=4,h-=4);t=(f=c.getFrameReaderFunction(l))?f(k,h,m,t):null;k=this._getFrameDescription(l);h={id:l,size:h,description:k,data:t};
l in n?(n[l].id&&(n[l]=[n[l]]),n[l].push(h)):n[l]=h}}return n}},{key:"_readFrameHeader",value:function(a,b,c){c=c.major;var e=null;switch(c){case 2:var g=a.getStringAt(b,3),d=a.getInteger24At(b+3,!0),f=6;break;case 3:g=a.getStringAt(b,4);d=a.getLongAt(b+4,!0);f=10;break;case 4:g=a.getStringAt(b,4),d=a.getSynchsafeInteger32At(b+4),f=10}if(g==String.fromCharCode(0,0,0)||g==String.fromCharCode(0,0,0,0))g="";g&&2<c&&(e=this._readFrameFlags(a,b+8));return{id:g||"",size:d||0,headerSize:f||0,flags:e}}},
{key:"_readFrameFlags",value:function(a,b){return{message:{tag_alter_preservation:a.isBitSetAt(b,6),file_alter_preservation:a.isBitSetAt(b,5),read_only:a.isBitSetAt(b,4)},format:{grouping_identity:a.isBitSetAt(b+1,7),compression:a.isBitSetAt(b+1,3),encryption:a.isBitSetAt(b+1,2),unsynchronisation:a.isBitSetAt(b+1,1),data_length_indicator:a.isBitSetAt(b+1,0)}}}},{key:"_getFrameData",value:function(a,b){for(var c=0,e;e=b[c];c++)if(e in a)return a[e].data}},{key:"_getFrameDescription",value:function(a){return a in
b?b[a]:"Unknown"}},{key:"getShortcuts",value:function(){return a}}],[{key:"getTagIdentifierByteRange",value:function(){return{offset:0,length:10}}},{key:"canReadTagFormat",value:function(a){return"ID3"===String.fromCharCode.apply(String,a.slice(0,3))}}]);return g}(m);var b={BUF:"Recommended buffer size",CNT:"Play counter",COM:"Comments",CRA:"Audio encryption",CRM:"Encrypted meta frame",ETC:"Event timing codes",EQU:"Equalization",GEO:"General encapsulated object",IPL:"Involved people list",LNK:"Linked information",
MCI:"Music CD Identifier",MLL:"MPEG location lookup table",PIC:"Attached picture",POP:"Popularimeter",REV:"Reverb",RVA:"Relative volume adjustment",SLT:"Synchronized lyric/text",STC:"Synced tempo codes",TAL:"Album/Movie/Show title",TBP:"BPM (Beats Per Minute)",TCM:"Composer",TCO:"Content type",TCR:"Copyright message",TDA:"Date",TDY:"Playlist delay",TEN:"Encoded by",TFT:"File type",TIM:"Time",TKE:"Initial key",TLA:"Language(s)",TLE:"Length",TMT:"Media type",TOA:"Original artist(s)/performer(s)",TOF:"Original filename",
TOL:"Original Lyricist(s)/text writer(s)",TOR:"Original release year",TOT:"Original album/Movie/Show title",TP1:"Lead artist(s)/Lead performer(s)/Soloist(s)/Performing group",TP2:"Band/Orchestra/Accompaniment",TP3:"Conductor/Performer refinement",TP4:"Interpreted, remixed, or otherwise modified by",TPA:"Part of a set",TPB:"Publisher",TRC:"ISRC (International Standard Recording Code)",TRD:"Recording dates",TRK:"Track number/Position in set",TSI:"Size",TSS:"Software/hardware and settings used for encoding",
TT1:"Content group description",TT2:"Title/Songname/Content description",TT3:"Subtitle/Description refinement",TXT:"Lyricist/text writer",TXX:"User defined text information frame",TYE:"Year",UFI:"Unique file identifier",ULT:"Unsychronized lyric/text transcription",WAF:"Official audio file webpage",WAR:"Official artist/performer webpage",WAS:"Official audio source webpage",WCM:"Commercial information",WCP:"Copyright/Legal information",WPB:"Publishers official webpage",WXX:"User defined URL link frame",
AENC:"Audio encryption",APIC:"Attached picture",ASPI:"Audio seek point index",COMM:"Comments",COMR:"Commercial frame",ENCR:"Encryption method registration",EQU2:"Equalisation (2)",EQUA:"Equalization",ETCO:"Event timing codes",GEOB:"General encapsulated object",GRID:"Group identification registration",IPLS:"Involved people list",LINK:"Linked information",MCDI:"Music CD identifier",MLLT:"MPEG location lookup table",OWNE:"Ownership frame",PRIV:"Private frame",PCNT:"Play counter",POPM:"Popularimeter",
POSS:"Position synchronisation frame",RBUF:"Recommended buffer size",RVA2:"Relative volume adjustment (2)",RVAD:"Relative volume adjustment",RVRB:"Reverb",SEEK:"Seek frame",SYLT:"Synchronized lyric/text",SYTC:"Synchronized tempo codes",TALB:"Album/Movie/Show title",TBPM:"BPM (beats per minute)",TCOM:"Composer",TCON:"Content type",TCOP:"Copyright message",TDAT:"Date",TDLY:"Playlist delay",TDRC:"Recording time",TDRL:"Release time",TDTG:"Tagging time",TENC:"Encoded by",TEXT:"Lyricist/Text writer",TFLT:"File type",
TIME:"Time",TIPL:"Involved people list",TIT1:"Content group description",TIT2:"Title/songname/content description",TIT3:"Subtitle/Description refinement",TKEY:"Initial key",TLAN:"Language(s)",TLEN:"Length",TMCL:"Musician credits list",TMED:"Media type",TMOO:"Mood",TOAL:"Original album/movie/show title",TOFN:"Original filename",TOLY:"Original lyricist(s)/text writer(s)",TOPE:"Original artist(s)/performer(s)",TORY:"Original release year",TOWN:"File owner/licensee",TPE1:"Lead performer(s)/Soloist(s)",
TPE2:"Band/orchestra/accompaniment",TPE3:"Conductor/performer refinement",TPE4:"Interpreted, remixed, or otherwise modified by",TPOS:"Part of a set",TPRO:"Produced notice",TPUB:"Publisher",TRCK:"Track number/Position in set",TRDA:"Recording dates",TRSN:"Internet radio station name",TRSO:"Internet radio station owner",TSOA:"Album sort order",TSOP:"Performer sort order",TSOT:"Title sort order",TSIZ:"Size",TSRC:"ISRC (international standard recording code)",TSSE:"Software/Hardware and settings used for encoding",
TSST:"Set subtitle",TYER:"Year",TXXX:"User defined text information frame",UFID:"Unique file identifier",USER:"Terms of use",USLT:"Unsychronized lyric/text transcription",WCOM:"Commercial information",WCOP:"Copyright/Legal information",WOAF:"Official audio file webpage",WOAR:"Official artist/performer webpage",WOAS:"Official audio source webpage",WORS:"Official internet radio station homepage",WPAY:"Payment",WPUB:"Publishers official webpage",WXXX:"User defined URL link frame"},a={title:["TIT2","TT2"],
artist:["TPE1","TP1"],album:["TALB","TAL"],year:["TYER","TYE"],comment:["COMM","COM"],track:["TRCK","TRK"],genre:["TCON","TCO"],picture:["APIC","PIC"],lyrics:["USLT","ULT"]};h.exports=f},{"./ArrayFileReader":3,"./ID3v2FrameReader":7,"./MediaFileReader":10,"./MediaTagReader":11}],9:[function(f,h,m){function k(a,b){if("function"!==typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function, not "+typeof b);a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,
enumerable:!1,writable:!0,configurable:!0}});b&&(Object.setPrototypeOf?Object.setPrototypeOf(a,b):a.__proto__=b)}var l=function(){function a(a,b){for(var c=0;c<b.length;c++){var d=b[c];d.enumerable=d.enumerable||!1;d.configurable=!0;"value"in d&&(d.writable=!0);Object.defineProperty(a,d.key,d)}}return function(b,c,d){c&&a(b.prototype,c);d&&a(b,d);return b}}();m=f("./MediaTagReader");f("./MediaFileReader");f=function(a){function e(){if(!(this instanceof e))throw new TypeError("Cannot call a class as a function");
var a=Object.getPrototypeOf(e).apply(this,arguments);if(!this)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!a||"object"!==typeof a&&"function"!==typeof a?this:a}k(e,a);l(e,[{key:"_loadData",value:function(a,b){var c=this;a.loadRange([0,16],{onSuccess:function(){c._loadAtom(a,0,"",b)},onError:b.onError})}},{key:"_loadAtom",value:function(a,b,c,e){if(b>=a.getSize())e.onSuccess();else{var d=this,f=a.getLongAt(b,!0);if(0==f||isNaN(f))e.onSuccess();else{var n=
a.getStringAt(b+4,4);if(this._isContainerAtom(n)){"meta"==n&&(b+=4);var l=(c?c+".":"")+n;"moov.udta.meta.ilst"===l?a.loadRange([b,b+f],e):a.loadRange([b+8,b+8+8],{onSuccess:function(){d._loadAtom(a,b+8,l,e)},onError:e.onError})}else a.loadRange([b+f,b+f+8],{onSuccess:function(){d._loadAtom(a,b+f,c,e)},onError:e.onError})}}}},{key:"_isContainerAtom",value:function(a){return 0<=["moov","udta","meta","ilst"].indexOf(a)}},{key:"_canReadAtom",value:function(a){return"----"!==a}},{key:"_parseData",value:function(a,
c){var e={};c=this._expandShortcutTags(c);this._readAtom(e,a,0,a.getSize(),c);for(var d in b)if(b.hasOwnProperty(d)){var f=e[b[d]];f&&(e[d]="track"===d?f.data.track:f.data)}return{type:"MP4",ftyp:a.getStringAt(8,4),version:a.getLongAt(12,!0),tags:e}}},{key:"_readAtom",value:function(a,b,c,e,d,f,n){n=void 0===n?"":n+" ";for(var l=c;l<c+e;){var h=b.getLongAt(l,!0);if(0==h)break;var k=b.getStringAt(l+4,4);if(this._isContainerAtom(k)){"meta"==k&&(l+=4);this._readAtom(a,b,l+8,h-8,d,(f?f+".":"")+k,n);
break}(!d||0<=d.indexOf(k))&&"moov.udta.meta.ilst"===f&&this._canReadAtom(k)&&(a[k]=this._readMetadataAtom(b,l));l+=h}}},{key:"_readMetadataAtom",value:function(a,b){var e=a.getLongAt(b,!0),f=a.getStringAt(b+4,4),l=a.getInteger24At(b+16+1,!0),l=d[l],k;if("trkn"==f)k={track:a.getByteAt(b+16+11),total:a.getByteAt(b+16+13)};else{var n=b+24,h=e-24;"covr"===f&&"uint8"===l&&(l="jpeg");switch(l){case "text":k=a.getStringWithCharsetAt(n,h,"utf-8").toString();break;case "uint8":k=a.getShortAt(n,!1);break;
case "int":case "uint":k=("int"==l?1==h?a.getSByteAt:2==h?a.getSShortAt:4==h?a.getSLongAt:a.getLongAt:1==h?a.getByteAt:2==h?a.getShortAt:a.getLongAt).call(a,n+(8==h?4:0),!0);break;case "jpeg":case "png":k={format:"image/"+l,data:a.getBytesAt(n,h)}}}return{id:f,size:e,description:c[f]||"Unknown",data:k}}},{key:"getShortcuts",value:function(){return b}}],[{key:"getTagIdentifierByteRange",value:function(){return{offset:0,length:16}}},{key:"canReadTagFormat",value:function(a){return"ftyp"===String.fromCharCode.apply(String,
a.slice(4,8))}}]);return e}(m);var d={0:"uint8",1:"text",13:"jpeg",14:"png",21:"int",22:"uint"},c={"\u00a9alb":"Album","\u00a9ART":"Artist",aART:"Album Artist","\u00a9day":"Release Date","\u00a9nam":"Title","\u00a9gen":"Genre",gnre:"Genre",trkn:"Track Number","\u00a9wrt":"Composer","\u00a9too":"Encoding Tool","\u00a9enc":"Encoded By",cprt:"Copyright",covr:"Cover Art","\u00a9grp":"Grouping",keyw:"Keywords","\u00a9lyr":"Lyrics","\u00a9cmt":"Comment",tmpo:"Tempo",cpil:"Compilation",disk:"Disc Number",
tvsh:"TV Show Name",tven:"TV Episode ID",tvsn:"TV Season",tves:"TV Episode",tvnn:"TV Network",desc:"Description",ldes:"Long Description",sonm:"Sort Name",soar:"Sort Artist",soaa:"Sort Album",soco:"Sort Composer",sosn:"Sort Show",purd:"Purchase Date",pcst:"Podcast",purl:"Podcast URL",catg:"Category",hdvd:"HD Video",stik:"Media Type",rtng:"Content Rating",pgap:"Gapless Playback",apID:"Purchase Account",sfID:"Country Code",atID:"Artist ID",cnID:"Catalog ID",plID:"Collection ID",geID:"Genre ID","xid ":"Vendor Information",
flvr:"Codec Flavor"},b={title:"\u00a9nam",artist:"\u00a9ART",album:"\u00a9alb",year:"\u00a9day",comment:"\u00a9cmt",track:"trkn",genre:"\u00a9gen",picture:"covr",lyrics:"\u00a9lyr"};h.exports=f},{"./MediaFileReader":10,"./MediaTagReader":11}],10:[function(f,h,m){var k=function(){function d(c,b){for(var a=0;a<b.length;a++){var e=b[a];e.enumerable=e.enumerable||!1;e.configurable=!0;"value"in e&&(e.writable=!0);Object.defineProperty(c,e.key,e)}}return function(c,b,a){b&&d(c.prototype,b);a&&d(c,a);return c}}(),
l=f("./StringUtils");f=function(){function d(){if(!(this instanceof d))throw new TypeError("Cannot call a class as a function");this._isInitialized=!1;this._size=0}k(d,[{key:"init",value:function(c){var b=this;if(this._isInitialized)setTimeout(c.onSuccess,1);else return this._init({onSuccess:function(){b._isInitialized=!0;c.onSuccess()},onError:c.onError})}},{key:"_init",value:function(c){throw Error("Must implement init function");}},{key:"loadRange",value:function(c,b){throw Error("Must implement loadRange function");
}},{key:"getSize",value:function(){if(!this._isInitialized)throw Error("init() must be called first.");return this._size}},{key:"getByteAt",value:function(c){throw Error("Must implement getByteAt function");}},{key:"getBytesAt",value:function(c,b){for(var a=Array(b),e=0;e<b;e++)a[e]=this.getByteAt(c+e);return a}},{key:"isBitSetAt",value:function(c,b){return 0!=(this.getByteAt(c)&1<<b)}},{key:"getSByteAt",value:function(c){c=this.getByteAt(c);return 127<c?c-256:c}},{key:"getShortAt",value:function(c,
b){var a=b?(this.getByteAt(c)<<8)+this.getByteAt(c+1):(this.getByteAt(c+1)<<8)+this.getByteAt(c);0>a&&(a+=65536);return a}},{key:"getSShortAt",value:function(c,b){var a=this.getShortAt(c,b);return 32767<a?a-65536:a}},{key:"getLongAt",value:function(c,b){var a=this.getByteAt(c),e=this.getByteAt(c+1),d=this.getByteAt(c+2),f=this.getByteAt(c+3),a=b?(((a<<8)+e<<8)+d<<8)+f:(((f<<8)+d<<8)+e<<8)+a;0>a&&(a+=4294967296);return a}},{key:"getSLongAt",value:function(c,b){var a=this.getLongAt(c,b);return 2147483647<
a?a-4294967296:a}},{key:"getInteger24At",value:function(c,b){var a=this.getByteAt(c),e=this.getByteAt(c+1),d=this.getByteAt(c+2),a=b?((a<<8)+e<<8)+d:((d<<8)+e<<8)+a;0>a&&(a+=16777216);return a}},{key:"getStringAt",value:function(c,b){for(var a=[],e=c,d=0;e<c+b;e++,d++)a[d]=String.fromCharCode(this.getByteAt(e));return a.join("")}},{key:"getStringWithCharsetAt",value:function(c,b,a){c=this.getBytesAt(c,b);switch((a||"").toLowerCase()){case "utf-16":case "utf-16le":case "utf-16be":a=l.readUTF16String(c,
"utf-16be"===a);break;case "utf-8":a=l.readUTF8String(c);break;default:a=l.readNullTerminatedString(c)}return a}},{key:"getCharAt",value:function(c){return String.fromCharCode(this.getByteAt(c))}},{key:"getSynchsafeInteger32At",value:function(c){var b=this.getByteAt(c),a=this.getByteAt(c+1),e=this.getByteAt(c+2);return this.getByteAt(c+3)&127|(e&127)<<7|(a&127)<<14|(b&127)<<21}}],[{key:"canReadFile",value:function(c){throw Error("Must implement canReadFile function");}}]);return d}();h.exports=f},
{"./StringUtils":12}],11:[function(f,h,m){var k=function(){function f(d,c){for(var b=0;b<c.length;b++){var a=c[b];a.enumerable=a.enumerable||!1;a.configurable=!0;"value"in a&&(a.writable=!0);Object.defineProperty(d,a.key,a)}}return function(d,c,b){c&&f(d.prototype,c);b&&f(d,b);return d}}();f("./MediaFileReader");f=function(){function f(d){if(!(this instanceof f))throw new TypeError("Cannot call a class as a function");this._mediaFileReader=d;this._tags=null}k(f,[{key:"setTagsToRead",value:function(d){this._tags=
d;return this}},{key:"read",value:function(d){var c=this;this._mediaFileReader.init({onSuccess:function(){c._loadData(c._mediaFileReader,{onSuccess:function(){try{var b=c._parseData(c._mediaFileReader,c._tags)}catch(a){if(d.onError){d.onError({type:"parseData",info:a.message});return}}d.onSuccess(b)},onError:d.onError})},onError:d.onError})}},{key:"getShortcuts",value:function(){return{}}},{key:"_loadData",value:function(d,c){throw Error("Must implement _loadData function");}},{key:"_parseData",value:function(d,
c){throw Error("Must implement _parseData function");}},{key:"_expandShortcutTags",value:function(d){if(!d)return null;for(var c=[],b=this.getShortcuts(),a=0,e;e=d[a];a++)c=c.concat(b[e]||[e]);return c}}],[{key:"getTagIdentifierByteRange",value:function(){throw Error("Must implement");}},{key:"canReadTagFormat",value:function(d){throw Error("Must implement");}}]);return f}();h.exports=f},{"./MediaFileReader":10}],12:[function(f,h,m){var k=function(){function d(c,b){for(var a=0;a<b.length;a++){var e=
b[a];e.enumerable=e.enumerable||!1;e.configurable=!0;"value"in e&&(e.writable=!0);Object.defineProperty(c,e.key,e)}}return function(c,b,a){b&&d(c.prototype,b);a&&d(c,a);return c}}(),l=function(){function d(c,b){if(!(this instanceof d))throw new TypeError("Cannot call a class as a function");this._value=c;this.bytesReadCount=b;this.length=c.length}k(d,[{key:"toString",value:function(){return this._value}}]);return d}();h.exports={readUTF16String:function(d,c,b){var a=0,e=1,g=0;b=Math.min(b||d.length,
d.length);254==d[0]&&255==d[1]?(c=!0,a=2):255==d[0]&&254==d[1]&&(c=!1,a=2);c&&(e=0,g=1);c=[];for(var f=0;a<b;f++){var h=d[a+e],k=(h<<8)+d[a+g],a=a+2;if(0==k)break;else 216>h||224<=h?c[f]=String.fromCharCode(k):(h=(d[a+e]<<8)+d[a+g],a+=2,c[f]=String.fromCharCode(k,h))}return new l(c.join(""),a)},readUTF8String:function(d,c){var b=0;c=Math.min(c||d.length,d.length);239==d[0]&&187==d[1]&&191==d[2]&&(b=3);for(var a=[],e=0;b<c;e++){var g=d[b++];if(0==g)break;else if(128>g)a[e]=String.fromCharCode(g);else if(194<=
g&&224>g){var f=d[b++];a[e]=String.fromCharCode(((g&31)<<6)+(f&63))}else if(224<=g&&240>g){var f=d[b++],h=d[b++];a[e]=String.fromCharCode(((g&255)<<12)+((f&63)<<6)+(h&63))}else if(240<=g&&245>g){var f=d[b++],h=d[b++],k=d[b++],g=((g&7)<<18)+((f&63)<<12)+((h&63)<<6)+(k&63)-65536;a[e]=String.fromCharCode((g>>10)+55296,(g&1023)+56320)}}return new l(a.join(""),b)},readNullTerminatedString:function(d,c){var b=[];c=c||d.length;for(var a=0;a<c;){var e=d[a++];if(0==e)break;b[a-1]=String.fromCharCode(e)}return new l(b.join(""),
a)}}},{}],13:[function(f,h,m){function k(c,b){if("function"!==typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function, not "+typeof b);c.prototype=Object.create(b&&b.prototype,{constructor:{value:c,enumerable:!1,writable:!0,configurable:!0}});b&&(Object.setPrototypeOf?Object.setPrototypeOf(c,b):c.__proto__=b)}var l=function(){function c(b,a){for(var c=0;c<a.length;c++){var d=a[c];d.enumerable=d.enumerable||!1;d.configurable=!0;"value"in d&&(d.writable=!0);Object.defineProperty(b,
d.key,d)}}return function(b,a,e){a&&c(b.prototype,a);e&&c(b,e);return b}}(),d=f("./ChunkedFileData");m=function(c){function b(a){if(!(this instanceof b))throw new TypeError("Cannot call a class as a function");var c;c=Object.getPrototypeOf(b).call(this);if(!this)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");c=!c||"object"!==typeof c&&"function"!==typeof c?this:c;c._url=a;c._fileData=new d;return c}k(b,c);l(b,[{key:"_init",value:function(a){b._config.avoidHeadRequests?
this._fetchSizeWithGetRequest(a):this._fetchSizeWithHeadRequest(a)}},{key:"_fetchSizeWithHeadRequest",value:function(a){var b=this;this._makeXHRRequest("HEAD",null,{onSuccess:function(c){(c=b._parseContentLength(c))?(b._size=c,a.onSuccess()):b._fetchSizeWithGetRequest(a)},onError:a.onError})}},{key:"_fetchSizeWithGetRequest",value:function(a){var b=this,c=this._roundRangeToChunkMultiple([0,0]);this._makeXHRRequest("GET",c,{onSuccess:function(c){var d=b._parseContentRange(c);c=b._getXhrResponseContent(c);
if(d){if(null==d.instanceLength){b._fetchEntireFile(a);return}b._size=d.instanceLength}else b._size=c.length;b._fileData.addData(0,c);a.onSuccess()},onError:a.onError})}},{key:"_fetchEntireFile",value:function(a){var b=this;this._makeXHRRequest("GET",null,{onSuccess:function(c){c=b._getXhrResponseContent(c);b._size=c.length;b._fileData.addData(0,c);a.onSuccess()},onError:a.onError})}},{key:"_getXhrResponseContent",value:function(a){return a.responseBody||a.responseText||""}},{key:"_parseContentLength",
value:function(a){a=this._getResponseHeader(a,"Content-Length");return null==a?a:parseInt(a,10)}},{key:"_parseContentRange",value:function(a){if(a=this._getResponseHeader(a,"Content-Range")){var b=a.match(/bytes (\d+)-(\d+)\/(?:(\d+)|\*)/i);if(!b)throw Error("FIXME: Unknown Content-Range syntax: ",a);return{firstBytePosition:parseInt(b[1],10),lastBytePosition:parseInt(b[2],10),instanceLength:b[3]?parseInt(b[3],10):null}}return null}},{key:"loadRange",value:function(a,b){var c=this;c._fileData.hasDataRange(a[0],
Math.min(c._size,a[1]))?setTimeout(b.onSuccess,1):(a=this._roundRangeToChunkMultiple(a),a[1]=Math.min(c._size,a[1]),this._makeXHRRequest("GET",a,{onSuccess:function(d){d=c._getXhrResponseContent(d);c._fileData.addData(a[0],d);b.onSuccess()},onError:b.onError}))}},{key:"_roundRangeToChunkMultiple",value:function(a){return[a[0],a[0]+1024*Math.ceil((a[1]-a[0]+1)/1024)-1]}},{key:"_makeXHRRequest",value:function(a,c,d){var f=this._createXHRObject(),h=function(){if(200===f.status||206===f.status)d.onSuccess(f);
else if(d.onError)d.onError({type:"xhr",info:"Unexpected HTTP status "+f.status+".",xhr:f});f=null};"undefined"!==typeof f.onload?(f.onload=h,f.onerror=function(){if(d.onError)d.onError({type:"xhr",info:"Generic XHR error, check xhr object.",xhr:f})}):f.onreadystatechange=function(){4===f.readyState&&h()};b._config.timeoutInSec&&(f.timeout=1E3*b._config.timeoutInSec,f.ontimeout=function(){if(d.onError)d.onError({type:"xhr",info:"Timeout after "+f.timeout/1E3+"s. Use jsmediatags.Config.setXhrTimeout to override.",
xhr:f})});f.open(a,this._url);f.overrideMimeType("text/plain; charset=x-user-defined");c&&this._setRequestHeader(f,"Range","bytes="+c[0]+"-"+c[1]);this._setRequestHeader(f,"If-Modified-Since","Sat, 01 Jan 1970 00:00:00 GMT");f.send(null)}},{key:"_setRequestHeader",value:function(a,c,d){0>b._config.disallowedXhrHeaders.indexOf(c.toLowerCase())&&a.setRequestHeader(c,d)}},{key:"_hasResponseHeader",value:function(a,b){var c=a.getAllResponseHeaders();if(!c)return!1;for(var c=c.split("\r\n"),d=[],f=0;f<
c.length;f++)d[f]=c[f].split(":")[0].toLowerCase();return 0<=d.indexOf(b.toLowerCase())}},{key:"_getResponseHeader",value:function(a,b){return this._hasResponseHeader(a,b)?a.getResponseHeader(b):null}},{key:"getByteAt",value:function(a){return this._fileData.getByteAt(a).charCodeAt(0)&255}},{key:"_createXHRObject",value:function(){if("undefined"===typeof window)return new (f("xhr2").XMLHttpRequest);if(window.XMLHttpRequest)return new window.XMLHttpRequest;throw Error("XMLHttpRequest is not supported");
}}],[{key:"canReadFile",value:function(a){return"string"===typeof a&&/^[a-z]+:\/\//i.test(a)}},{key:"setConfig",value:function(a){for(var b in a)a.hasOwnProperty(b)&&(this._config[b]=a[b]);a=this._config.disallowedXhrHeaders;for(b=0;b<a.length;b++)a[b]=a[b].toLowerCase()}}]);return b}(f("./MediaFileReader"));m._config={avoidHeadRequests:!1,disallowedXhrHeaders:[],timeoutInSec:30};h.exports=m},{"./ChunkedFileData":5,"./MediaFileReader":10,xhr2:2}],14:[function(f,h,m){function k(a,b){if(!(a instanceof
b))throw new TypeError("Cannot call a class as a function");}function l(a,b){var c=0>a.offset&&(-a.offset>b||0<a.offset+a.length);return!(0<=a.offset&&a.offset+a.length>=b||c)}var d=function(){function a(b,c){for(var d=0;d<c.length;d++){var e=c[d];e.enumerable=e.enumerable||!1;e.configurable=!0;"value"in e&&(e.writable=!0);Object.defineProperty(b,e.key,e)}}return function(b,c,d){c&&a(b.prototype,c);d&&a(b,d);return b}}();f("./MediaFileReader");m=f("./NodeFileReader");var c=f("./XhrFileReader"),b=
f("./BlobFileReader"),a=f("./ArrayFileReader");f("./MediaTagReader");var e=f("./ID3v1TagReader"),g=f("./ID3v2TagReader");f=f("./MP4TagReader");var p=[],q=[],r=function(){function a(b){k(this,a);this._file=b}d(a,[{key:"setTagsToRead",value:function(a){this._tagsToRead=a;return this}},{key:"setFileReader",value:function(a){this._fileReader=a;return this}},{key:"setTagReader",value:function(a){this._tagReader=a;return this}},{key:"read",value:function(a){var b=new (this._getFileReader())(this._file),
c=this;b.init({onSuccess:function(){c._getTagReader(b,{onSuccess:function(d){(new d(b)).setTagsToRead(c._tagsToRead).read(a)},onError:a.onError})},onError:a.onError})}},{key:"_getFileReader",value:function(){return this._fileReader?this._fileReader:this._findFileReader()}},{key:"_findFileReader",value:function(){for(var a=0;a<p.length;a++)if(p[a].canReadFile(this._file))return p[a];throw Error("No suitable file reader found for ",this._file);}},{key:"_getTagReader",value:function(a,b){if(this._tagReader){var c=
this._tagReader;setTimeout(function(){b.onSuccess(c)},1)}else this._findTagReader(a,b)}},{key:"_findTagReader",value:function(a,b){for(var c=[],d=[],e=a.getSize(),f=0;f<q.length;f++){var g=q[f].getTagIdentifierByteRange();l(g,e)&&(0<=g.offset&&g.offset<e/2||0>g.offset&&g.offset<-e/2?c.push(q[f]):d.push(q[f]))}var h=!1,f={onSuccess:function(){if(h){for(var c=0;c<q.length;c++){var d=q[c].getTagIdentifierByteRange();if(l(d,e)){try{var f=a.getBytesAt(0<=d.offset?d.offset:d.offset+e,d.length)}catch(g){if(b.onError){b.onError({type:"fileReader",
info:g.message});return}}if(q[c].canReadTagFormat(f)){b.onSuccess(q[c]);return}}}if(b.onError)b.onError({type:"tagFormat",info:"No suitable tag reader found"})}else h=!0},onError:b.onError};this._loadTagIdentifierRanges(a,c,f);this._loadTagIdentifierRanges(a,d,f)}},{key:"_loadTagIdentifierRanges",value:function(a,b,c){if(0===b.length)setTimeout(c.onSuccess,1);else{for(var d=[Number.MAX_VALUE,0],e=a.getSize(),f=0;f<b.length;f++){var g=b[f].getTagIdentifierByteRange(),h=0<=g.offset?g.offset:g.offset+
e,g=h+g.length-1;d[0]=Math.min(h,d[0]);d[1]=Math.max(g,d[1])}a.loadRange(d,c)}}}]);return a}(),w=function(){function a(){k(this,a)}d(a,null,[{key:"addFileReader",value:function(b){p.push(b);return a}},{key:"addTagReader",value:function(b){q.push(b);return a}},{key:"removeTagReader",value:function(b){b=q.indexOf(b);0<=b&&q.splice(b,1);return a}},{key:"EXPERIMENTAL_avoidHeadRequests",value:function(){c.setConfig({avoidHeadRequests:!0})}},{key:"setDisallowedXhrHeaders",value:function(a){c.setConfig({disallowedXhrHeaders:a})}},
{key:"setXhrTimeoutInSec",value:function(a){c.setConfig({timeoutInSec:a})}}]);return a}();w.addFileReader(c).addFileReader(b).addFileReader(a).addTagReader(g).addTagReader(e).addTagReader(f);"undefined"!==typeof process&&w.addFileReader(m);h.exports={read:function(a,b){(new r(a)).read(b)},Reader:r,Config:w}},{"./ArrayFileReader":3,"./BlobFileReader":4,"./ID3v1TagReader":6,"./ID3v2TagReader":8,"./MP4TagReader":9,"./MediaFileReader":10,"./MediaTagReader":11,"./NodeFileReader":1,"./XhrFileReader":13}]},
{},[14])(14)});
var jsmediatags = window.jsmediatags;
var sounds = [];
var newSounds = [];
var currentSongIndex = -1;
function setTags(sound, soundIndex) {
new jsmediatags.Reader(sound)
.setTagsToRead(["artist", "title"])
.read({
onSuccess: function(tag) {
var tags = tag.tags;
console.log("test "+soundIndex);
document.querySelector("p[data-sound-index=\""+soundIndex+"\"]").innerText = tags.artist + " - " + tags.title;
},
onError: function(error) {
console.log("nope");
if (error.type === "xhr") {
console.log("There was a network error: ", error.xhr);
}
console.log(error);
}
});
}
function playNextSong() {
console.log(currentSongIndex);
if (currentSongIndex != -1) {
currentSongIndex = parseInt(currentSongIndex) + 1
if (currentSongIndex > sounds.length) {
currentSongIndex = 0;
}
playCurrentSong();
}
}
function playPrevSong() {
console.log(currentSongIndex);
if (currentSongIndex != -1) {
currentSongIndex = parseInt(currentSongIndex) - 1
if (currentSongIndex < 0) {
currentSongIndex = sounds.length;
}
playCurrentSong();
}
}
function playCurrentSong() {
if (currentSongIndex < 0) {
currentSongIndex = 0;
}
document.querySelector("audio").src = URL.createObjectURL(sounds[currentSongIndex]);
new jsmediatags.Reader(sounds[currentSongIndex])
.setTagsToRead(["artist", "title"])
.read({
onSuccess: function(tag) {
var tags = tag.tags;
document.querySelector(".nowPlaying").innerText = tags.artist + " - " + tags.title;
},
onError: function(error) {
if (error.type === "xhr") {
console.log("There was a network error: ", error.xhr);
}
document.querySelector(".nowPlaying").innerText = sounds[currentSongIndex].name;
console.log(error);
}
});
$(".playing").removeClass("playing");
$("p[data-sound-index=\""+currentSongIndex+"\"]").addClass("playing");
document.querySelector("audio").play();
}
document.addEventListener("DOMContentLoaded", function(e) {
document.querySelector("audio").addEventListener("ended", function(){
console.log(currentSongIndex);
if (currentSongIndex != -1) {
currentSongIndex = (parseInt(currentSongIndex) + 1) % sounds.length;
console.log(currentSongIndex);
playCurrentSong();
}
});
/* code for custom audio controls begin */
document.querySelector("audio").insertAdjacentHTML('afterend', '<div class="audioPlayer paused">'
+'<div class="playPause button"><div class="icon"><div class="top"></div><div class="bottom"></div></div></div><div class="prevButton button"><i class="fa fa-backward"></i></div><div class="nextButton button"><i class="fa fa-forward"></i></div>'
+'<div class="progress bar"><div class="stateIndicator"><span class="elapsedTime">0s</span></div><div class="seekIndicator"></div><span class="fileLength"></span></div>'
+'<div class="volume bar"><i class="fa fa-volume-up"></i><div class="stateIndicator"></div><div class="seekIndicator"></div></div>'
+'</div>');
var icon = $(".audioPlayer .playPause");
var player = $(".audioPlayer");
var duration;
var src = document.querySelector("audio");
src.volume = 0.9999999;
src.style.display = "none";
src.removeAttribute("controls");
src.addEventListener("timeupdate", timeUpdate, false);
src.addEventListener("ended", function() {
player.addClass("paused");
});
function timeUpdate() {
if (src.currentTime > duration && !isNaN(src.currentTime)) {
duration = src.currentTime;
document.querySelector(".audioPlayer .progress.bar .fileLength").innerHTML = Math.floor(duration) + "s";
}
document.querySelector(".audioPlayer .progress.bar .elapsedTime").innerHTML = Math.floor(src.currentTime) + "s";
var playPercent = 100 * (src.currentTime / duration);
document.querySelector(".audioPlayer .progress.bar .stateIndicator").style.width = playPercent + "%";
}
// Gets audio file duration
src.addEventListener("canplaythrough", function() {
duration = src.duration;
document.querySelector(".audioPlayer .progress.bar .fileLength").innerHTML = Math.floor(src.duration) + "s";
}, false);
icon.click(function() {
player.toggleClass("paused");
if (src.paused) {
if (document.querySelector("audio").readyState != 4) {
playCurrentSong();
} else {
src.play();
}
} else {
src.pause();
}
});
$(".audioPlayer .progress.bar").click(function(e) {
var parentOffset = $(this).offset();
var relativeXPosition = (e.pageX - parentOffset.left) / $(this).outerWidth();
src.currentTime = relativeXPosition * duration;
});
$(".audioPlayer .progress.bar").mousemove(function(e) {
$(".audioPlayer .progress.bar .stateIndicator").addClass("active");
var parentOffset = $(this).offset();
var relativeXPosition = (e.pageX - parentOffset.left) / $(this).outerWidth(); //offset -> method allows you to retrieve the current position of an element 'relative' to the document
document.querySelector(".audioPlayer .progress.bar .seekIndicator").style.left = relativeXPosition * 100 + "%";
}).mouseout(function() {
$(".audioPlayer .progress.bar .stateIndicator").removeClass("active");
});
src.addEventListener("volumechange", function() {
document.querySelector(".audioPlayer .volume.bar .stateIndicator").style.width = src.volume * 100 + "%";
});
src.addEventListener("play", function() {
player.removeClass("paused");
});
src.addEventListener("pause", function() {
player.addClass("paused");
});
src.addEventListener("loadedmetadata", function() {
src.currentTime = 0;
duration = src.duration;
document.querySelector(".audioPlayer .progress.bar .fileLength").innerHTML = Math.floor(src.duration) + "s";
});
$("body").bind("keyup",function(event){
console.log("button pressed: "+event.keyCode);
if (event.keyCode == 176) {
playNextSong();
} else if (event.keyCode == 177) {
playPrevSong();
} else if (event.keyCode == 179) {
if (!document.querySelector("audio").paused) {
$(".playPause").click();
} else {
playCurrentSong();
}
}
});
document.querySelector(".nextButton").addEventListener("click", function(){
playNextSong();
});
document.querySelector(".prevButton").addEventListener("click", function(){
playPrevSong();
});
$(".audioPlayer .volume.bar").mousedown(function(e) {
var parentOffset = $(this).offset();
var relativeXPosition = (e.pageX - parentOffset.left) / $(this).outerWidth();
src.volume = relativeXPosition;
document.querySelector(".audioPlayer .volume.bar .stateIndicator").style.width = relativeXPosition * 100 + "%";
});
$(".audioPlayer .volume.bar").mousemove(function(e) {
$(".audioPlayer .volume.bar .stateIndicator").addClass("active");
var parentOffset = $(this).offset();
var relativeXPosition = (e.pageX - parentOffset.left) / $(this).outerWidth(); //offset -> method allows you to retrieve the current position of an element 'relative' to the document
document.querySelector(".audioPlayer .volume.bar .seekIndicator").style.left = relativeXPosition * 100 + "%";
}).mouseout(function() {
$(".audioPlayer .volume.bar .stateIndicator").removeClass("active");
});
/* code for custom audio controls end */
});
input.onchange = function(e){
newSounds = [];
for (file in this.files) {
var file = this.files[file];
console.log(this.files);
console.log(file);
console.log(file.type);
if ((file.type) != undefined && document.querySelector("audio").canPlayType(file.type) != "") {
newSounds.push(file);
}
}
for (localSoundIndex in newSounds) {
var soundIndex = parseInt(localSoundIndex) + parseInt(sounds.length);
var sound = newSounds[localSoundIndex];
var title = document.createElement("p");
var titleText = document.createTextNode(sound.name);
title.appendChild(titleText);
console.log(newSounds);
document.querySelector("body").appendChild(title);
console.log(soundIndex);
title.dataset.soundIndex = soundIndex;
setTags(sound, soundIndex);
title.addEventListener("click", function(){
console.log(sound);
console.log(soundIndex);
currentSongIndex = this.dataset.soundIndex;
playCurrentSong();
});
}
sounds = sounds.concat(newSounds);
}
var context = new AudioContext();
var audio = document.querySelector("audio");
var source = context.createMediaElementSource(audio);
var canvas = document.querySelector(".spectrum");
var canvasCtx = canvas.getContext("2d");
var WIDTH = canvas.width;
var HEIGHT = canvas.height;
canvas.setAttribute('width',WIDTH);
var drawVisual;
var analyser = context.createAnalyser();
analyser.fftSize = 256;
var bufferLength = analyser.frequencyBinCount;
var dataArray = new Uint8Array(bufferLength);
var gain = context.createGain();
gain.gain.value = 0.1;
source.connect(gain);
gain.connect(analyser);
source.connect(context.destination);
draw();
function draw() {
drawVisual = requestAnimationFrame(draw);
// only do rendering if the audio element is playing
if (!audio.paused && !audio.ended && 0 < audio.currentTime) {
var WIDTH = canvas.offsetWidth;
var HEIGHT = canvas.offsetHeight;
canvasCtx.canvas.width = WIDTH;
canvasCtx.canvas.height = HEIGHT;
analyser.getByteFrequencyData(dataArray);
canvasCtx.fillStyle = "transparent";
canvasCtx.fillRect(0, 0, WIDTH, HEIGHT);
var barWidth = (WIDTH / bufferLength);
var barHeight;
var x = 0;
for(var i = 0; i < bufferLength; i++) {
barHeight = dataArray[i];
// that spectrograph won't draw itself
var grad = canvasCtx.createLinearGradient(0,0,0,barHeight);
grad.addColorStop(0,"#FFC507");
grad.addColorStop(1,"#1989F8");
canvasCtx.fillStyle=grad;
canvasCtx.fillRect(x,HEIGHT-(barHeight/256)*HEIGHT,barWidth,(barHeight/256)*HEIGHT);
x += barWidth + 1;
}
}
};</script>
</body>
</html>