Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

wavesurfer.js

Package Overview
Dependencies
Maintainers
1
Versions
292
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

wavesurfer.js

Audio waveform player

  • 7.8.8
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created

What is wavesurfer.js?

wavesurfer.js is a customizable audio waveform visualization library, built on top of Web Audio API and HTML5 Canvas. It allows you to create interactive audio waveforms, add regions, and control playback, among other features.

What are wavesurfer.js's main functionalities?

Waveform Visualization

This feature allows you to create a visual representation of an audio file's waveform. The code sample demonstrates how to initialize WaveSurfer and load an audio file for visualization.

const WaveSurfer = require('wavesurfer.js');
const wavesurfer = WaveSurfer.create({
  container: '#waveform',
  waveColor: 'violet',
  progressColor: 'purple'
});
wavesurfer.load('path/to/audio/file.mp3');

Playback Control

This feature provides methods to control audio playback, such as play, pause, and stop. The code sample shows how to play the audio once it's ready and how to pause and stop playback.

wavesurfer.on('ready', function () {
  wavesurfer.play();
});

// Pause playback
wavesurfer.pause();

// Stop playback
wavesurfer.stop();

Regions

This feature allows you to add regions to the waveform, which can be used to highlight specific parts of the audio. The code sample demonstrates how to add a region from 5 to 10 seconds with a semi-transparent green color.

wavesurfer.on('ready', function () {
  wavesurfer.addRegion({
    start: 5,    // time in seconds
    end: 10,     // time in seconds
    color: 'rgba(0, 255, 0, 0.1)'
  });
});

Plugins

wavesurfer.js supports various plugins to extend its functionality. The code sample demonstrates how to add and initialize a cursor plugin that shows the current time on the waveform.

const cursorPlugin = WaveSurfer.cursor.create({
  showTime: true,
  opacity: 1,
  customShowTimeStyle: {
    'background-color': '#000',
    color: '#fff',
    padding: '2px',
    'font-size': '10px'
  }
});
wavesurfer.addPlugin(cursorPlugin).initPlugin('cursor');
0

Keywords

FAQs

Package last updated on 23 Oct 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc