katspaugh/wavesurfer.js — dự án frontend — đang có 10.4k sao GitHub trong nhóm Frontend. Audio waveform player
Tóm tắt dựng từ metadata GitHub của chính dự án — chưa có bài review TopGit. Trang sẽ tự động cập nhật khi bài review đầy đủ được xuất bản.
VÌ SAO CHƯA CÓ REVIEW
TopGit viết bài đầy đủ cho repo có nhiều sao nhất và được yêu cầu nhiều nhất. Trang này là snapshot trong thời gian chờ — xem README gốc ở tab READ ME.
Wavesurfer.js is an interactive waveform rendering and audio playback library, perfect for web applications. It leverages modern web technologies to provide a robust and visually engaging audio experience.
Gold Sponsor 💖 Closed Caption Creator – Professional Subtitle Editor
Table of contents
Getting started
API reference
Plugins
Advanced / reactive API
CSS styling
Frequent questions
Development
Tests
Feedback
Getting started
Install and import the package:
npm install --save wavesurfer.js
import WaveSurfer from 'wavesurfer.js'
Alternatively, insert a UMD script tag which exports the library as a global WaveSurfer variable:
TypeScript types are included in the package, so there's no need to install @types/wavesurfer.js.
See more examples.
Documentation
See the wavesurfer.js guide on our website for beginner-friendly, practical documentation covering common use cases, plugins, framework integration, and troubleshooting.
API reference
The full generated API reference lives at wavesurfer.xyz/docs/api:
methods
options
events
Plugins
We maintain a number of official plugins that add various extra features:
Regions – visual overlays and markers for regions of audio
Timeline – displays notches and time labels below the waveform
Minimap – a small waveform that serves as a scrollbar for the main waveform
Envelope – a graphical interface to add fade-in and -out effects and control volume
Record – records audio from the microphone and renders a waveform
Spectrogram – visualization of an audio frequency spectrum (written by @akreal)
Hover – shows a vertical line and timestmap on waveform hover
Advanced / reactive API
Beyond the imperative wavesurfer.on(...) events, v8 exposes a small reactive
surface for apps that want to read state instead of tracking it themselves:
getState() returns read-only Signal objects
(.value to read, .subscribe(fn) to watch) for things like currentTime,
isPlaying, volume, muted, loadPhase and scrollPosition.
getRenderer().getVisibleRange() is a derived signal with the currently visible
{startTime, endTime} of the viewport, useful for plugins that need to sync to
what's on screen (e.g. a custom minimap or timeline).
If you're writing a plugin, WaveSurfer.definePlugin(name, (ctx, options) => api)
is an alternative to subclassing BasePlugin: ctx gives you { wavesurfer, scope, state, emit },
and anything you register on ctx.scope (listeners, timers, child scopes) is torn
down automatically on destroy() — no manual cleanup array required.
The Spectrogram plugin accepts
a rendering: 'windowed' option for very long audio files: it renders only the
visible time range and evicts off-screen segments, instead of computing the
whole file's frequency data up front.
This replaces the standalone WindowedSpectrogramPlugin (spectrogram-windowed.js),
which is now deprecated in favor of the merged option above — it's kept working
as a thin backward-compatible shim, but new code should use SpectrogramPlugin
directly.
CSS styling
wavesurfer.js v7 is rendered into a Shadow DOM tree. This isolates its CSS from the rest of the web page.
However, it's still possible to style various wavesurfer.js elements with CSS via the ::part() pseudo-selector.
For example:
You can see which elements you can style in the DOM inspector – they will have a part attribute.
See this example to play around with styling.
Questions
Have a question about integrating wavesurfer.js on your website? Feel free to ask in our Discussions forum.
However, please keep in mind that this forum is dedicated to wavesurfer-specific questions. If you're new to JavaScript and need help with the general basics like importing NPM modules, please consider asking ChatGPT or StackOverflow first.
FAQ
I'm having CORS issues
Wavesurfer fetches audio from the URL you specify in order to decode it. Make sure this URL allows fetching data from your domain. In browser JavaScript, you can only fetch data eithetr from the same domain or another domain if and only if that domain enables CORS. So if your audio file is on an external domain, make sure that domain sends the right Access-Control-Allow-Origin headers. There's nothing you can do about it from the requesting side (i.e. your JS code).
Does wavesurfer support large files?
Since wavesurfer decodes audio entirely in the browser using Web Audio, large clips may fail to decode due to memory constraints. We recommend using pre-decoded peaks for large files (see this example). You can use a tool like audiowaveform to generate peaks.
What about streaming audio?
Streaming audio is supported only with pre-decoded peaks and duration.
There is a mismatch between my audio and the waveform. How do I fix it?
If you're using a VBR (variable bit rate) audio file, there might be a mismatch between the audio and the waveform. This can be fixed by converting your file to CBR (constant bit rate).
Alternatively, you can use the Web Audio shim which is more accurate.
How do I connect wavesurfer.js to Web Audio effects?
Generally, wavesurfer.js doesn't aim to be a wrapper for all things Web Audio. It's just a player with a waveform visualization. It does allow connecting itself to a Web Audio graph by exporting its audio element (see this example) but nothign more than that. Please don't expect wavesurfer to be able to cut, add effects, or process your audio in any way.
Why does my waveform look asymmetrical?
By default, wavesurfer.js renders stereo audio as a single waveform, with the left channel on the top half and the right channel on the bottom half. If your audio has hard-panned sounds, this will result in an asymmetrical waveform.
To render each channel separately, use the splitChannels option.
Development
To get started with development, follow these steps:
Install dev dependencies:
yarn
Start the TypeScript compiler in watch mode and launch an HTTP server:
yarn start
This command will open http://localhost:9090 in your browser with live reload, allowing you to see the changes as you develop.
Tests
The tests are written in the Cypress framework. They are a mix of e2e and visual regression tests.
To run the test suite locally, first build the project:
yarn build
Then launch the tests:
yarn cypress
Feedback
We appreciate your feedback and contributions!
If you encounter any issues or have suggestions for improvements, please don't hesitate to post in our forum.
We hope you enjoy using wavesurfer.js and look forward to hearing about your experiences with the library!
katspaugh/wavesurfer.js thuộc nhóm Frontend trên TopGit, cùng 6 topic GitHub. Trang Trending và Topics liệt kê các repo cùng số sao và cùng ngôn ngữ để so sánh.
Đọc thêm về katspaugh/wavesurfer.js ở đâu?
Trang TopGit này là một snapshot — tab "Readme" hiển thị nguyên văn README của repo (đã bỏ link, giữ ảnh). Repo GitHub ở github.com/katspaugh/wavesurfer.js là nguồn chính thức.
katspaugh/wavesurfer.js có bao nhiêu sao?
katspaugh/wavesurfer.js có 10.4k sao GitHub — tải lại trang để xem số mới nhất, hoặc xem trực tiếp github.com/katspaugh/wavesurfer.js. TopGit phản chiếu số sao của GitHub nhưng không cam kết đến từng phút.
katspaugh/wavesurfer.js có phải mã nguồn mở không?
Có — katspaugh/wavesurfer.js phát hành theo license BSD-3-Clause, nghĩa là mã nguồn mở để đọc, fork và (tùy license) tái sử dụng. Mã: github.com/katspaugh/wavesurfer.js.
katspaugh/wavesurfer.js có trang demo không?
Dự án có trang chủ ở https://wavesurfer.xyz. Tab "Readme" ở trang này thường có ảnh chụp và hướng dẫn bắt đầu nhanh.
katspaugh/wavesurfer.js là gì?
katspaugh/wavesurfer.js (katspaugh/wavesurfer.js) là dự án TypeScript trên GitHub. Theo mô tả gốc: Audio waveform player
katspaugh/wavesurfer.js so với các dự án Frontend khác thế nào?
katspaugh/wavesurfer.js được TopGit xếp vào nhóm Frontend, với 10.4k sao GitHub và viết bằng TypeScript. Xem trang chủ đề Frontend trên TopGit để so sánh với các dự án tương tự theo số sao và mức độ hoạt động.
Đọc đầy đủ README ở tab phía trên.
Muốn nghe thêm một ý kiến về wavesurfer.js?
Hỏi một AI đọc được trang này — một cú bấm là có ngay nhận định về wavesurfer.js.