admin commited on
Commit
a9f5b1e
·
1 Parent(s): 644e87e
Files changed (3) hide show
  1. css/musicvision.css +14 -7
  2. index.html +5 -5
  3. js/player.js +13 -13
css/musicvision.css CHANGED
@@ -6,17 +6,21 @@ td {
6
  }
7
 
8
  td:nth-child(2),
9
- td:nth-child(5) {
 
10
  text-align: right;
11
  }
12
 
13
  td:nth-child(1),
14
  td:nth-child(3),
15
- td:nth-child(4),
16
  td:nth-child(6) {
17
  text-align: left;
18
  }
19
 
 
 
 
 
20
  table {
21
  table-layout: fixed;
22
  }
@@ -57,6 +61,14 @@ p,
57
  color: white;
58
  }
59
 
 
 
 
 
 
 
 
 
60
  .bg {
61
  background-image: url('../src/bg.jpg');
62
  background-repeat: no-repeat;
@@ -72,11 +84,6 @@ p,
72
  z-index: -1;
73
  }
74
 
75
- #home {
76
- text-decoration: none;
77
- color: khaki;
78
- }
79
-
80
  td p,
81
  td a {
82
  font-size: x-small;
 
6
  }
7
 
8
  td:nth-child(2),
9
+ td:nth-child(5),
10
+ td:nth-child(7) {
11
  text-align: right;
12
  }
13
 
14
  td:nth-child(1),
15
  td:nth-child(3),
 
16
  td:nth-child(6) {
17
  text-align: left;
18
  }
19
 
20
+ td:nth-child(4) {
21
+ text-align: center;
22
+ }
23
+
24
  table {
25
  table-layout: fixed;
26
  }
 
61
  color: white;
62
  }
63
 
64
+ #bgFile {
65
+ text-align-last: right;
66
+ }
67
+
68
+ #startStop {
69
+ text-align: center;
70
+ }
71
+
72
  .bg {
73
  background-image: url('../src/bg.jpg');
74
  background-repeat: no-repeat;
 
84
  z-index: -1;
85
  }
86
 
 
 
 
 
 
87
  td p,
88
  td a {
89
  font-size: x-small;
index.html CHANGED
@@ -13,7 +13,7 @@
13
  <table border="0" width="100%">
14
  <tr>
15
  <td>
16
- <a href="javascript:recover_bg();" id="home">Restore to initial background</p>
17
  </td>
18
  <td>
19
  <p id="tip">Upload audio to be visualized👉</p>
@@ -22,16 +22,16 @@
22
  <input type="file" id="musicFile" accept=".mp3,.wav,.m4a,.flac">
23
  </td>
24
  <td>
25
- <input type="button" name="startStop" value="Pause" id="startStop">
26
  </td>
27
  <td>
28
- <p>Upload background image👉</p>
29
  </td>
30
  <td>
31
- <input type="file" id="bgFile" accept=".png,.jpg,.gif,.bmp">
32
  </td>
33
  <td>
34
- <button id="fullscreen">Fullscreen</button>
35
  </td>
36
  </tr>
37
  </table>
 
13
  <table border="0" width="100%">
14
  <tr>
15
  <td>
16
+ <button id="fullscreen">Fullscreen</button>
17
  </td>
18
  <td>
19
  <p id="tip">Upload audio to be visualized👉</p>
 
22
  <input type="file" id="musicFile" accept=".mp3,.wav,.m4a,.flac">
23
  </td>
24
  <td>
25
+ <input type="button" id="startStop" name="startStop" value="Pause">
26
  </td>
27
  <td>
28
+ <input type="file" id="bgFile" accept=".png,.jpg,.gif,.bmp">
29
  </td>
30
  <td>
31
+ <p>👈Upload background image</p>
32
  </td>
33
  <td>
34
+ <button id="home">Restore to initial background</button>
35
  </td>
36
  </tr>
37
  </table>
js/player.js CHANGED
@@ -30,7 +30,6 @@ function openFullscreen(elem) {
30
  } else if (elem.msRequestFullscreen) { // IE/Edge
31
  elem.msRequestFullscreen();
32
  }
33
- document.getElementById("fullscreen").innerText = zh_CN ? "退出全屏" : "Exit fullscreen";
34
  }
35
 
36
  // exit fullscreen
