Samael

wavesurfer的笔记

简介

wavesurfer是一个使用canvas绘制波形图和操作音频的js库, 并且有一定的扩展能力. 开发者可以方便地进行拓展.

使用

<div id="waveform">
      <!-- Here be the waveform -->
</div>
var wavesurfer = Object.create(WaveSurfer);
var options = {
  //表示在html中要绘制波形的容器,在index.html中可以找到
      container     : document.querySelector('#waveform'), // 选择页面中的容器
      waveColor     : 'violet',
      progressColor : 'purple',
      loaderColor   : 'purple',
      cursorColor   : 'navy'
  };
  if (location.search.match('scroll')) {
      options.minPxPerSec = 100;
      options.scrollParent = true;
  }
  if (location.search.match('normalize')) {
      options.normalize = true;
  }
  // Init
  wavesurfer.init(options);
  // Load audio from URL
  wavesurfer.load('example/media/demo.wav');
  // Regions
  if (wavesurfer.enableDragSelection) {
      wavesurfer.enableDragSelection({
          color: 'rgba(0, 255, 0, 0.1)'
      });

插件

在wavesurfer里有七个实用插件

参考

http://www.wavesurfer.fm/


Share this: