-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplayer.html
More file actions
3433 lines (3182 loc) · 127 KB
/
player.html
File metadata and controls
3433 lines (3182 loc) · 127 KB
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
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Local MP3 Folder Player</title>
<style>
:root {
--bg: #040712;
--panel: rgba(9, 16, 38, 0.78);
--panel-strong: rgba(13, 20, 48, 0.92);
--accent: #5dfbff;
--muted: #8da0d8;
--text: #f3f8ff;
--border: rgba(108, 154, 255, 0.22);
--glow: rgba(93, 251, 255, 0.45);
--ctrl-min: 120px;
--playlist-width: clamp(420px, 42%, 600px);
--playcount-col: 3.6ch;
}
* { box-sizing: border-box; }
body {
margin: 0; font: 14px/1.4 system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
color: var(--text); background-color: var(--bg);
min-height: 100dvh; display: grid; place-items: center; padding: 20px;
position: relative; overflow: hidden;
}
body::before,
body::after {
content: ''; position: fixed; inset: -140px;
pointer-events: none; z-index: -2;
}
body::before {
background:
radial-gradient(420px 380px at 20% 25%, rgba(89, 32, 188, 0.42), transparent 70%),
radial-gradient(360px 340px at 78% 18%, rgba(10, 132, 255, 0.34), transparent 65%),
radial-gradient(520px 460px at 50% 86%, rgba(220, 46, 210, 0.24), transparent 75%);
filter: blur(10px);
animation: nebulaShift 18s ease-in-out infinite alternate;
}
body::after {
z-index: -1; opacity: 0.65;
background-image:
radial-gradient(1px 1px at 20px 30px, rgba(255,255,255,0.85), transparent),
radial-gradient(1px 1px at 80px 120px, rgba(149,205,255,0.9), transparent),
radial-gradient(1px 1px at 160px 90px, rgba(255,255,255,0.7), transparent),
radial-gradient(2px 2px at 60px 200px, rgba(255,255,255,0.8), transparent),
radial-gradient(1px 1px at 200px 40px, rgba(255,255,255,0.6), transparent);
background-size: 260px 260px, 320px 320px, 280px 280px, 360px 360px, 400px 400px;
animation: starDrift 60s linear infinite;
}
.app {
width: min(1120px, 100%); background: linear-gradient(150deg, var(--panel), var(--panel-strong));
border: 1px solid var(--border); border-radius: 20px; box-shadow: 0 20px 60px rgba(2, 8, 23, 0.65), 0 0 38px rgba(93, 251, 255, 0.15);
overflow: hidden;
backdrop-filter: blur(16px);
}
header {
display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 18px 10px;
border-bottom: 1px solid var(--border); background: linear-gradient(180deg, rgba(255,255,255,.08), rgba(9,16,38,0.12));
box-shadow: inset 0 -1px 0 rgba(93, 251, 255, 0.08);
}
h1 { margin: 0; font-size: 19px; letter-spacing: .38px; font-weight: 600; text-shadow: 0 0 14px rgba(93, 251, 255, 0.45); }
.hint { color: var(--muted); font-size: 12px; }
.folder-path {
margin-top: 4px; font-size: 12px; color: var(--accent); overflow-wrap: anywhere; text-shadow: 0 0 10px rgba(93, 251, 255, 0.4);
}
.choose { appearance: none; border: 1px solid var(--border); background: #101427; color: var(--text);
padding: 10px 14px; border-radius: 12px; cursor: pointer; font-weight: 600; letter-spacing: .3px;
box-shadow: 0 0 20px rgba(93, 251, 255, 0.12); transition: border-color .2s ease, box-shadow .2s ease, transform .2s ease;
}
.choose:hover { border-color: rgba(93, 251, 255, 0.45); box-shadow: 0 0 24px rgba(93, 251, 255, 0.28); transform: translateY(-1px); }
.wrap {
/* Left: main player (will have an internal 4-col grid), Right: playlist */
display: grid; grid-template-columns: minmax(0, 1fr) var(--playlist-width); gap: 0; min-height: 520px;
}
@media (max-width: 1100px) {
:root { --playlist-width: clamp(320px, 45%, 380px); }
}
@media (max-width: 900px) { .wrap { grid-template-columns: 1fr; } }
.player {
padding-top: 18px;
padding-left: 18px;
padding-bottom: 18px;
padding-right: 0px;
display: grid;
/* internal player grid: 3 main columns + 1 auto column for the volume panel
Use `auto` so the volume column only becomes as wide as its contents. */
grid-template-columns: 1fr 1fr 1fr auto;
grid-auto-rows: auto; gap: 14px;
background: linear-gradient(180deg, rgba(13, 20, 48, 0.46), transparent);
}
@media (max-width: 900px) { .player { grid-template-columns: 1fr; } }
@media (max-width: 900px) { .player { border-right: none; border-bottom: 1px solid var(--border); } }
@media (max-width: 900px) {
/* stack volume and visualizer in single-column layout */
.volume-panel { grid-column: 1 / -1; grid-row: auto; border-left: none; border-top: 1px solid var(--border); padding-top: 12px; }
.visualizer { grid-column: 1 / -1; grid-row: auto; }
}
/* Now area: simple 2x2 grid */
.now {
display: grid;
grid-template-columns: auto 1fr; /* label | artist/title column */
grid-template-rows: auto auto; /* top row = label+artist, bottom row = track# + title */
gap: 6px 12px;
align-items: center;
background: rgba(11, 18, 46, 0.84); border: 1px solid var(--border); border-radius: 14px; padding: 14px;
box-shadow: 0 0 22px rgba(93, 251, 255, 0.08);
}
/* Top-left: label */
.now-label {
grid-column: 1 / 2;
grid-row: 1 / 2;
color: color-mix(in srgb, var(--muted) 40%, var(--accent) 60%);
margin: 0;
font-size: 16px; font-weight: 600; letter-spacing: .8px;
align-self: center;
}
/* Top-right: artist fills remaining width and is right-justified */
.now-artist {
grid-column: 2 / 3;
grid-row: 1 / 2;
color: var(--muted);
margin: 0;
font-size: 17px; font-weight: 600;
line-height: 1.1;
}
/* Bottom-left: track number */
.now-num {
grid-column: 1 / 2;
grid-row: 2 / 3;
justify-self: center; /* center within that cell */
min-width: var(--now-num-min, 4ch); font-variant-numeric: tabular-nums;
color: var(--accent); letter-spacing: .6px;
display: inline-flex; align-items: center; justify-content: center;
padding: 8px var(--now-num-pad-x, 12px); border-radius: 999px; border: 1px solid rgba(93, 251, 255, 0.28);
background: rgba(93, 251, 255, 0.12); font-weight: 600; line-height: 1;
}
/* Bottom-right: title fills remaining width and ellipses when needed */
.now-title {
grid-column: 2 / 3;
grid-row: 2 / 3;
color: var(--text);
font-weight: 600;
}
.now-title-link {
color: var(--accent);
text-decoration: none;
}
.now-title-link:hover {
text-decoration: underline;
}
.controls {
display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px;
}
button.ctrl {
border: 1px solid var(--border); background: rgba(12, 19, 44, 0.82); color: var(--text);
padding: 12px 12px; border-radius: 12px; cursor: pointer; font-weight: 600;
box-shadow: 0 0 18px rgba(93, 251, 255, 0.08); transition: border-color .2s ease, box-shadow .2s ease, transform .2s ease;
}
button.ctrl[aria-pressed="true"], button.ctrl.active {
outline: 2px solid color-mix(in oklab, var(--accent) 70%, transparent); box-shadow: 0 0 24px rgba(93, 251, 255, 0.35);
}
button.ctrl:hover { border-color: rgba(93, 251, 255, 0.45); box-shadow: 0 0 26px rgba(93, 251, 255, 0.45); transform: translateY(-1px); }
button.ctrl:disabled {
opacity: 0.45;
cursor: not-allowed;
pointer-events: none;
}
.seek {
display: grid; grid-template-columns: 1fr auto auto auto; align-items: center; gap: 10px; margin-top: 4px;
}
input[type="range"] {
width: 100%; accent-color: var(--accent);
background: linear-gradient(90deg, rgba(93, 251, 255, 0.45), rgba(155, 132, 255, 0.35));
border-radius: 999px; height: 4px;
}
.visualizer {
background: rgba(11, 18, 46, 0.78); border: 1px solid var(--border); border-radius: 14px; padding: 12px;
display: grid; gap: 10px; box-shadow: 0 0 22px rgba(93, 251, 255, 0.08);
/* span all internal player columns so it covers prev/play/next/volume area */
grid-column: 1 / 5;
}
/* Volume panel when moved inside player as column 4 */
.volume-panel {
/* occupy the 4th internal column */
grid-column: 4 / 5; align-self: stretch; justify-self: center;
/* span the first 4 rows (top-controls, now, controls, seek) */
grid-row: 1 / 5;
/* stack label / track / percent vertically and center them */
display: grid; grid-template-rows: auto 1fr auto; align-items: center; justify-items: center;
padding: 12px;
background: rgba(11, 18, 46, 0.78); border: 1px solid var(--border); border-radius: 14px;
box-shadow: 0 0 22px rgba(93, 251, 255, 0.08);
}
/* volume inner container used for the label and track */
.volume-panel .volume-label { text-align: center; }
.volume-panel .volume-label .hint { font-size: 14px; font-weight: 600; color: var(--text); }
.volume-panel .volume-track {
/* let track size to its contents (the vertical input) so column remains narrow */
height: 100%;
display: flex;
align-items: center;
justify-content: center;
width: auto;
box-sizing: border-box;
overflow: visible;
padding-top: 10px;
padding-bottom: 10px;
}
.volume-vertical { display:flex; flex-direction: column; align-items:center; }
/* vertical volume slider styling - use native vertical writing-mode for modern browsers */
#volume.vertical {
/* Use native vertical layout instead of rotating the control. This is supported in
modern Chromium and produces a cleaner bounding box without overlap. */
writing-mode: vertical-lr;
direction: rtl;
/* horizontal thickness and vertical length */
width: 22px;
height: 200px;
display: block;
margin: 0;
box-sizing: border-box;
}
.volume-value {
font-size: 15px; font-weight: 600; color: var(--text); margin-top: 0;
}
/* place the main player sections into the left 3 columns; volume-panel occupies column 4 */
.top-controls { grid-column: 1 / 4; }
.now { grid-column: 1 / 4; }
.controls { grid-column: 1 / 4; }
.seek { grid-column: 1 / 4; }
.top-controls { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.viz-toolbar {
display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 13px;
}
.viz-title { font-weight: 600; letter-spacing: .3px; text-transform: uppercase; color: var(--muted); }
.viz-select {
appearance: none; border: 1px solid var(--border); background: #101427; color: var(--text);
padding: 6px 30px 6px 12px; border-radius: 10px; cursor: pointer; font-weight: 600; letter-spacing: .2px;
box-shadow: 0 0 18px rgba(93, 251, 255, 0.12); min-width: 160px;
background-image: linear-gradient(135deg, rgba(93, 251, 255, 0.18), rgba(155, 132, 255, 0.12));
}
.viz-select:hover { border-color: rgba(93, 251, 255, 0.4); box-shadow: 0 0 22px rgba(93, 251, 255, 0.24); }
.viz-select:focus {
outline: 2px solid color-mix(in oklab, var(--accent) 65%, transparent);
box-shadow: 0 0 22px rgba(93, 251, 255, 0.32);
}
.viz-select:disabled { opacity: .6; cursor: not-allowed; }
.viz-canvas {
width: 100%; height: 180px; border-radius: 10px; display: block;
background: linear-gradient(180deg, rgba(4, 7, 18, 0.78), rgba(8, 14, 36, 0.82));
box-shadow: inset 0 0 22px rgba(93, 251, 255, 0.12);
}
.viz-status { font-size: 12px; color: var(--muted); }
.time {
color: var(--muted);
text-align: right;
justify-self: end;
font-variant-numeric: tabular-nums;
}
.now-rating {
display: flex; gap: 3px; font-size: 16px; padding: 0 8px;
justify-self: end; justify-content: flex-end;
border-left: 1px solid var(--border);
}
.now-rating .star {
cursor: pointer; color: rgba(255, 255, 255, 0.2); transition: color .15s ease, transform .15s ease;
user-select: none;
}
.now-rating .star.filled { color: #ffd700; text-shadow: 0 0 8px rgba(255, 215, 0, 0.6); }
.now-rating .star.hover-fill { color: #ffd700; }
.now-rating .star:hover { transform: scale(1.15); }
.now-play-count {
display: inline-flex; align-items: center; justify-content: center; gap: 3px; padding: 0 6px;
font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums;
border-left: 1px solid var(--border);
min-width: var(--playcount-col);
justify-self: center;
}
.now-play-count .count-icon { opacity: 0.6; font-size: 12px; }
.now-play-count .count-value { font-weight: 600; }
.list {
padding: 12px; overflow: auto; max-height: 610px;
background: linear-gradient(180deg, rgba(8, 14, 36, 0.55), rgba(8, 14, 36, 0.2));
}
.item {
display: grid; grid-template-columns: auto 1fr auto auto auto; align-items: center; gap: 10px;
padding: 10px 12px; border-radius: 12px; cursor: pointer; user-select: none;
transition: background-color .18s ease, box-shadow .18s ease, transform .18s ease;
}
.item:hover { background: rgba(93, 251, 255, 0.08); box-shadow: 0 10px 28px rgba(2, 8, 23, 0.4); transform: translateX(2px); }
.item.active { background: rgba(93, 251, 255, 0.16); outline: 1px solid rgba(93, 251, 255, 0.45); box-shadow: 0 0 24px rgba(93, 251, 255, 0.25); }
.num { color: var(--muted); width: 2ch; text-align: right; text-shadow: 0 0 6px rgba(93, 251, 255, 0.35); }
.name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dur {
color: var(--muted);
font-variant-numeric: tabular-nums;
text-align: right;
justify-self: end;
}
.play-count {
color: var(--muted); font-size: 12px; text-align: center;
font-variant-numeric: tabular-nums;
opacity: 0.8;
width: var(--playcount-col);
display: flex; align-items: center; justify-content: center;
}
.play-count:not(:empty)::before { content: '▶'; opacity: 0.6; margin-right: 2px; font-size: 11px; }
.rating {
display: flex;
gap: 2px;
font-size: 14px;
justify-content: flex-end;
justify-self: end;
}
.rating .star {
cursor: pointer; color: rgba(255, 255, 255, 0.2); transition: color .15s ease, transform .15s ease;
user-select: none;
}
.rating .star.filled { color: #ffd700; text-shadow: 0 0 8px rgba(255, 215, 0, 0.6); }
.rating .star.hover-fill { color: #ffd700; }
.rating .star:hover { transform: scale(1.15); }
.footer-actions { display: flex; align-items: center; gap: 12px; }
.history-btn {
appearance: none; border: 1px solid var(--border); border-radius: 10px;
background: rgba(9, 15, 33, 0.78); color: var(--text); font-weight: 600;
padding: 8px 14px; cursor: pointer; transition: border-color .2s ease, box-shadow .2s ease, background .2s ease;
}
.history-btn:hover {
border-color: rgba(93, 251, 255, 0.55);
box-shadow: 0 0 20px rgba(93, 251, 255, 0.25);
}
.history-overlay {
position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
padding: 32px; background: rgba(4, 7, 18, 0.82); backdrop-filter: blur(8px);
z-index: 300;
}
.history-overlay[hidden] { display: none; }
.history-sheet {
width: min(1080px, 96vw); max-height: min(90vh, 760px);
background: linear-gradient(150deg, rgba(11, 18, 46, 0.96), rgba(6, 12, 30, 0.94));
border: 1px solid rgba(93, 251, 255, 0.25);
border-radius: 18px; box-shadow: 0 30px 80px rgba(3, 9, 24, 0.65), 0 0 40px rgba(93, 251, 255, 0.18);
display: flex; flex-direction: column; overflow: hidden;
}
.history-sheet-header {
display: flex; align-items: center; justify-content: space-between;
padding: 20px 24px; border-bottom: 1px solid rgba(93, 251, 255, 0.18);
}
.history-title { margin: 0; font-size: 20px; font-weight: 600; }
.history-header-actions { display: flex; align-items: center; gap: 12px; }
.history-counter { font-size: 12px; color: var(--muted); }
.history-clear {
appearance: none; border: 1px solid rgba(255, 99, 132, 0.35); border-radius: 10px;
background: rgba(255, 99, 132, 0.12); color: #ff99a6; font-weight: 600;
padding: 6px 12px; cursor: pointer; transition: border-color .2s ease, background .2s ease, color .2s ease;
}
.history-clear:hover {
border-color: rgba(255, 99, 132, 0.55);
background: rgba(255, 99, 132, 0.18);
color: #ffc0c8;
}
.history-close {
appearance: none; border: none; background: transparent; color: var(--muted);
font-size: 26px; width: 36px; height: 36px; border-radius: 10px; cursor: pointer;
transition: background .2s ease, color .2s ease;
}
.history-close:hover { background: rgba(93, 251, 255, 0.15); color: var(--text); }
.history-sheet-body {
padding: 18px 24px 24px; overflow: auto; display: flex; flex-direction: column; gap: 18px;
}
.history-body-actions { display: none; }
.history-empty {
text-align: center; font-size: 14px; color: var(--muted);
padding: 30px 12px; border: 1px dashed rgba(93, 251, 255, 0.25); border-radius: 14px;
background: rgba(9, 15, 33, 0.4);
}
.history-table-wrap { overflow: auto; }
.history-table-wrap.hide { display: none; }
.history-table {
width: 100%; border-collapse: collapse; min-width: 720px;
background: rgba(5, 12, 28, 0.75);
}
.history-table tr.live { background: rgba(93, 251, 255, 0.04); }
.history-table th,
.history-table td {
padding: 12px 14px; text-align: left; border-bottom: 1px solid rgba(93, 251, 255, 0.12);
vertical-align: top;
}
.history-table th {
font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted);
background: rgba(13, 20, 48, 0.55);
position: sticky; top: 0;
white-space: nowrap;
}
.history-table td { font-size: 13px; color: var(--text); }
.history-table td.time-cell { font-variant-numeric: tabular-nums; white-space: nowrap; }
.history-table td.status-cell { width: 1%; white-space: nowrap; }
.history-table td.action-cell { width: 1%; white-space: nowrap; text-align: right; }
.history-track-cell { font-weight: 600; word-break: break-word; }
.history-table td.meta-cell { color: var(--muted); font-size: 12px; line-height: 1.4; word-break: break-word; }
.history-path-link { color: var(--accent); text-decoration: none; }
.history-path-link:hover { text-decoration: underline; }
.heard-indicator { font-weight: 600; }
.heard-indicator.heard-low { color: #ffd66b; }
.heard-indicator.heard-exact { color: #82c3ff; }
.heard-indicator.heard-high { color: #7efce0; }
.history-status {
display: inline-flex; align-items: center; justify-content: center;
padding: 4px 12px; border-radius: 999px; font-size: 12px; font-weight: 600;
border: 1px solid transparent; background: rgba(255,255,255,0.04);
text-transform: capitalize;
}
.history-status.completed { border-color: rgba(93, 251, 255, 0.45); color: var(--accent); }
.history-status.skipped { border-color: rgba(255, 71, 87, 0.65); color: #ff8b99; }
.history-status.scrubbed { border-color: rgba(255, 214, 0, 0.75); color: #ffeaa7; }
.history-status.fast-forward { border-color: rgba(255, 166, 77, 0.75); color: #ffba7a; }
.history-status.rewound { border-color: rgba(67, 255, 192, 0.75); color: #7efce0; }
.history-status.stopped { border-color: rgba(255, 165, 2, 0.55); color: #ffcd82; }
.history-status.live { border-color: rgba(255, 255, 255, 0.3); color: var(--text); background: rgba(93, 251, 255, 0.12); }
.history-delete-btn {
appearance: none; border: 1px solid rgba(255, 99, 132, 0.4);
border-radius: 8px; background: rgba(255, 99, 132, 0.1);
color: #ff99a6; padding: 4px 10px; cursor: pointer;
font-size: 12px; font-weight: 600;
transition: border-color .2s ease, background .2s ease, color .2s ease;
}
.history-delete-btn:hover {
border-color: rgba(255, 99, 132, 0.65);
background: rgba(255, 99, 132, 0.2);
color: #ffc0c8;
}
@media (max-width: 640px) {
.history-sheet { width: 100%; height: 100%; border-radius: 0; }
.history-sheet-body { padding: 18px; }
.history-table { min-width: unset; }
}
footer {
padding: 10px 18px 14px; display: flex; align-items: center; justify-content: space-between;
border-top: 1px solid var(--border); color: var(--muted); font-size: 12px;
background: linear-gradient(0deg, rgba(9, 16, 38, 0.18), transparent);
}
.kbd { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; background:#0e1327; border:1px solid var(--border);
padding: 2px 6px; border-radius: 6px; color: var(--text); box-shadow: 0 0 12px rgba(93, 251, 255, 0.12);
}
.hide { display: none !important; }
.button-group { display: flex; gap: 10px; }
/* Settings modal */
.modal-backdrop {
display: none; position: fixed; inset: 0; z-index: 100;
background: rgba(4, 7, 18, 0.85); backdrop-filter: blur(8px);
align-items: center; justify-content: center; padding: 20px;
}
.modal-backdrop.show { display: flex; }
.modal {
background: linear-gradient(150deg, var(--panel), var(--panel-strong));
border: 1px solid var(--border); border-radius: 16px;
box-shadow: 0 20px 60px rgba(2, 8, 23, 0.75), 0 0 38px rgba(93, 251, 255, 0.2);
max-width: 520px; width: 100%; max-height: 80vh; overflow-y: auto;
}
.modal-header {
padding: 18px 20px; border-bottom: 1px solid var(--border);
display: flex; align-items: center; justify-content: space-between;
}
.modal-title { margin: 0; font-size: 18px; font-weight: 600; }
.modal-close {
appearance: none; border: none; background: transparent;
color: var(--muted); font-size: 24px; cursor: pointer;
width: 32px; height: 32px; display: flex; align-items: center; justify-content: center;
border-radius: 8px; transition: background .2s, color .2s;
}
.modal-close:hover { background: rgba(93, 251, 255, 0.12); color: var(--text); }
.modal-body { padding: 20px; }
.modal-section { margin-bottom: 24px; }
.modal-section:last-child { margin-bottom: 0; }
.modal-section-title {
font-size: 15px; font-weight: 600; color: var(--accent);
margin: 0 0 12px; text-transform: uppercase; letter-spacing: .5px;
}
.modal-section-desc { font-size: 13px; color: var(--muted); margin: 0 0 14px; line-height: 1.5; }
.modal-option {
display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 10px;
background: rgba(11, 18, 46, 0.6); border: 1px solid var(--border);
margin-bottom: 10px; transition: background .2s, border-color .2s;
}
.modal-option:hover { background: rgba(11, 18, 46, 0.8); border-color: rgba(93, 251, 255, 0.3); }
.modal-option-label { flex: 1; display: flex; flex-direction: column; gap: 4px; }
.modal-option-name { font-weight: 600; color: var(--text); font-size: 14px; }
.modal-option-hint { font-size: 12px; color: var(--muted); line-height: 1.4; }
.modal-option-status { font-size: 11px; color: var(--accent); margin-top: 4px; }
/* Toast notifications */
.toast-container {
position: fixed; bottom: 20px; right: 20px; z-index: 200;
display: flex; flex-direction: column; gap: 10px; max-width: 400px;
}
.toast {
background: linear-gradient(135deg, rgba(13, 20, 48, 0.95), rgba(9, 16, 38, 0.95));
border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px;
box-shadow: 0 10px 30px rgba(2, 8, 23, 0.6), 0 0 20px rgba(93, 251, 255, 0.15);
backdrop-filter: blur(12px);
display: flex; align-items: start; gap: 10px;
animation: toastSlide 0.3s ease-out;
}
@keyframes toastSlide {
from { transform: translateX(400px); opacity: 0; }
to { transform: translateX(0); opacity: 1; }
}
.toast-icon { font-size: 18px; line-height: 1; }
.toast-content { flex: 1; }
.toast-title { font-weight: 600; color: var(--text); margin: 0 0 4px; font-size: 14px; }
.toast-message { font-size: 13px; color: var(--muted); margin: 0; line-height: 1.4; }
.toast.error { border-left: 3px solid #ff4757; }
.toast.success { border-left: 3px solid #5dfbff; }
.toast.warning { border-left: 3px solid #ffa502; }
.tree-root { margin-top: 4px; }
details.tree-dir { padding-left: 0; margin: 2px 0 2px; }
details.tree-dir > summary {
cursor: pointer; padding: 6px 10px; border-radius: 8px;
list-style: none; display: flex; align-items: center; gap: 8px;
color: var(--muted); background: transparent;
}
details.tree-dir > summary::before {
content: '📁'; font-size: 14px;
}
details.tree-dir > summary::-webkit-details-marker { display: none; }
details.tree-dir[open] > summary { color: var(--text); background: rgba(93, 251, 255, 0.08); }
details.tree-dir > summary:hover { background: rgba(93, 251, 255, 0.1); color: var(--text); }
.tree-children { margin-left: 18px; border-left: 1px solid rgba(93, 251, 255, 0.2); padding-left: 10px; }
.tree-children .item { margin: 2px 0; }
.tree-children .num { min-width: 2.5ch; color: var(--muted); text-align: right; text-shadow: 0 0 6px rgba(93, 251, 255, 0.35); }
.track-item { margin: 2px 0; }
@keyframes nebulaShift {
0% { transform: translate3d(-2%, -1%, 0) scale(1.02); }
50% { transform: translate3d(1%, 2%, 0) scale(1.06); }
100% { transform: translate3d(3%, -2%, 0) scale(1.03); }
}
@keyframes starDrift {
0% { transform: translate3d(0, 0, 0); }
100% { transform: translate3d(-240px, -360px, 0); }
}
</style>
</head>
<body>
<div class="app" role="application" aria-label="Local MP3 Folder Player">
<header>
<div>
<h1>Local MP3 Folder Player</h1>
<div class="hint">Choose a folder to scan recursively for <strong>.mp3</strong> files (Chromium browsers).</div>
<div class="folder-path" id="folderPath" aria-live="polite">No folder selected.</div>
</div>
<div class="button-group">
<button class="choose" id="settingsBtn" title="Settings">⚙️ Settings</button>
<button class="choose" id="chooseBtn">🎵 Choose folder…</button>
</div>
</header>
<div class="wrap">
<section class="player">
<div class="top-controls" role="group" aria-label="Top controls">
<button class="ctrl" id="shuffleBtn" aria-pressed="true" title="Toggle Shuffle (S)">🔀 Shuffle</button>
<button class="ctrl" id="loopBtn" title="Cycle Loop (L)">🔁 Loop: All</button>
<button class="ctrl" id="announceBtn" aria-pressed="true" title="Toggle Speech Announcements (A)">🗣 Announce On</button>
</div>
<div class="now" role="group" aria-labelledby="nowLabel">
<small id="nowLabel" class="now-label">Now Playing:</small>
<span id="nowArtist" class="now-artist">—</span>
<span id="nowTrackNumber" class="now-num">—</span>
<span id="nowTitle" class="now-title" aria-live="polite" aria-atomic="true">—</span>
</div>
<div class="controls" role="group" aria-label="Playback controls">
<button class="ctrl" id="prevBtn" title="Previous (Cmd/Ctrl+←)">⏮ Prev</button>
<button class="ctrl" id="playPauseBtn" title="Space">▶️ Play</button>
<button class="ctrl" id="nextBtn" title="Next (Cmd/Ctrl+→)">⏭ Next</button>
</div>
<div class="seek">
<input id="seek" type="range" min="0" max="1000" value="0" />
<div class="time"><span id="tCur">0:00</span> / <span id="tTot">0:00</span></div>
<div class="now-play-count" id="nowPlayCount" title="Play count">
<span class="count-icon">▶</span>
<span class="count-value" id="nowPlayCountValue">—</span>
</div>
<div class="now-rating" id="nowRating" title="Rate this track">
<span class="star" data-rating="1">★</span>
<span class="star" data-rating="2">★</span>
<span class="star" data-rating="3">★</span>
<span class="star" data-rating="4">★</span>
<span class="star" data-rating="5">★</span>
</div>
</div>
<div class="volume-panel" aria-label="Volume panel">
<div class="volume-label"><label for="volume" class="hint">Volume</label></div>
<div class="volume-track"><input id="volume" class="vertical" type="range" min="0" max="100" value="100" title="Volume (↑/↓)" /></div>
<div class="volume-value" id="volumeDisplay">100%</div>
</div>
<div class="visualizer" role="region" aria-label="Audio visualizer">
<div class="viz-toolbar">
<span class="viz-title" id="vizTitle">Spectrum Analyzer</span>
<select id="vizMode" class="viz-select" aria-labelledby="vizTitle">
<option value="bars">Neon Bars</option>
<option value="wave">Glow Wave</option>
<option value="radial">Pulse Halo</option>
</select>
</div>
<canvas id="vizCanvas" class="viz-canvas" role="img" aria-label="Audio visualization"></canvas>
<div class="viz-status" id="vizStatus">Select a style and start playback to visualize audio.</div>
</div>
</section>
<aside class="list" id="list" aria-label="Playlist"></aside>
</div>
<footer>
<div>Shortcuts: <span class="kbd">Space</span> Play/Pause · <span class="kbd">←/→</span> Seek · <span class="kbd">Cmd/Ctrl+←/→</span> Prev/Next · <span class="kbd">↑/↓</span> Volume · <span class="kbd">S</span> Shuffle · <span class="kbd">L</span> Loop · <span class="kbd">A</span> Announce</div>
<div class="footer-actions">
<div id="count">0 tracks</div>
<button class="history-btn" id="historyToggleBtn" type="button">📜 History</button>
</div>
</footer>
</div>
<div class="history-overlay" id="historyOverlay" hidden aria-hidden="true">
<div class="history-sheet" role="dialog" aria-modal="true" aria-labelledby="historyTitle">
<div class="history-sheet-header">
<h2 class="history-title" id="historyTitle">Listening History</h2>
<div class="history-header-actions">
<span class="history-counter" id="historyCountLabel">0 entries</span>
<button class="history-clear" id="historyClearBtn" type="button">Clear</button>
<button class="history-close" id="historyCloseBtn" type="button" aria-label="Close history">×</button>
</div>
</div>
<div class="history-sheet-body">
<p class="history-empty" id="historyEmptyState">No listening history yet.</p>
<div class="history-table-wrap hide" id="historyTableWrap">
<table class="history-table">
<thead>
<tr>
<th scope="col">Started</th>
<th scope="col">Track</th>
<th scope="col">Artist • Path</th>
<th scope="col">Listened</th>
<th scope="col">% Heard</th>
<th scope="col">Plays</th>
<th scope="col">Status</th>
<th scope="col" aria-label="Actions">Actions</th>
</tr>
</thead>
<tbody id="historyTbody"></tbody>
</table>
</div>
</div>
</div>
</div>
<!-- Settings Modal -->
<div class="modal-backdrop" id="settingsModal" role="dialog" aria-labelledby="settingsModalTitle" aria-modal="true">
<div class="modal">
<div class="modal-header">
<h2 class="modal-title" id="settingsModalTitle">Settings</h2>
<button class="modal-close" id="closeSettingsBtn" aria-label="Close settings">×</button>
</div>
<div class="modal-body">
<section class="modal-section">
<h3 class="modal-section-title">OBS Metadata Export</h3>
<p class="modal-section-desc">
Export currently playing track metadata to a text file for use in OBS overlays and streaming software.
The file updates automatically whenever the track changes.
</p>
<div class="modal-option">
<div class="modal-option-label">
<div class="modal-option-name">Text File Export</div>
<div class="modal-option-hint">
Save "Title – Artist" to a text file. Requires Chromium-based browser (Chrome, Edge, Opera).
</div>
<div class="modal-option-status" id="textFileStatus">Not configured</div>
</div>
<button class="ctrl" id="configureTextFileBtn" style="min-width: 100px;">Configure</button>
</div>
</section>
</div>
</div>
</div>
<!-- Toast Container -->
<div class="toast-container" id="toastContainer"></div>
<audio id="audio" class="hide" preload="metadata"></audio>
<script>
(() => {
const chooseBtn = document.getElementById('chooseBtn');
const listEl = document.getElementById('list');
const historyOverlay = document.getElementById('historyOverlay');
const historyToggleBtn = document.getElementById('historyToggleBtn');
const historyCloseBtn = document.getElementById('historyCloseBtn');
const historyTableBody = document.getElementById('historyTbody');
const historyCountLabel = document.getElementById('historyCountLabel');
const historyClearBtn = document.getElementById('historyClearBtn');
const historyTableWrap = document.getElementById('historyTableWrap');
const historyEmptyEl = document.getElementById('historyEmptyState');
const audio = document.getElementById('audio');
const nowTitleEl = document.getElementById('nowTitle');
const nowArtistEl = document.getElementById('nowArtist');
const nowTrackNumberEl = document.getElementById('nowTrackNumber');
const nowPlayCountEl = document.getElementById('nowPlayCountValue');
const countEl = document.getElementById('count');
const prevBtn = document.getElementById('prevBtn');
const playPauseBtn= document.getElementById('playPauseBtn');
const nextBtn = document.getElementById('nextBtn');
const shuffleBtn = document.getElementById('shuffleBtn');
const loopBtn = document.getElementById('loopBtn');
const announceBtn = document.getElementById('announceBtn');
const seek = document.getElementById('seek');
const tCur = document.getElementById('tCur');
const tTot = document.getElementById('tTot');
const volumeSlider= document.getElementById('volume');
const volumeDisplay=document.getElementById('volumeDisplay');
const folderPathEl= document.getElementById('folderPath');
const vizModeSel = document.getElementById('vizMode');
const vizCanvas = document.getElementById('vizCanvas');
const vizStatusEl = document.getElementById('vizStatus');
const nowRatingEl = document.getElementById('nowRating');
// Settings modal elements
const settingsBtn = document.getElementById('settingsBtn');
const settingsModal = document.getElementById('settingsModal');
const closeSettingsBtn = document.getElementById('closeSettingsBtn');
const configureTextFileBtn = document.getElementById('configureTextFileBtn');
const textFileStatus = document.getElementById('textFileStatus');
const toastContainer = document.getElementById('toastContainer');
/** Persistence */
const DB_NAME = 'lwa-player';
const STORE_NAME = 'handles';
const HISTORY_STORE = 'play-history';
const RATINGS_STORE = 'track-ratings';
const PLAY_COUNTS_STORE = 'play-counts';
const HISTORY_INDEX = 'by-started-at';
const LAST_KEY = 'last-folder';
const SHUFFLE_KEY = 'shuffle-enabled';
const LOOP_KEY = 'loop-mode';
const LAST_TRACK_KEY = 'last-track';
const ANNOUNCE_KEY = 'lwa-announce-enabled';
const VIZ_MODE_KEY = 'lwa-viz-mode';
const VOLUME_KEY = 'lwa-volume';
const TEXT_FILE_HANDLE_KEY = 'text-file-handle';
const TEXT_FILE_ENABLED_KEY = 'text-file-enabled';
const HISTORY_RENDER_LIMIT = 200;
const HISTORY_MAX_ENTRIES = 500;
// Play count threshold: A track is counted as "played" if at least 50% of its duration is heard.
// This prevents accidental skips from inflating counts while still capturing genuine listens.
const SKIP_THRESHOLD = 0.5;
const REWIND_RATIO_THRESHOLD = 1.005;
const HEARD_LOW_RATIO_THRESHOLD = 0.995;
const REWIND_DISPLAY_PERCENT = REWIND_RATIO_THRESHOLD * 100;
const HEARD_LOW_DISPLAY_PERCENT = HEARD_LOW_RATIO_THRESHOLD * 100;
let handleDbPromise = null;
const NAME_COLLATOR = new Intl.Collator(undefined, { numeric: true, sensitivity: 'base' });
const HISTORY_TIME_FORMATTER = new Intl.DateTimeFormat(undefined, { dateStyle: 'short', timeStyle: 'short' });
const HISTORY_TIME_CACHE = new Map();
let trackRatings = new Map();
let trackPlayCounts = new Map();
const getHandleDb = () => {
if (!('indexedDB' in window)) return null;
if (!handleDbPromise) {
handleDbPromise = new Promise((resolve, reject) => {
// Version 2: Added HISTORY_STORE for playback session tracking
// Version 3: Added RATINGS_STORE for track ratings
// Version 4: Added PLAY_COUNTS_STORE for tracking play counts
const req = indexedDB.open(DB_NAME, 4);
req.onerror = () => reject(req.error);
req.onupgradeneeded = () => {
const db = req.result;
if (!db.objectStoreNames.contains(STORE_NAME)) db.createObjectStore(STORE_NAME);
if (!db.objectStoreNames.contains(HISTORY_STORE)) {
const historyStore = db.createObjectStore(HISTORY_STORE, { keyPath: 'id', autoIncrement: true });
historyStore.createIndex(HISTORY_INDEX, 'startedAt');
}
if (!db.objectStoreNames.contains(RATINGS_STORE)) {
db.createObjectStore(RATINGS_STORE);
}
if (!db.objectStoreNames.contains(PLAY_COUNTS_STORE)) {
db.createObjectStore(PLAY_COUNTS_STORE);
}
};
req.onsuccess = () => resolve(req.result);
}).catch(err => {
console.error('Failed opening handle DB', err);
handleDbPromise = null;
return null;
});
}
return handleDbPromise;
};
const putStoreValue = async (key, value) => {
const db = await getHandleDb();
if (!db) return Promise.resolve();
return new Promise((resolve, reject) => {
const tx = db.transaction(STORE_NAME, 'readwrite');
tx.objectStore(STORE_NAME).put(value, key);
tx.oncomplete = resolve;
tx.onerror = () => reject(tx.error);
});
};
const getStoreValue = async (key) => {
const db = await getHandleDb();
if (!db) return undefined;
return await new Promise((resolve, reject) => {
const tx = db.transaction(STORE_NAME, 'readonly');
const req = tx.objectStore(STORE_NAME).get(key);
req.onsuccess = () => resolve(req.result);
req.onerror = () => reject(req.error);
});
};
const setTrackRating = async (trackKey, rating) => {
const db = await getHandleDb();
if (!db) return;
await new Promise((resolve, reject) => {
const tx = db.transaction(RATINGS_STORE, 'readwrite');
tx.objectStore(RATINGS_STORE).put(rating, trackKey);
tx.oncomplete = resolve;
tx.onerror = () => reject(tx.error);
});
trackRatings.set(trackKey, rating);
};
const getTrackRating = async (trackKey) => {
const db = await getHandleDb();
if (!db) return 0;
return await new Promise((resolve, reject) => {
const tx = db.transaction(RATINGS_STORE, 'readonly');
const req = tx.objectStore(RATINGS_STORE).get(trackKey);
req.onsuccess = () => resolve(req.result ?? 0);
req.onerror = () => reject(req.error);
});
};
const loadAllRatings = async () => {
const db = await getHandleDb();
if (!db) return;
return await new Promise((resolve, reject) => {
const tx = db.transaction(RATINGS_STORE, 'readonly');
const store = tx.objectStore(RATINGS_STORE);
const req = store.openCursor();
req.onsuccess = (event) => {
const cursor = event.target.result;
if (cursor) {
trackRatings.set(cursor.key, cursor.value);
cursor.continue();
}
};
tx.oncomplete = () => resolve();
tx.onerror = () => reject(tx.error);
});
};
const getPlayCount = async (trackKey) => {
const db = await getHandleDb();
if (!db) return 0;
return await new Promise((resolve, reject) => {
const tx = db.transaction(PLAY_COUNTS_STORE, 'readonly');
const req = tx.objectStore(PLAY_COUNTS_STORE).get(trackKey);
req.onsuccess = () => resolve(req.result ?? 0);
req.onerror = () => reject(req.error);
});
};
const incrementPlayCount = async (trackKey) => {
const db = await getHandleDb();
if (!db) return 0;
const currentCount = await getPlayCount(trackKey);
const newCount = currentCount + 1;
await new Promise((resolve, reject) => {
const tx = db.transaction(PLAY_COUNTS_STORE, 'readwrite');
tx.objectStore(PLAY_COUNTS_STORE).put(newCount, trackKey);
tx.oncomplete = resolve;
tx.onerror = () => reject(tx.error);
});
trackPlayCounts.set(trackKey, newCount);
return newCount;
};
const loadAllPlayCounts = async () => {
const db = await getHandleDb();
if (!db) return;
return await new Promise((resolve, reject) => {
const tx = db.transaction(PLAY_COUNTS_STORE, 'readonly');
const store = tx.objectStore(PLAY_COUNTS_STORE);
const req = store.openCursor();
req.onsuccess = (event) => {
const cursor = event.target.result;
if (cursor) {
trackPlayCounts.set(cursor.key, cursor.value);
cursor.continue();
}
};
tx.oncomplete = () => resolve();
tx.onerror = () => reject(tx.error);
});
};
const pruneHistoryEntries = async () => {
const db = await getHandleDb();
if (!db) return;
await new Promise((resolve, reject) => {
const tx = db.transaction(HISTORY_STORE, 'readwrite');
const store = tx.objectStore(HISTORY_STORE);
const index = store.index(HISTORY_INDEX);
let kept = 0;
const cursorReq = index.openCursor(null, 'prev');
cursorReq.onsuccess = (event) => {
const cursor = event.target.result;
if (!cursor) return;
if (kept >= HISTORY_MAX_ENTRIES) {
cursor.delete();
} else {
kept += 1;
}
cursor.continue();
};
cursorReq.onerror = () => reject(cursorReq.error);
tx.oncomplete = resolve;
tx.onerror = () => reject(tx.error);
});
};
const fetchRecentHistory = async (limit = HISTORY_RENDER_LIMIT) => {
const db = await getHandleDb();
if (!db) return [];
return await new Promise((resolve, reject) => {
const tx = db.transaction(HISTORY_STORE, 'readonly');
const store = tx.objectStore(HISTORY_STORE);
const index = store.index(HISTORY_INDEX);
const results = [];
const cursorReq = index.openCursor(null, 'prev');
cursorReq.onsuccess = (event) => {
const cursor = event.target.result;
if (!cursor) return;
if (results.length < limit) {
results.push(cursor.value);
cursor.continue();
}
};
cursorReq.onerror = () => reject(cursorReq.error);
tx.oncomplete = () => resolve(results);
tx.onerror = () => reject(tx.error);
});
};
const prependHistoryEntry = (entry) => {
historyEntries = [entry, ...historyEntries].slice(0, HISTORY_RENDER_LIMIT);
requestHistoryRender();
};
const deleteHistoryEntryById = async (id) => {
const db = await getHandleDb();
if (!db) return;
await new Promise((resolve, reject) => {
const tx = db.transaction(HISTORY_STORE, 'readwrite');
tx.objectStore(HISTORY_STORE).delete(id);
tx.oncomplete = resolve;
tx.onerror = () => reject(tx.error);
});
};
const clearHistoryStore = async () => {
const db = await getHandleDb();
if (!db) return;
await new Promise((resolve, reject) => {
const tx = db.transaction(HISTORY_STORE, 'readwrite');