@@ -44,17 +43,12 @@ function closeFullscreen() {
44
  } else if (document.msExitFullscreen) { // IE/Edge
45
  document.msExitFullscreen();
46
  }
47
- document.getElementById("fullscreen").innerText = zh_CN ? "全屏" : "Fullscreen";
48
- }
49
-
50
- function isFullscreen() {
51
- return document.fullscreenElement || window.innerWidth === window.screen.width || window.innerHeight === window.screen.height;
52
  }
53
 
54
  function loadFullscreen() {
55
  // fullscreen related
56
  document.getElementById("fullscreen").addEventListener("click", function () {
57
- if (isFullscreen()) {
58
  closeFullscreen();
59
  } else {
60
  openFullscreen(document.documentElement);
@@ -62,14 +56,14 @@ function loadFullscreen() {
62
  });
63
 
64
  document.addEventListener('fullscreenchange', function () {
65
- if (isFullscreen()) {
66
  document.getElementById("fullscreen").innerText = zh_CN ? "退出全屏" : "Exit fullscreen";
67
  } else {
68
  document.getElementById("fullscreen").innerText = zh_CN ? "全屏" : "Fullscreen";
69
  }
70
  });
71
 
72
- if (isFullscreen()) {
73
  document.getElementById("fullscreen").innerText = zh_CN ? "退出全屏" : "Exit fullscreen";
74
  } else {
75
  document.getElementById("fullscreen").innerText = zh_CN ? "全屏" : "Fullscreen";
@@ -98,6 +92,10 @@ window.onload = function () {
98
  canvasCtx.shadowColor = "white";
99
  canvasCtx.shadowBlur = 10;
100
 
 
 
 
 
101
  $('#upl').hover(function () {
102
  $(this).removeClass("first");
103
  });
@@ -117,11 +115,13 @@ window.onload = function () {
117
  });
118
 
119
  $('#musicFile').change(function () {
120
- if (audioContext.state == 'running') {
121
- audioContext.close();
122
- audioContext = new AudioContext();
123
  }
124
- if (this.files.length == 0) return;
 
 
125
  let file = $('#musicFile')[0].files[0];
126
  let fileReader = new FileReader();
127
  fileReader.readAsArrayBuffer(file);
 
30
  } else if (elem.msRequestFullscreen) { // IE/Edge
31
  elem.msRequestFullscreen();
32
  }
 
33
  }
34
 
35
  // exit fullscreen
 
43
  } else if (document.msExitFullscreen) { // IE/Edge
44
  document.msExitFullscreen();
45
  }
 
 
 
 
 
46
  }
47
 
48
  function loadFullscreen() {
49
  // fullscreen related
50
  document.getElementById("fullscreen").addEventListener("click", function () {
51
+ if (document.fullscreenElement) {
52
  closeFullscreen();
53
  } else {
54
  openFullscreen(document.documentElement);
 
56
  });
57
 
58
  document.addEventListener('fullscreenchange', function () {
59
+ if (document.fullscreenElement) {
60
  document.getElementById("fullscreen").innerText = zh_CN ? "退出全屏" : "Exit fullscreen";
61
  } else {
62
  document.getElementById("fullscreen").innerText = zh_CN ? "全屏" : "Fullscreen";
63
  }
64
  });
65
 
66
+ if (document.fullscreenElement) {
67
  document.getElementById("fullscreen").innerText = zh_CN ? "退出全屏" : "Exit fullscreen";
68
  } else {
69
  document.getElementById("fullscreen").innerText = zh_CN ? "全屏" : "Fullscreen";
 
92
  canvasCtx.shadowColor = "white";
93
  canvasCtx.shadowBlur = 10;
94
 
95
+ $("#home").click(function () {
96
+ recover_bg();
97
+ });
98
+
99
  $('#upl').hover(function () {
100
  $(this).removeClass("first");
101
  });
 
115
  });
116
 
117
  $('#musicFile').change(function () {
118
+ if (this.files.length == 0) {
119
+ $("#tip").text(zh_CN ? "上传待可视化的音频👉" : "Upload audio to be visualized👉");
120
+ return;
121
  }
122
+ audioContext.close();
123
+ audioContext = new AudioContext();
124
+ $("#startStop").val(zh_CN ? '暂停' : 'Pause');
125
  let file = $('#musicFile')[0].files[0];
126
  let fileReader = new FileReader();
127
  fileReader.readAsArrayBuffer(file);