11/*
2- *An audio spectrum visualizer built with HTML5 Audio API
3- *Author:Wayou
4- *License:feel free to use but keep this info please!
5- *Feb 15 2014
6- *Need support you can :
7- *view the project page:https://github.com/Wayou/HTML5_Audio_Visualizer/
8- *view online demo:http://wayouliu.duapp.com/mess/audio_visualizer.html
9- view the blog on how this is done:http://www.cnblogs.com/Wayou/p/html5_audio_api_visualizer.html
10- *or contact me:liuwayong@gmail.com
2+ * An audio spectrum visualizer built with HTML5 Audio API
3+ * Author:Wayou
4+ * License:feel free to use but keep this info please!
5+ * Feb 15, 2014
6+ * For more infomation or support you can :
7+ * view the project page:https://github.com/Wayou/HTML5_Audio_Visualizer/
8+ * view online demo:http://wayouliu.duapp.com/mess/audio_visualizer.html
9+ * view the blog on how this is done:http://www.cnblogs.com/Wayou/p/html5_audio_api_visualizer.html
10+ * or contact me:liuwayong@gmail.com
1111 */
1212window . onload = function ( ) {
1313 new Visualizer ( ) . ini ( ) ;
@@ -37,7 +37,7 @@ Visualizer.prototype = {
3737 try {
3838 this . audioContext = new AudioContext ( ) ;
3939 } catch ( e ) {
40- that . _updateInfo ( '!Your browser does not support AudioContext' , false ) ;
40+ this . _updateInfo ( '!Your browser does not support AudioContext' , false ) ;
4141 console . log ( e ) ;
4242 }
4343 } ,
@@ -64,6 +64,7 @@ Visualizer.prototype = {
6464 } ;
6565 //listen the drag & drop
6666 dropContainer . addEventListener ( "dragenter" , function ( ) {
67+ document . getElementById ( 'fileWrapper' ) . style . opacity = 1 ;
6768 that . _updateInfo ( 'Drop it on the page' , true ) ;
6869 } , false ) ;
6970 dropContainer . addEventListener ( "dragover" , function ( e ) {
@@ -73,6 +74,7 @@ Visualizer.prototype = {
7374 e . dataTransfer . dropEffect = 'copy' ;
7475 } , false ) ;
7576 dropContainer . addEventListener ( "dragleave" , function ( ) {
77+ document . getElementById ( 'fileWrapper' ) . style . opacity = 0.2 ;
7678 that . _updateInfo ( that . info , false ) ;
7779 } , false ) ;
7880 dropContainer . addEventListener ( "drop" , function ( e ) {
@@ -157,7 +159,6 @@ Visualizer.prototype = {
157159 canvas = document . getElementById ( 'canvas' ) ,
158160 cwidth = canvas . width ,
159161 cheight = canvas . height - 2 ,
160- /*2 is the gap between meter and cap*/
161162 meterWidth = 10 , //width of the meters in the spectrum
162163 gap = 2 , //gap between meters
163164 capHeight = 2 ,
@@ -182,7 +183,7 @@ Visualizer.prototype = {
182183 allCapsReachBottom = allCapsReachBottom && ( capYPositionArray [ i ] === 0 ) ;
183184 } ;
184185 if ( allCapsReachBottom ) {
185- cancelAnimationFrame ( that . animationId ) ; //since the sound is top and animation finished, stop the requestAnimation to prevent potential memory leak,THIS IS VERY IMPORTANT!
186+ cancelAnimationFrame ( that . animationId ) ; //since the sound is top and animation finished, stop the requestAnimation to prevent potential memory leak,THIS IS VERY IMPORTANT!
186187 return ;
187188 } ;
188189 } ;
0 commit comments