Skip to content
This repository has been archived by the owner on Jun 25, 2020. It is now read-only.

Latest commit

 

History

History
54 lines (36 loc) · 968 Bytes

README.md

File metadata and controls

54 lines (36 loc) · 968 Bytes

react-waveform

Generates waveform using Web Audio API.

Install

npm install react-waveform

Props

  • buffer AudioBuffer
  • width Number
  • height Number
  • zoom Number
  • color String
  • onDone Function

Example

var React = require('react');
var Waveform = require('react-waveform');

var request = new XMLHttpRequest();
request.open('GET', 'HardaTider-Har&nu.mp3', true);
request.responseType = 'arraybuffer';

request.addEventListener('load', function () {
  var context = new (window.AudioContext || window.webkitAudioContext)();

  context.decodeAudioData(request.response, function (buffer) {
    React.render(
        <Waveform buffer={buffer} width={720} color="cadetblue" />,
        document.getElementById('waveform')
        );
  });
});

request.send();

License

MIT