Overview
The audio playback system provides a complete set of controls for playing audio files and navigating through transcripts. It features a custom scrub bar for precise seeking, play/pause controls, and automatic time synchronization.Audio Component
The viewer uses a hidden HTML5 audio element controlled by React:Audio Props Configuration
The audio element is configured automatically by the container:Play/Pause Control
The play/pause button automatically toggles based on playback state:Usage
- Default Icon
- Custom Content
Playback Control Functions
The viewer hook provides imperative playback controls:Scrub Bar
The scrub bar provides visual feedback and seeking capabilities:Scrub Bar Components
- ScrubBarContainer: Handles mouse/touch events for scrubbing
- ScrubBarTrack: The background track
- ScrubBarProgress: Visual indicator of playback progress
- ScrubBarThumb: Draggable handle for seeking
- ScrubBarTimeLabel: Formatted time display
Customization
Seeking Functionality
Seek to Time
Seek to a specific time in seconds:Seek to Word
Jump to a specific word in the transcript:Scrubbing State Management
When the user drags the scrub bar, the RAF loop is paused for performance:The
isScrubbing state can be used to show visual feedback during seeking, such as a larger preview or tooltip.Audio Event Handling
The viewer listens to all relevant audio events:Duration Fallback
If audio metadata isn’t loaded, the viewer uses alignment data as fallback:State Synchronization
The viewer maintains multiple state sources:- Update React state (
currentTime) - Update current word index via
handleTimeUpdate - Update audio element’s
currentTime
Complete Example
Here’s a full playback interface:Next Steps
- Learn about Transcript Viewer word synchronization
- Configure Speaker Diarization for multi-speaker audio
- Explore Transcription API options