Spaces:
Running
Running
admin
commited on
Commit
·
cadab89
1
Parent(s):
3790e60
fix resize
Browse files- js/player.js +33 -4
js/player.js
CHANGED
@@ -41,10 +41,6 @@ function closeFullscreen() {
|
|
41 |
}
|
42 |
|
43 |
window.onload = function () {
|
44 |
-
$('#upl').hover(function () {
|
45 |
-
$(this).removeClass("first");
|
46 |
-
});
|
47 |
-
|
48 |
wrap.width = window.innerWidth - 1;
|
49 |
wrap.height = window.innerHeight - 1;
|
50 |
let canvasCtx = wrap.getContext("2d");
|
@@ -52,6 +48,11 @@ window.onload = function () {
|
|
52 |
let audioContext = new AudioContext();
|
53 |
canvasCtx.shadowColor = "white";
|
54 |
canvasCtx.shadowBlur = 10;
|
|
|
|
|
|
|
|
|
|
|
55 |
$('#bgFile').change(function () {
|
56 |
if (this.files.length <= 0) return;
|
57 |
if (this.files[0].size > 5242880) {
|
@@ -142,6 +143,34 @@ window.onload = function () {
|
|
142 |
canvasCtx.fillText(file.name.split('.mp3')[0], oW / 2, oH / 2);
|
143 |
requestAnimationFrame(drawSpectrum);
|
144 |
})();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
145 |
})
|
146 |
}
|
147 |
})
|
|
|
41 |
}
|
42 |
|
43 |
window.onload = function () {
|
|
|
|
|
|
|
|
|
44 |
wrap.width = window.innerWidth - 1;
|
45 |
wrap.height = window.innerHeight - 1;
|
46 |
let canvasCtx = wrap.getContext("2d");
|
|
|
48 |
let audioContext = new AudioContext();
|
49 |
canvasCtx.shadowColor = "white";
|
50 |
canvasCtx.shadowBlur = 10;
|
51 |
+
|
52 |
+
$('#upl').hover(function () {
|
53 |
+
$(this).removeClass("first");
|
54 |
+
});
|
55 |
+
|
56 |
$('#bgFile').change(function () {
|
57 |
if (this.files.length <= 0) return;
|
58 |
if (this.files[0].size > 5242880) {
|
|
|
143 |
canvasCtx.fillText(file.name.split('.mp3')[0], oW / 2, oH / 2);
|
144 |
requestAnimationFrame(drawSpectrum);
|
145 |
})();
|
146 |
+
|
147 |
+
$(window).resize(function () {
|
148 |
+
wrap.width = window.innerWidth - 1;
|
149 |
+
wrap.height = window.innerHeight - 1;
|
150 |
+
let oW = wrap.width;
|
151 |
+
let oH = wrap.height;
|
152 |
+
(function drawSpectrum() {
|
153 |
+
analyser.getByteFrequencyData(output);
|
154 |
+
canvasCtx.clearRect(0, 0, wrap.width, wrap.height);
|
155 |
+
for (let i = 0; i < 360; i++) {
|
156 |
+
let value = output[i] / 10;
|
157 |
+
canvasCtx.beginPath();
|
158 |
+
canvasCtx.lineWidth = W;
|
159 |
+
Rv1 = (R - value);
|
160 |
+
Rv2 = (R + value);
|
161 |
+
canvasCtx.moveTo((Math.sin((i * du) / 180 * Math.PI) * Rv1 + oW / 2), -Math.cos((i * du) / 180 * Math.PI) * Rv1 + oH / 2);
|
162 |
+
canvasCtx.lineTo((Math.sin((i * du) / 180 * Math.PI) * Rv2 + oW / 2), -Math.cos((i * du) / 180 * Math.PI) * Rv2 + oH / 2);
|
163 |
+
canvasCtx.strokeStyle = color1;
|
164 |
+
canvasCtx.stroke();
|
165 |
+
}
|
166 |
+
canvasCtx.font = "italic bold 20px Microsoft Yahei";
|
167 |
+
canvasCtx.fillStyle = color2;
|
168 |
+
canvasCtx.textAlign = "center";
|
169 |
+
canvasCtx.textBaseline = "middle";
|
170 |
+
canvasCtx.fillText(file.name.split('.mp3')[0], oW / 2, oH / 2);
|
171 |
+
requestAnimationFrame(drawSpectrum);
|
172 |
+
})();
|
173 |
+
});
|
174 |
})
|
175 |
}
|
176 |
})
|