百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
R

react-audio-spectrum

> 编程语言
开源

用于显示音频频谱的组件

99 stars0 点赞2 次浏览
访问官网GitHub

工具介绍

用于显示音频频谱的组件

React Audio Spectrum

An audio spectrum visualizer for react.

Live Demo

https://hu-ke.github.io/react-audio-spectrum/

Getting Started

you can also pass audio element to the component

this.audioEle = new Audio('path/to/your/song.mp3) 

if you use both audioId and audioEle props, the component will ignore audioEle.

How to fix CORS issue?

if you encounter the console error like: MediaElementAudioSource outputs zeroes due to CORS access restrictions That means your web application attempts to access resources (like MP3 files) from a different origin (domain, protocol, or port) without the appropriate CORS headers being set by the server hosting the resource. Here is the nginx sample config to resolve CORS errors:

bash
location / {
    add_header 'Access-Control-Allow-Origin' '*';
}

Or, if you are specifying allowed origins:

bash
location / {
    add_header 'Access-Control-Allow-Origin' 'https://your-website.com';
}

Further more, you need to add the crossOrigin attribute to your audio element:

The link https://reader.guru/medias/How-Long-Will-I-Love-You.mp3 has been configured with Access-Control-Allow-Origin header, you can use it for testing.

Props

property description type default isRequired
id canvas id number/string a random string false
width canvas width number 300 false
height canvas height number 200 false
audioId id of the target audio element number/string - false
audioEle target audio element audio object - false
capColor color of caps string #FFF false
capHeight height of caps string 2 false
meterWidth width of meters number 2 false
meterColor color of meters string/array [{stop: 0, color: '#f00'},{stop: 0.5, color: '#0CD7FD'},{stop: 1, color: 'red'}] false
gap gap between meters number 10 false
silent if play the audio in silent mode boolean false false

Install

bash
yarn add react-audio-spectrum --save
or
npm install react-audio-spectrum --save

Contributing

react-audio-spectrum is a free and open source react library, and I appreciate any help you're willing to give - whether it's fixing bugs, improving documentation, or suggesting new features.

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

TypeScript

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言