File size: 33,696 Bytes
f3e872c
 
 
 
 
daa2f53
f3e872c
 
daa2f53
f3e872c
daa2f53
 
 
f3e872c
daa2f53
 
f3e872c
daa2f53
 
 
 
 
 
 
 
 
f3e872c
daa2f53
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f3e872c
d827615
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f3e872c
 
 
 
 
daa2f53
 
 
f3e872c
daa2f53
 
f3e872c
 
 
daa2f53
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d827615
 
 
f3e872c
d827615
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f3e872c
d827615
 
 
f3e872c
d827615
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f3e872c
d827615
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f3e872c
d827615
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f3e872c
d827615
f3e872c
d827615
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f3e872c
d827615
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f3e872c
 
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
<!DOCTYPE html>
<html lang="fr">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>YouTube DJ Remix Station</title>
    <script src="https://cdn.tailwindcss.com"></script>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <script src="https://www.youtube.com/iframe_api"></script>
    <style>
        @keyframes spin {
            0% { transform: rotate(0deg); }
            100% { transform: rotate(360deg); }
        }
        .vinyl-spin {
            animation: spin 2s linear infinite;
        }
        .knob {
            -webkit-appearance: none;
            width: 100%;
            height: 15px;
            background: #4b5563;
            outline: none;
            opacity: 0.7;
            transition: opacity .2s;
            border-radius: 10px;
        }
        .knob:hover {
            opacity: 1;
        }
        .knob::-webkit-slider-thumb {
            -webkit-appearance: none;
            appearance: none;
            width: 25px;
            height: 25px;
            border-radius: 50%;
            background: #3b82f6;
            cursor: pointer;
        }
        .crossfader {
            -webkit-appearance: none;
            height: 10px;
            background: linear-gradient(to right, #ef4444, #3b82f6);
            outline: none;
            border-radius: 5px;
        }
        .crossfader::-webkit-slider-thumb {
            -webkit-appearance: none;
            appearance: none;
            width: 30px;
            height: 30px;
            border-radius: 50%;
            background: white;
            cursor: pointer;
            box-shadow: 0 0 5px rgba(0,0,0,0.5);
        }
        .eq-slider {
            -webkit-appearance: slider-vertical;
            width: 10px;
            height: 100px;
            background: #4b5563;
            outline: none;
            border-radius: 5px;
        }
        .eq-slider::-webkit-slider-thumb {
            -webkit-appearance: none;
            appearance: none;
            width: 20px;
            height: 20px;
            border-radius: 50%;
            background: #3b82f6;
            cursor: pointer;
        }
        .waveform {
            height: 60px;
            background: linear-gradient(90deg, #3b82f6, #3b82f6 0%, transparent 0%);
            transition: background 0.1s;
        }
        .deck-active {
            box-shadow: 0 0 20px rgba(59, 130, 246, 0.5);
        }
        .search-loading {
            position: relative;
        }
        .search-loading::after {
            content: "";
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            width: 20px;
            height: 20px;
            border: 2px solid rgba(255,255,255,0.3);
            border-radius: 50%;
            border-top-color: #3b82f6;
            animation: spin 1s linear infinite;
        }
    </style>
</head>
<body class="bg-gray-900 text-white min-h-screen font-sans">
    <div class="container mx-auto px-4 py-8">
        <!-- Header -->
        <header class="text-center mb-8">
            <h1 class="text-4xl md:text-5xl font-bold mb-2 bg-gradient-to-r from-blue-400 to-purple-600 bg-clip-text text-transparent">
                YouTube DJ Remix Station
            </h1>
            <p class="text-lg text-gray-300">
                Mix and remix YouTube tracks like a pro DJ
            </p>
        </header>

        <!-- Main DJ Interface -->
        <div class="bg-gray-800 rounded-xl p-6 mb-8 shadow-xl">
            <!-- Crossfader -->
            <div class="mb-6">
                <div class="flex justify-between items-center mb-2">
                    <span class="text-red-400 font-medium"><i class="fas fa-volume-up mr-2"></i>Deck A</span>
                    <span class="text-blue-400 font-medium">Deck B<i class="fas fa-volume-up ml-2"></i></span>
                </div>
                <input type="range" min="0" max="100" value="50" class="crossfader w-full" id="crossfader">
            </div>

            <!-- Dual Decks -->
            <div class="grid grid-cols-1 lg:grid-cols-2 gap-6">
                <!-- Deck A -->
                <div class="bg-gray-700 rounded-lg p-4 deck" id="deckA">
                    <div class="flex items-center mb-4">
                        <div class="relative w-24 h-24 mr-4">
                            <div class="absolute inset-0 bg-gray-900 rounded-full flex items-center justify-center vinyl-spin" id="vinylA">
                                <div class="w-8 h-8 bg-gray-800 rounded-full"></div>
                            </div>
                            <div class="absolute inset-0 flex items-center justify-center">
                                <i class="fas fa-compact-disc text-4xl text-blue-400 opacity-70"></i>
                            </div>
                        </div>
                        <div class="flex-1">
                            <h3 class="text-xl font-bold" id="trackTitleA">No track loaded</h3>
                            <div class="waveform bg-gray-600 rounded my-2" id="waveformA"></div>
                            <div class="flex justify-between text-sm text-gray-400">
                                <span id="timeA">0:00</span>
                                <span id="durationA">0:00</span>
                            </div>
                        </div>
                    </div>
                    
                    <div class="grid grid-cols-3 gap-4 mb-4">
                        <div>
                            <label class="block text-sm text-gray-400 mb-1">BPM</label>
                            <input type="range" min="50" max="200" value="120" class="knob w-full" id="bpmA">
                            <div class="text-center mt-1 text-sm" id="bpmValueA">120</div>
                        </div>
                        <div>
                            <label class="block text-sm text-gray-400 mb-1">Pitch</label>
                            <input type="range" min="-12" max="12" value="0" class="knob w-full" id="pitchA">
                            <div class="text-center mt-1 text-sm" id="pitchValueA">0</div>
                        </div>
                        <div>
                            <label class="block text-sm text-gray-400 mb-1">Volume</label>
                            <input type="range" min="0" max="100" value="80" class="knob w-full" id="volumeA">
                            <div class="text-center mt-1 text-sm" id="volumeValueA">80</div>
                        </div>
                    </div>
                    
                    <div class="grid grid-cols-4 gap-2 mb-4">
                        <button class="bg-blue-600 hover:bg-blue-700 text-white p-2 rounded" id="playA">
                            <i class="fas fa-play"></i>
                        </button>
                        <button class="bg-gray-600 hover:bg-gray-500 text-white p-2 rounded" id="pauseA">
                            <i class="fas fa-pause"></i>
                        </button>
                        <button class="bg-gray-600 hover:bg-gray-500 text-white p-2 rounded" id="stopA">
                            <i class="fas fa-stop"></i>
                        </button>
                        <button class="bg-red-600 hover:bg-red-700 text-white p-2 rounded" id="cueA">
                            <i class="fas fa-undo"></i>
                        </button>
                    </div>
                    
                    <div class="grid grid-cols-3 gap-2">
                        <button class="effect-btn bg-purple-600 hover:bg-purple-700 text-white p-2 rounded text-sm" data-effect="filter">
                            <i class="fas fa-filter mr-1"></i> Filter
                        </button>
                        <button class="effect-btn bg-purple-600 hover:bg-purple-700 text-white p-2 rounded text-sm" data-effect="echo">
                            <i class="fas fa-echo mr-1"></i> Echo
                        </button>
                        <button class="effect-btn bg-purple-600 hover:bg-purple-700 text-white p-2 rounded text-sm" data-effect="flanger">
                            <i class="fas fa-wave-square mr-1"></i> Flanger
                        </button>
                    </div>
                </div>
                
                <!-- Deck B -->
                <div class="bg-gray-700 rounded-lg p-4 deck" id="deckB">
                    <div class="flex items-center mb-4">
                        <div class="relative w-24 h-24 mr-4">
                            <div class="absolute inset-0 bg-gray-900 rounded-full flex items-center justify-center" id="vinylB">
                                <div class="w-8 h-8 bg-gray-800 rounded-full"></div>
                            </div>
                            <div class="absolute inset-0 flex items-center justify-center">
                                <i class="fas fa-compact-disc text-4xl text-blue-400 opacity-70"></i>
                            </div>
                        </div>
                        <div class="flex-1">
                            <h3 class="text-xl font-bold" id="trackTitleB">No track loaded</h3>
                            <div class="waveform bg-gray-600 rounded my-2" id="waveformB"></div>
                            <div class="flex justify-between text-sm text-gray-400">
                                <span id="timeB">0:00</span>
                                <span id="durationB">0:00</span>
                            </div>
                        </div>
                    </div>
                    
                    <div class="grid grid-cols-3 gap-4 mb-4">
                        <div>
                            <label class="block text-sm text-gray-400 mb-1">BPM</label>
                            <input type="range" min="50" max="200" value="120" class="knob w-full" id="bpmB">
                            <div class="text-center mt-1 text-sm" id="bpmValueB">120</div>
                        </div>
                        <div>
                            <label class="block text-sm text-gray-400 mb-1">Pitch</label>
                            <input type="range" min="-12" max="12" value="0" class="knob w-full" id="pitchB">
                            <div class="text-center mt-1 text-sm" id="pitchValueB">0</div>
                        </div>
                        <div>
                            <label class="block text-sm text-gray-400 mb-1">Volume</label>
            <input type="range" min="0" max="100" value="80" class="knob w-full" id="volumeB">
            <div class="text-center mt-1 text-sm" id="volumeValueB">80</div>
          </div>
        </div>
        
        <div class="grid grid-cols-4 gap-2 mb-4">
          <button class="bg-blue-600 hover:bg-blue-700 text-white p-2 rounded" id="playB">
            <i class="fas fa-play"></i>
          </button>
          <button class="bg-gray-600 hover:bg-gray-500 text-white p-2 rounded" id="pauseB">
            <i class="fas fa-pause"></i>
          </button>
          <button class="bg-gray-600 hover:bg-gray-500 text-white p-2 rounded" id="stopB">
            <i class="fas fa-stop"></i>
          </button>
          <button class="bg-red-600 hover:bg-red-700 text-white p-2 rounded" id="cueB">
            <i class="fas fa-undo"></i>
          </button>
        </div>
        
        <div class="grid grid-cols-3 gap-2">
          <button class="effect-btn bg-purple-600 hover:bg-purple-700 text-white p-2 rounded text-sm" data-effect="filter">
            <i class="fas fa-filter mr-1"></i> Filter
          </button>
          <button class="effect-btn bg-purple-600 hover:bg-purple-700 text-white p-2 rounded text-sm" data-effect="echo">
            <i class="fas fa-echo mr-1"></i> Echo
          </button>
          <button class="effect-btn bg-purple-600 hover:bg-purple-700 text-white p-2 rounded text-sm" data-effect="flanger">
            <i class="fas fa-wave-square mr-1"></i> Flanger
          </button>
        </div>
      </div>
    </div>
  </div>

  <!-- Track Search and Load -->
  <div class="bg-gray-800 rounded-xl p-6 mb-8 shadow-xl">
    <h2 class="text-2xl font-bold mb-4">Load YouTube Tracks</h2>
    
    <div class="grid grid-cols-1 md:grid-cols-2 gap-6">
      <!-- Deck A Load -->
      <div>
        <h3 class="text-xl font-medium mb-2 text-blue-400">Deck A</h3>
        <div class="flex mb-4">
          <input type="text" id="searchA" placeholder="Search YouTube..." class="flex-1 bg-gray-700 text-white px-4 py-2 rounded-l focus:outline-none focus:ring-2 focus:ring-blue-500">
          <button class="bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 rounded-r" id="searchBtnA">
            <i class="fas fa-search"></i>
          </button>
        </div>
        <div class="h-64 overflow-y-auto bg-gray-700 rounded p-2 mb-2" id="resultsA">
          <p class="text-gray-400 text-center py-20">Search for YouTube tracks to load</p>
        </div>
        <button class="w-full bg-green-600 hover:bg-green-700 text-white py-2 rounded" id="loadA">
          <i class="fas fa-arrow-down mr-2"></i> Load to Deck A
        </button>
      </div>
      
      <!-- Deck B Load -->
      <div>
        <h3 class="text-xl font-medium mb-2 text-blue-400">Deck B</h3>
        <div class="flex mb-4">
          <input type="text" id="searchB" placeholder="Search YouTube..." class="flex-1 bg-gray-700 text-white px-4 py-2 rounded-l focus:outline-none focus:ring-2 focus:ring-blue-500">
          <button class="bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 rounded-r" id="searchBtnB">
            <i class="fas fa-search"></i>
          </button>
        </div>
        <div class="h-64 overflow-y-auto bg-gray-700 rounded p-2 mb-2" id="resultsB">
          <p class="text-gray-400 text-center py-20">Search for YouTube tracks to load</p>
        </div>
        <button class="w-full bg-green-600 hover:bg-green-700 text-white py-2 rounded" id="loadB">
          <i class="fas fa-arrow-down mr-2"></i> Load to Deck B
        </button>
      </div>
    </div>
  </div>

  <!-- EQ Controls -->
  <div class="bg-gray-800 rounded-xl p-6 shadow-xl">
    <h2 class="text-2xl font-bold mb-4">Equalizer</h2>
    
    <div class="grid grid-cols-2 md:grid-cols-4 lg:grid-cols-6 gap-6">
      <!-- Deck A EQ -->
      <div class="bg-gray-700 rounded-lg p-4">
        <h3 class="text-lg font-medium mb-3 text-center text-blue-400">Deck A</h3>
        <div class="flex justify-around">
          <div class="flex flex-col items-center">
            <label class="text-sm text-gray-400 mb-2">Low</label>
            <input type="range" min="0" max="100" value="50" class="eq-slider" id="eqLowA">
          </div>
          <div class="flex flex-col items-center">
            <label class="text-sm text-gray-400 mb-2">Mid</label>
            <input type="range" min="0" max="100" value="50" class="eq-slider" id="eqMidA">
          </div>
          <div class="flex flex-col items-center">
            <label class="text-sm text-gray-400 mb-2">High</label>
            <input type="range" min="0" max="100" value="50" class="eq-slider" id="eqHighA">
          </div>
        </div>
      </div>
      
      <!-- Deck B EQ -->
      <div class="bg-gray-700 rounded-lg p-4">
        <h3 class="text-lg font-medium mb-3 text-center text-blue-400">Deck B</h3>
        <div class="flex justify-around">
          <div class="flex flex-col items-center">
            <label class="text-sm text-gray-400 mb-2">Low</label>
            <input type="range" min="0" max="100" value="50" class="eq-slider" id="eqLowB">
          </div>
          <div class="flex flex-col items-center">
            <label class="text-sm text-gray-400 mb-2">Mid</label>
            <input type="range" min="0" max="100" value="50" class="eq-slider" id="eqMidB">
          </div>
          <div class="flex flex-col items-center">
            <label class="text-sm text-gray-400 mb-2">High</label>
            <input type="range" min="0" max="100" value="50" class="eq-slider" id="eqHighB">
          </div>
        </div>
      </div>
      
      <!-- Master EQ -->
      <div class="bg-gray-700 rounded-lg p-4 col-span-2 md:col-span-4 lg:col-span-2">
        <h3 class="text-lg font-medium mb-3 text-center text-purple-400">Master Output</h3>
        <div class="flex justify-around">
          <div class="flex flex-col items-center">
            <label class="text-sm text-gray-400 mb-2">Low</label>
            <input type="range" min="0" max="100" value="50" class="eq-slider" id="eqLowMaster">
          </div>
          <div class="flex flex-col items-center">
            <label class="text-sm text-gray-400 mb-2">Mid</label>
            <input type="range" min="0" max="100" value="50" class="eq-slider" id="eqMidMaster">
          </div>
          <div class="flex flex-col items-center">
            <label class="text-sm text-gray-400 mb-2">High</label>
            <input type="range" min="0" max="100" value="50" class="eq-slider" id="eqHighMaster">
          </div>
          <div class="flex flex-col items-center">
            <label class="text-sm text-gray-400 mb-2">Volume</label>
            <input type="range" min="0" max="100" value="80" class="eq-slider" id="eqVolumeMaster">
          </div>
        </div>
      </div>
    </div>
  </div>

  <!-- Footer -->
  <footer class="mt-12 text-center text-gray-400 text-sm">
    <p>© 2023 YouTube DJ Remix Station - For educational purposes only</p>
    <p class="mt-2">Made with <i class="fas fa-heart text-red-500"></i> for music lovers</p>
  </footer>
</div>

<script>
  document.addEventListener('DOMContentLoaded', function() {
    // YouTube API setup
    let youtubePlayers = {
      A: null,
      B: null
    };
    
    let currentDeck = 'A';
    let crossfaderValue = 50;
    let searchResults = {
      A: [],
      B: []
    };
    let selectedTrack = {
      A: null,
      B: null
    };
    let trackProgress = {
      A: 0,
      B: 0
    };
    let trackDuration = {
      A: 0,
      B: 0
    };
    let isPlaying = {
      A: false,
      B: false
    };
    
    // Sample music database for demo purposes
    const musicDatabase = [
      {
        id: 'dQw4w9WgXcQ',
        title: 'Never Gonna Give You Up - Rick Astley',
        thumbnail: 'https://i.ytimg.com/vi/dQw4w9WgXcQ/default.jpg',
        duration: '3:32'
      },
      {
        id: '9bZkp7q19f0',
        title: 'Gangnam Style - PSY',
        thumbnail: 'https://i.ytimg.com/vi/9bZkp7q19f0/default.jpg',
        duration: '4:13'
      },
      {
        id: 'kJQP7kiw5Fk',
        title: 'Despacito - Luis Fonsi ft. Daddy Yankee',
        thumbnail: 'https://i.ytimg.com/vi/kJQP7kiw5Fk/default.jpg',
        duration: '3:47'
      },
      {
        id: 'JGwWNGJdvx8',
        title: 'Shape of You - Ed Sheeran',
        thumbnail: 'https://i.ytimg.com/vi/JGwWNGJdvx8/default.jpg',
        duration: '3:53'
      },
      {
        id: 'RgKAFK5djSk',
        title: 'See You Again - Wiz Khalifa ft. Charlie Puth',
        thumbnail: 'https://i.ytimg.com/vi/RgKAFK5djSk/default.jpg',
        duration: '3:49'
      },
      {
        id: 'OPf0YbXqDm0',
        title: 'Uptown Funk - Mark Ronson ft. Bruno Mars',
        thumbnail: 'https://i.ytimg.com/vi/OPf0YbXqDm0/default.jpg',
        duration: '4:30'
      },
      {
        id: 'AJtDXIazrMo',
        title: 'Blinding Lights - The Weeknd',
        thumbnail: 'https://i.ytimg.com/vi/AJtDXIazrMo/default.jpg',
        duration: '3:20'
      },
      {
        id: 'kXAvbHPdTZ0',
        title: 'Dance Monkey - Tones and I',
        thumbnail: 'https://i.ytimg.com/vi/kXAvbHPdTZ0/default.jpg',
        duration: '3:29'
      },
      {
        id: '2Vv-BfVoq4g',
        title: 'Perfect - Ed Sheeran',
        thumbnail: 'https://i.ytimg.com/vi/2Vv-BfVoq4g/default.jpg',
        duration: '4:23'
      },
      {
        id: 'pRpeEdMmmQ0',
        title: 'Closer - The Chainsmokers ft. Halsey',
        thumbnail: 'https://i.ytimg.com/vi/pRpeEdMmmQ0/default.jpg',
        duration: '4:04'
      }
    ];
    
    // Initialize YouTube API
    function onYouTubeIframeAPIReady() {
      // Players will be created when tracks are loaded
    }
    
    // Create YouTube player for a deck
    function createPlayer(deckId, videoId) {
      if (youtubePlayers[deckId]) {
        youtubePlayers[deckId].destroy();
      }
      
      youtubePlayers[deckId] = new YT.Player(`player${deckId}`, {
        height: '0',
        width: '0',
        videoId: videoId,
        playerVars: {
          'autoplay': 0,
          'controls': 0,
          'disablekb': 1,
          'enablejsapi': 1,
          'fs': 0,
          'iv_load_policy': 3,
          'modestbranding': 1,
          'rel': 0
        },
        events: {
          'onReady': onPlayerReady.bind(null, deckId),
          'onStateChange': onPlayerStateChange.bind(null, deckId)
        }
      });
    }
    
    function onPlayerReady(deckId, event) {
      console.log(`Player ${deckId} ready`);
      trackDuration[deckId] = youtubePlayers[deckId].getDuration();
      updateDurationDisplay(deckId);
      
      // Set initial volume based on crossfader
      updateVolume(deckId);
    }
    
    function onPlayerStateChange(deckId, event) {
      if (event.data == YT.PlayerState.PLAYING) {
        isPlaying[deckId] = true;
        document.getElementById(`vinyl${deckId}`).classList.add('vinyl-spin');
        document.getElementById(`deck${deckId}`).classList.add('deck-active');
        updateProgress(deckId);
      } else if (event.data == YT.PlayerState.PAUSED) {
        isPlaying[deckId] = false;
        document.getElementById(`vinyl${deckId}`).classList.remove('vinyl-spin');
        document.getElementById(`deck${deckId}`).classList.remove('deck-active');
      } else if (event.data == YT.PlayerState.ENDED) {
        isPlaying[deckId] = false;
        document.getElementById(`vinyl${deckId}`).classList.remove('vinyl-spin');
        document.getElementById(`deck${deckId}`).classList.remove('deck-active');
      }
    }
    
    // Update track progress
    function updateProgress(deckId) {
      if (isPlaying[deckId]) {
        trackProgress[deckId] = youtubePlayers[deckId].getCurrentTime();
        updateTimeDisplay(deckId);
        
        // Update waveform visualization
        const progressPercent = (trackProgress[deckId] / trackDuration[deckId]) * 100;
        document.getElementById(`waveform${deckId}`).style.background = 
          `linear-gradient(90deg, #3b82f6, #3b82f6 ${progressPercent}%, transparent ${progressPercent}%)`;
        
        requestAnimationFrame(() => updateProgress(deckId));
      }
    }
    
    // Format time (seconds to MM:SS)
    function formatTime(seconds) {
      const mins = Math.floor(seconds / 60);
      const secs = Math.floor(seconds % 60);
      return `${mins}:${secs < 10 ? '0' : ''}${secs}`;
    }
    
    function updateTimeDisplay(deckId) {
      document.getElementById(`time${deckId}`).textContent = formatTime(trackProgress[deckId]);
    }
    
    function updateDurationDisplay(deckId) {
      document.getElementById(`duration${deckId}`).textContent = formatTime(trackDuration[deckId]);
    }
    
    // Update volume based on crossfader
    function updateVolume(deckId) {
      if (!youtubePlayers[deckId]) return;
      
      const volumeControl = parseInt(document.getElementById(`volume${deckId}`).value);
      let volume;
      
      if (deckId === 'A') {
        volume = volumeControl * (crossfaderValue / 100);
      } else {
        volume = volumeControl * ((100 - crossfaderValue) / 100);
      }
      
      youtubePlayers[deckId].setVolume(volume);
      document.getElementById(`volumeValue${deckId}`).textContent = Math.round(volume);
    }
    
    // Search YouTube (simulated with our music database)
    async function searchYouTube(query, deckId) {
      if (!query) {
        document.getElementById(`results${deckId}`).innerHTML = 
          '<p class="text-gray-400 text-center py-20">Please enter a search term</p>';
        return;
      }
      
      // Show loading indicator
      const resultsContainer = document.getElementById(`results${deckId}`);
      resultsContainer.innerHTML = '<div class="search-loading"></div>';
      
      // Simulate API delay
      setTimeout(() => {
        // Filter our music database for matching tracks
        const filteredResults = musicDatabase.filter(track => 
          track.title.toLowerCase().includes(query.toLowerCase())
        );
        
        searchResults[deckId] = filteredResults;
        displayResults(deckId);
      }, 800);
    }
    
    // Display search results
    function displayResults(deckId) {
      const resultsContainer = document.getElementById(`results${deckId}`);
      
      if (searchResults[deckId].length === 0) {
        resultsContainer.innerHTML = `
          <p class="text-gray-400 text-center py-20">
            No results found for your search.<br>
            Try different keywords.
          </p>
        `;
        return;
      }
      
      let html = '';
      searchResults[deckId].forEach((result, index) => {
        html += `
          <div class="flex items-center p-2 mb-2 bg-gray-600 rounded cursor-pointer hover:bg-gray-500 result-item" 
               data-index="${index}" data-deck="${deckId}">
            <img src="${result.thumbnail}" alt="${result.title}" class="w-16 h-12 mr-3">
            <div class="flex-1">
              <h4 class="font-medium text-sm line-clamp-1">${result.title}</h4>
              <p class="text-gray-400 text-xs">${result.duration}</p>
            </div>
            <i class="fas fa-music text-gray-400 ml-2"></i>
          </div>
        `;
      });
      
      resultsContainer.innerHTML = html;
      
      // Add click handlers to result items
      document.querySelectorAll(`#results${deckId} .result-item`).forEach(item => {
        item.addEventListener('click', function() {
          const index = this.getAttribute('data-index');
          const deck = this.getAttribute('data-deck');
          selectTrack(index, deck);
        });
      });
    }
    
    // Select a track from search results
    function selectTrack(index, deckId) {
      selectedTrack[deckId] = searchResults[deckId][index];
      
      // Update UI
      document.getElementById(`trackTitle${deckId}`).textContent = selectedTrack[deckId].title;
      
      // Highlight selected track
      document.querySelectorAll(`#results${deckId} .result-item`).forEach(item => {
        item.classList.remove('bg-blue-600');
      });
      document.querySelector(`#results${deckId} .result-item[data-index="${index}"]`).classList.add('bg-blue-600');
    }
    
    // Load selected track to deck
    function loadTrack(deckId) {
      if (!selectedTrack[deckId]) {
        alert('Please select a track first');
        return;
      }
      
      createPlayer(deckId, selectedTrack[deckId].id);
      
      // Reset track progress
      trackProgress[deckId] = 0;
      trackDuration[deckId] = 0;
      document.getElementById(`waveform${deckId}`).style.background = 'linear-gradient(90deg, #3b82f6, #3b82f6 0%, transparent 0%)';
      document.getElementById(`time${deckId}`).textContent = '0:00';
      document.getElementById(`duration${deckId}`).textContent = '0:00';
      
      // Enable deck controls
      document.getElementById(`deck${deckId}`).querySelectorAll('button, input').forEach(el => {
        el.disabled = false;
      });
    }
    
    // Event listeners for deck controls
    document.getElementById('playA').addEventListener('click', () => {
      if (youtubePlayers.A) youtubePlayers.A.playVideo();
    });
    document.getElementById('pauseA').addEventListener('click', () => {
      if (youtubePlayers.A) youtubePlayers.A.pauseVideo();
    });
    document.getElementById('stopA').addEventListener('click', () => {
      if (youtubePlayers.A) {
        youtubePlayers.A.stopVideo();
        trackProgress.A = 0;
        updateTimeDisplay('A');
        document.getElementById('waveformA').style.background = 'linear-gradient(90deg, #3b82f6, #3b82f6 0%, transparent 0%)';
      }
    });
    document.getElementById('cueA').addEventListener('click', () => {
      if (youtubePlayers.A) {
        youtubePlayers.A.seekTo(0);
        trackProgress.A = 0;
        updateTimeDisplay('A');
        document.getElementById('waveformA').style.background = 'linear-gradient(90deg, #3b82f6, #3b82f6 0%, transparent 0%)';
      }
    });
    
    document.getElementById('playB').addEventListener('click', () => {
      if (youtubePlayers.B) youtubePlayers.B.playVideo();
    });
    document.getElementById('pauseB').addEventListener('click', () => {
      if (youtubePlayers.B) youtubePlayers.B.pauseVideo();
    });
    document.getElementById('stopB').addEventListener('click', () => {
      if (youtubePlayers.B) {
        youtubePlayers.B.stopVideo();
        trackProgress.B = 0;
        updateTimeDisplay('B');
        document.getElementById('waveformB').style.background = 'linear-gradient(90deg, #3b82f6, #3b82f6 0%, transparent 0%)';
      }
    });
    document.getElementById('cueB').addEventListener('click', () => {
      if (youtubePlayers.B) {
        youtubePlayers.B.seekTo(0);
        trackProgress.B = 0;
        updateTimeDisplay('B');
        document.getElementById('waveformB').style.background = 'linear-gradient(90deg, #3b82f6, #3b82f6 0%, transparent 0%)';
      }
    });
    
    // Crossfader control
    document.getElementById('crossfader').addEventListener('input', function() {
      crossfaderValue = parseInt(this.value);
      updateVolume('A');
      updateVolume('B');
    });
    
    // Volume controls
    document.getElementById('volumeA').addEventListener('input', function() {
      document.getElementById('volumeValueA').textContent = this.value;
      updateVolume('A');
    });
    
    document.getElementById('volumeB').addEventListener('input', function() {
      document.getElementById('volumeValueB').textContent = this.value;
      updateVolume('B');
    });
    
    // BPM controls
    document.getElementById('bpmA').addEventListener('input', function() {
      document.getElementById('bpmValueA').textContent = this.value;
      // In a real app, you would adjust playback rate here
    });
    
    document.getElementById('bpmB').addEventListener('input', function() {
      document.getElementById('bpmValueB').textContent = this.value;
      // In a real app, you would adjust playback rate here
    });
    
    // Pitch controls
    document.getElementById('pitchA').addEventListener('input', function() {
      document.getElementById('pitchValueA').textContent = this.value;
      // In a real app, you would adjust pitch here
    });
    
    document.getElementById('pitchB').addEventListener('input', function() {
      document.getElementById('pitchValueB').textContent = this.value;
      // In a real app, you would adjust pitch here
    });
    
    // Search controls
    document.getElementById('searchBtnA').addEventListener('click', () => {
      const query = document.getElementById('searchA').value;
      searchYouTube(query, 'A');
    });
    
    document.getElementById('searchBtnB').addEventListener('click', () => {
      const query = document.getElementById('searchB').value;
      searchYouTube(query, 'B');
    });
    
    // Also search when pressing Enter in search fields
    document.getElementById('searchA').addEventListener('keypress', function(e) {
      if (e.key === 'Enter') {
        const query = this.value;
        searchYouTube(query, 'A');
      }
    });
    
    document.getElementById('searchB').addEventListener('keypress', function(e) {
      if (e.key === 'Enter') {
        const query = this.value;
        searchYouTube(query, 'B');
      }
    });
    
    // Load controls
    document.getElementById('loadA').addEventListener('click', () => loadTrack('A'));
    document.getElementById('loadB').addEventListener('click', () => loadTrack('B'));
    
    // Effect buttons
    document.querySelectorAll('.effect-btn').forEach(btn => {
      btn.addEventListener('click', function() {
        const effect = this.getAttribute('data-effect');
        const deckId = this.closest('.deck').id.replace('deck', '');
        alert(`Applying ${effect} effect to Deck ${deckId}`);
        // In a real app, you would apply audio effects here
      });
    });
    
    // Initialize with disabled deck controls
    document.querySelectorAll('.deck button, .deck input').forEach(el => {
      el.disabled = true;
    });
    
    // Enable search controls
    document.querySelectorAll('#searchA, #searchB, #searchBtnA, #searchBtnB').forEach(el => {
      el.disabled = false;
    });
  });
</script>
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=wolfangus/soundboad" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
</html>