Dancer.js是一个高级的音频API,旨在创建炫酷的可视化效果,可以和Mozilla的AudioDataAPI以及Webkit的WebAudioAPI结合使用。
Dancer.js主要功能如下:
使用实时音频波形和频率数据,并可映射为各种可视化效果
从现有的音频源中获取音频数据
可检测到你的可视化效果
支持WebAudio(webkit)、AudioData(mozilla)和flashfallback(v9+)
可扩展,支持插件和自定义行为
Dancer.js实例方法
Setup
•load(source)specifiestheaudiosourceforthedancerinstance.sourcecaneitherbeanaudioelement,oranobjectwithasrcpropertyandanoptionalcodecsarray.Whiletheaudioelementsourceisrecommendedtousewithotherplayers,ifyouspecifyaconfigobject,thesrcpropertycaneitherbeastringoftheaudiopath,orastringoftheaudiopath,withoutthefileextension,ifyouspecifyacodecarraytoworkacrossmultipleaudioimplementations.Examplesofinput:
vardancer=newDancer();
//Usinganaudioobject
vara=newAudio();
a.src='somesong.mp3';
dancer.load(a);
//Usinganaudioelementonthepage
dancer.load(document.getElementsByTagName('audio')[0]);
//Usingaconfigobjectandyouonlyhaveoneencoding
dancer.load({src:'somesong.mp3'});
//Usingaconfigobject,andyouhaveanoggandmp3version
dancer.load({src:'somesong',codecs:['ogg','mp3']});
下一篇:web前端热更新原理是什么