|
44 | 44 | </footer> |
45 | 45 | <script type="text/javascript"> |
46 | 46 | /* |
47 | | - *An audio spectrum visualizer built with HTML5 Audio API |
48 | | - *Author:Wayou |
49 | | - *License:feel free to use but keep this info please! |
50 | | - *Feb 15 2014 |
51 | | - *Need support you can : |
52 | | - *view the project page:https://github.com/Wayou/HTML5_Audio_Visualizer/ |
53 | | - *view online demo:http://wayouliu.duapp.com/mess/audio_visualizer.html |
54 | | - view the blog on how this is done:http://www.cnblogs.com/Wayou/p/html5_audio_api_visualizer.html |
55 | | - *or contact me:liuwayong@gmail.com |
| 47 | + * An audio spectrum visualizer built with HTML5 Audio API |
| 48 | + * Author:Wayou |
| 49 | + * License:feel free to use but keep this info please! |
| 50 | + * Feb 15, 2014 |
| 51 | + * For more infomation or support you can : |
| 52 | + * view the project page:https://github.com/Wayou/HTML5_Audio_Visualizer/ |
| 53 | + * view online demo:http://wayouliu.duapp.com/mess/audio_visualizer.html |
| 54 | + * view the blog on how this is done:http://www.cnblogs.com/Wayou/p/html5_audio_api_visualizer.html |
| 55 | + * or contact me:liuwayong@gmail.com |
56 | 56 | */ |
57 | 57 | window.onload = function() { |
58 | 58 | new Visualizer().ini(); |
|
82 | 82 | try { |
83 | 83 | this.audioContext = new AudioContext(); |
84 | 84 | } catch (e) { |
85 | | - that._updateInfo('!Your browser does not support AudioContext', false); |
| 85 | + this._updateInfo('!Your browser does not support AudioContext', false); |
86 | 86 | console.log(e); |
87 | 87 | } |
88 | 88 | }, |
|
109 | 109 | }; |
110 | 110 | //listen the drag & drop |
111 | 111 | dropContainer.addEventListener("dragenter", function() { |
| 112 | + document.getElementById('fileWrapper').style.opacity = 1; |
112 | 113 | that._updateInfo('Drop it on the page', true); |
113 | 114 | }, false); |
114 | 115 | dropContainer.addEventListener("dragover", function(e) { |
|
118 | 119 | e.dataTransfer.dropEffect = 'copy'; |
119 | 120 | }, false); |
120 | 121 | dropContainer.addEventListener("dragleave", function() { |
| 122 | + document.getElementById('fileWrapper').style.opacity = 0.2; |
121 | 123 | that._updateInfo(that.info, false); |
122 | 124 | }, false); |
123 | 125 | dropContainer.addEventListener("drop", function(e) { |
|
202 | 204 | canvas = document.getElementById('canvas'), |
203 | 205 | cwidth = canvas.width, |
204 | 206 | cheight = canvas.height - 2, |
205 | | - /*2 is the gap between meter and cap*/ |
206 | 207 | meterWidth = 10, //width of the meters in the spectrum |
207 | 208 | gap = 2, //gap between meters |
208 | 209 | capHeight = 2, |
|
227 | 228 | allCapsReachBottom = allCapsReachBottom && (capYPositionArray[i] === 0); |
228 | 229 | }; |
229 | 230 | if (allCapsReachBottom) { |
230 | | - cancelAnimationFrame(that.animationId);//since the sound is top and animation finished, stop the requestAnimation to prevent potential memory leak,THIS IS VERY IMPORTANT! |
| 231 | + cancelAnimationFrame(that.animationId); //since the sound is top and animation finished, stop the requestAnimation to prevent potential memory leak,THIS IS VERY IMPORTANT! |
231 | 232 | return; |
232 | 233 | }; |
233 | 234 | }; |
|
0 commit comments