@vocalstack/player

中文文档
0.1.0-alpha.14发布于 2026/11/03MITTypeScriptES Module构建来源已验证

VocalStack video and transcript player for React: synced transcript, subtitles, spoken translations and background sound, over the public VocalStack API.

原始使用文档
文档目录3 节
  1. Props
  2. Settings
  3. License

@vocalstack/player

A React video and transcript player for VocalStack transcriptions. It shows subtitles, a synced transcript, and spoken translations read in the speakers' own (cloned) or stock voices. It can also remove the background sound. It talks only to the public VocalStack API.

npm install @vocalstack/player
import { VocalStackPlayer } from '@vocalstack/player';
import '@vocalstack/player/style.css';

export function Video() {
  return <VocalStackPlayer id="r4m4srrrhi24" mode="video" />;
}

id is the share code from a VocalStack share link (vocalstack.com/v/<code>). Shared transcriptions need no key.

Props

PropDefault
idA share code. Or, with token, a transcription id. With neither id nor src, the player opens on a box where the visitor pastes any video link and transcribes it in their own VocalStack account.
srcA video or audio link (YouTube, Vimeo, an mp3 or any media URL) instead of id. If the visitor has already transcribed it with VocalStack, it plays. If not, they are asked whether to start transcribing it. With token, the link is looked up in that account instead.
tokenA browser token (or a function returning one) for a private transcription. Never pass an API key to a browser.
mode'video''video' for the full player, 'transcript' for the reading view with a player.
layout'embed''embed' sizes to its container (16:9 for video). 'page' fills the page.
settingsSettings you control. Changing a value updates the player. See below.
initialThe same settings, applied once at the start. The viewer can change them afterwards.
onSettingsChangeCalled with all the settings whenever the viewer changes one.
controlsall on{ language, subtitles, audio, export, share, fullscreen, settings }. Pass false to hide one.
autoplaytrueStarts muted where the browser requires it.
startAtStart time in seconds.
endCardonAt the end of a video, offers to transcribe another link in the visitor's own VocalStack account. Pass false to turn it off.
baseUrlhttps://api.vocalstack.com
onSource, onProgress, onErrorCalled with the loaded transcription, the transcription progress (0-100, null when done), and errors.
onPlaybackCalled about ten times a second while anything changes, with { t, dur, playing, idx, seekN, lang }: the time in seconds, the length, whether it plays, the index of the current line, a counter that grows on every seek, and the language shown.
refA PlayerHandle: seek(t), play(), pause(), toggle().
compactfalseSmall controls at any width, and no title, summary or share card when paused. For a player inside a side column or card.
posterAn image shown behind the player before a video is chosen or before the visitor connects.

Settings

{
  lang?: string | null;          // translate into this language code; null = as spoken
  subtitles?: boolean;           // captions over the video
  speakerLabels?: boolean;       // who is speaking, before each line
  wordHighlight?: boolean;       // follow each word as it is spoken
  translateAudio?: boolean;      // hear the translation read aloud
  voices?: 'cloned' | 'synthetic';
  removeBackground?: boolean;    // play only the speech
}
<VocalStackPlayer
  id="r4m4srrrhi24"
  settings={{ lang: 'es', speakerLabels: true, voices: 'cloned' }}
  controls={{ export: false, share: false }}
  onSettingsChange={(s) => console.log(s)}
/>

<VocalStackPlayer src="https://www.youtube.com/watch?v=QWCLiPOgeuw" />

Follow and drive it from your page:

const player = useRef<PlayerHandle>(null);
<VocalStackPlayer ref={player} id="r4m4srrrhi24" onPlayback={(s) => setAt(s.t)} />
<button onClick={() => player.current?.seek(42)}>Jump to 0:42</button>

Theme it by overriding the CSS variables on .vsp, for example --vsp-radius, --brand and --vs-font-sans.

License

MIT

版本与发布记录

@vocalstack/player 共发布 16 个版本,首次发布于 2026/11/02;过去 12 个月发布了 16 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.1.0-alpha.14latest2026/11/03今天
0.1.0-alpha.132026/11/03今天
0.1.0-alpha.122026/11/03今天
0.1.0-alpha.112026/11/03今天
0.1.0-alpha.102026/11/03今天
0.1.0-alpha.92026/11/03今天

关于 @vocalstack/player 的常见问题

@vocalstack/player 是什么?

用于React的VocalStack视频和脚本播放器:同步脚本,字幕,口语翻译和背景声音,通过公共VocalStack API。

如何安装 @vocalstack/player?

在项目目录运行 npm install @vocalstack/player,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:react(>=18)、react-dom(>=18)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@vocalstack/player 支持 TypeScript 吗?

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

@vocalstack/player 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@vocalstack/player 可以商用吗?

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

@vocalstack/player 还在维护吗?

最新版本 0.1.0-alpha.14 发布于 2026/11/03(今天);至今共发布 16 个版本,其中过去 12 个月发布了 16 个;首次发布于 2026/11/02。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。