The `media-captions` library is a robust, lightweight, and zero-dependency solution for parsing and rendering various media caption formats on the modern web. It supports SubRip (SRT), WebVTT (VTT), and SubStation Alpha/Advanced SubStation Alpha (SSA/ASS) formats. Currently at version 0.0.18, it is actively maintained by the Vidstack team as a core component of their media player ecosystem, which ensures consistent and accessible caption experiences across different browsers and platforms, addressing limitations often found with native browser captioning. Key differentiators include its modular architecture for tree-shaking, a compact 5KB footprint, lazy-loaded parsers, efficient CSS-based style application, and adherence to WebVTT rendering specifications for features like regions, cues, and roll-up captions. It is built with TypeScript and designed to work both server-side and client-side, requiring Node.js version 16 or higher.
npm install media-captionsVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to parse an SRT caption string using both the `createParser` factory and directly instantiating `SRTParser`, then logs the resulting cue objects. It also briefly mentions how a `CaptionsRenderer` would be used.
Review changelogs carefully before upgrading. Consider using a tool like `npm-check-updates` with care.
Ensure a clear separation between native caption handling and `media-captions` rendering. If using `CaptionsRenderer`, typically you would not use native HTML `track` elements for the same content.
If experiencing issues with dynamically loaded parsers, ensure your bundler (Webpack, Rollup, Vite) is configured for code splitting and dynamic imports. The `createParser` factory handles this internally for standard usage.
Ensure you are using ESM `import { createParser } from 'media-captions';` and your build environment supports ESM. Check your `tsconfig.json` `module` and `moduleResolution` settings.Verify that the format string passed to `createParser()` is one of the supported types: 'vtt', 'srt', 'ssa', 'ass'.
No dependency data recorded yet.