Overview
TheAnnotationProvider is an optional context provider from the @waveform-playlist/annotations package that supplies annotation UI components, parsers, and controls to the browser package.
This provider enables:
- Visual annotation components (boxes, text lists)
- Aeneas format parsing and serialization
- Annotation control checkboxes (editable, continuous play, link endpoints)
- Download annotations button
Installation
Import
Usage
Wrap your application withAnnotationProvider to enable annotation features:
Integration Pattern
The@waveform-playlist/annotations package follows an integration context pattern:
- The
@waveform-playlist/browserpackage defines what it needs via theAnnotationIntegrationinterface - The
@waveform-playlist/annotationspackage provides the implementation viaAnnotationProvider - Browser components use
useAnnotationIntegration()to access features - If
AnnotationProvideris not present, components gracefully returnnullor throw helpful errors
Why This Pattern?
- Optional dependency: Annotations are opt-in, reducing bundle size when not needed
- Clear separation: Browser package handles playback/editing, annotations package handles annotation UI
- Fail-fast errors: Missing provider throws clear error with installation instructions
Provided Components
When you wrap your app withAnnotationProvider, these components become available:
AnnotationText
Text list view of annotations with editing capabilities.AnnotationBox
Visual box overlaid on waveform for a single annotation segment.AnnotationBoxesWrapper
Container for rendering multiple annotation boxes.Control Components
UI controls for annotation features:Provided Parsers
The provider includes parsers for Aeneas annotation format.parseAeneas
Parse raw Aeneas annotation data intoAnnotationData format.
WaveformPlaylistProvider. The provider expects numeric start and end values.
serializeAeneas
SerializeAnnotationData back to Aeneas format for export.
Using the Integration Hook
Access annotation features from any component:AnnotationProvider is not present:
Complete Example
Critical: Use onAnnotationsChange
When usingannotationList with editable annotations, always provide onAnnotationsChange:
Integration Context Details
TheAnnotationProvider supplies this integration object:
@waveform-playlist/browser/src/AnnotationIntegrationContext.tsx.
Without AnnotationProvider
If you don’t install@waveform-playlist/annotations, the browser package still works:
annotationListprop is ignored (no visual annotations)useAnnotationIntegration()throws with helpful error- Internal components that check for the provider with
useContext()returnnull
Related
- WaveformPlaylistProvider - Main playlist provider
- Annotations Guide - Working with annotations
- AnnotationData type - Annotation data structure