@arraypress/waveform-player

中文文档
1.30.0发布于 2026/10/21MITTypeScriptESM + CJS零依赖近 30 天下载 38.6万

Lightweight, customizable audio player with waveform visualization

原始使用文档
文档目录5 节
  1. Install
  2. Initializing only what you control
  3. Documentation
  4. -> docs.waveformplayer.com
  5. License

WaveformPlayer

Zero-config audio waveforms for the web. Add a data- attribute to a <div> and get a real, interactive waveform player. No build step, no dependencies.

npm gzip license

Documentation · npm


Install

npm install @arraypress/waveform-player

Load from a CDN and it auto-initializes every [data-waveform-player] on the page:

<link rel="stylesheet" href="https://unpkg.com/@arraypress/waveform-player/dist/waveform-player.css">
<script src="https://unpkg.com/@arraypress/waveform-player/dist/waveform-player.min.js"></script>

<div data-waveform-player data-url="track.mp3" data-title="My Song" data-artist="The Artist"></div>

Or drive it from JavaScript:

import WaveformPlayer from '@arraypress/waveform-player';

new WaveformPlayer('#player', { url: 'track.mp3', title: 'My Song', artist: 'The Artist' });

Initializing only what you control

Pages that render markup they don't author — user content, a CMS, an editor canvas — can turn the automatic scan off from the document element:

<html data-waveform-autoinit="false">

Nothing is initialized until you ask for it. Pass init() a root to scan only the subtree you own:

WaveformPlayer.init( document.querySelector( '#my-app' ) );

Constructing players directly still works too; only the scan on import is suppressed.

That attribute is for pages. If you're bundled into a page you don't author — a CMS block, a plugin, a widget dropped into someone else's template — there's no <html> in scope to mark before your import is evaluated. Import the library without the scan instead:

import WaveformPlayer from '@arraypress/waveform-player/no-autoinit';

// Identical in every other way. Nothing is initialized until you say so:
WaveformPlayer.init( myContainer );
new WaveformPlayer( el, { url: 'track.mp3' } );

Same class, same options, same window.WaveformPlayer; ships as ESM and CJS. Pick one entry point per bundle — each carries its own copy of the class and its own instance registry.

This scopes initialization — it isn't a sanitizer. playIcon / pauseIcon (and their data-play-icon / data-pause-icon equivalents) inject raw markup by design, for any player you do build. Untrusted content still needs sanitizing before it reaches the page.

Documentation

Every option, style, event and method is documented on the docs site.

-> docs.waveformplayer.com

Options · Waveform styles · Events · Methods · Accessibility

Extensions: Bar · Playlist · Tracker · Gen — Frameworks: React · Vue · Svelte · Astro

License

MIT © ArrayPress

版本与发布记录

@arraypress/waveform-player 共发布 62 个版本,首次发布于 2025/09/14;过去 12 个月发布了 54 个版本。

版本发布日期距今
1.30.0latest2026/10/2117 天前
1.29.12026/09/281 个月前
1.29.02026/09/281 个月前
1.28.12026/09/251 个月前
1.28.02026/09/241 个月前
1.27.12026/09/241 个月前

关于 @arraypress/waveform-player 的常见问题

@arraypress/waveform-player 是什么?

Lightweight, customizable audio player with waveform visualization

如何安装 @arraypress/waveform-player?

在项目目录运行 npm install @arraypress/waveform-player,或使用 pnpm add / yarn add / bun add。

@arraypress/waveform-player 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@arraypress/waveform-player 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@arraypress/waveform-player 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=14.0.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@arraypress/waveform-player 可以商用吗?

@arraypress/waveform-player 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@arraypress/waveform-player 的下载量有多少?

根据 npm 官方下载统计,@arraypress/waveform-player 在 2026/10/07 – 2026/11/05 这 30 天内被下载 386,497 次,日均约 12,883 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@arraypress/waveform-player 还在维护吗?

最新版本 1.30.0 发布于 2026/10/21(17 天前);至今共发布 62 个版本,其中过去 12 个月发布了 54 个;首次发布于 2025/09/14。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。