一直在用网易云音乐听歌,感觉他的这个动效还是挺不错的,最近也是想试试canvas绘图相关的。尝试了几次之后感觉效果还不错,不过距离网易云的还是有些差距。 本期准备仿照制作如下效果: 偷偷使用最近比较流行的罗刹海市的音乐来展示这个效果。 效果展示如下: 效果展示网站 参考文档 具体的流程大体上就是获取音频数据,然后根据音频数据绘制在canvas上,不同的绘制方式就能有很多惊艳的效果,毕竟还是数学最令人着迷了。 普通的audio标签无法提取音频数据,查了一下需要使用到 AudioContext 这个浏览器内置对象。 使用来说也比较简单,大体上就是创建,加载音频,播放等几个环境,在播放的时候通过链接音频处理节点获取音频数据。 几个比较重要的点如下: window.AudioContext = window.AudioContext || window.webkitAudioContext; this.audioCtx = new AudioContext() this.bufferSourceNode = this.audioCtx.createBufferSource()...
Is this you? As a journalist, you can create a free Muck Rack account to customize your profile, list your contact preferences, and upload a portfolio of your best work.
Claim your profile
Get in touch with var
Contact var, search articles and posts on X, monitor coverage, and track replies from one place.
Learn more about Muck Rack