# Interactive Transcript Feature
VidPly includes a powerful interactive transcript feature that displays video captions/subtitles in a dedicated window, allowing users to read along, search, and jump to specific parts of the video.
## Features
- **Auto-Scrolling** - Transcript automatically highlights and scrolls to the current line
- **Click to Seek** - Click any transcript line to jump to that moment in the video
- **Draggable Window** - Position the transcript anywhere on screen (desktop only)
- **Resizable Window** - Adjust transcript window size with mouse or keyboard
- **Keyboard Drag Mode** - Use arrow keys to move the transcript window (D key to toggle)
- **Keyboard Resize Mode** - Use arrow keys to resize the transcript window (R key to toggle)
- **Settings Menu** - Configure drag and resize modes
- **Mobile Responsive** - Adapts to mobile screens (< 768px) with optimized layout
- **Fullscreen Support** - Transcript repositions intelligently in fullscreen mode
- **Search & Read** - Perfect for accessibility and language learning
## Quick Start
### Enable Transcript
```html
```
That's it! The transcript button will appear in the control bar.
## Configuration Options
### Via JavaScript
```javascript
const player = new Player('#video', {
transcript: true, // Enable transcript feature
transcriptButton: true, // Show transcript button in controls
transcriptPosition: 'external' // Position mode (currently only 'external')
});
```
### Via Data Attributes
```html
```
## How It Works
The transcript feature automatically:
1. Detects caption/subtitle tracks in your video
2. Loads the VTT (WebVTT) cue text
3. Creates an interactive, scrollable window
4. Highlights the current line based on video playback time
5. Auto-scrolls to keep the current line visible
## API Methods
### Show/Hide Transcript
```javascript
const player = new Player('#video', {
transcript: true,
transcriptButton: true
});
// Show transcript window
player.transcriptManager.showTranscript();
// Hide transcript window
player.transcriptManager.hideTranscript();
// Toggle transcript visibility
player.transcriptManager.toggleTranscript();
```
### Check State
```javascript
// Check if transcript is visible
if (player.transcriptManager.isVisible) {
console.log('Transcript is showing');
}
```
### Programmatic Control
```javascript
// Get transcript entries
console.log(player.transcriptManager.transcriptEntries);
// Get current active entry
console.log(player.transcriptManager.currentActiveEntry);
```
## User Interaction
### Click to Seek
Users can click any transcript line to jump to that moment:
```javascript
// This happens automatically, but you can listen for it
player.on('timeupdate', (time) => {
console.log('User jumped to:', time);
});
```
### Drag & Resize Modes (Desktop)
On desktop (>= 768px), users can:
**Drag Mode:**
- **D Key** - Toggle keyboard drag mode
- **Arrow Keys** - Move window in 10px increments (Shift = 50px)
- **Mouse Drag** - Drag the transcript header to reposition
- **Home Key** - Reset to center position
- **Escape Key** - Exit drag mode
**Resize Mode:**
- **R Key** - Toggle keyboard resize mode
- **Arrow Keys** - Resize window in 10px increments (Shift = 50px)
- **Mouse Resize** - Drag resize handles at window edges
- **Escape Key** - Exit resize mode
**Settings Menu:**
- Click the settings icon (⚙️) in the transcript header
- Toggle drag mode and resize mode
- Close the transcript window
### Mobile Behavior
On mobile devices (< 768px breakpoint):
- Transcript appears below the video player
- Positioned in document flow (not draggable or resizable)
- Optimized for scrolling and reading
- Minimum width: 300px
## Positioning Modes
### Desktop (Non-Fullscreen)
- Appears next to the video player
- Draggable to any position
- Height matches video height
### Fullscreen Mode
- Positioned in bottom-right corner
- Floating over the video
- Leaves room for controls
### Mobile
- Below video and controls
- Full width
- Maximum height of 400px
- Part of page flow
## Keyboard Shortcuts
### Global Shortcuts (Player focused)
| Key | Action |
|-----|--------|
| T | Toggle transcript window |
| D | Toggle drag mode (when transcript visible) |
| R | Toggle resize mode (when transcript visible) |
### Drag Mode (D key - must be enabled first)
| Key | Action |
|-----|--------|
| ← → ↑ ↓ | Move window (10px) |
| Shift + Arrow | Move window (50px) |
| Home | Reset to center position |
| Escape | Exit drag mode |
### Resize Mode (R key - must be enabled first)
| Key | Action |
|-----|--------|
| ← → | Adjust width (10px) |
| ↑ ↓ | Adjust height (10px) |
| Shift + Arrow | Adjust size (50px) |
| Escape | Exit resize mode |
### Transcript Entries
| Key | Action |
|-----|--------|
| Enter / Space | Jump to that time (when entry focused) |
| Tab | Navigate through transcript entries |
## Styling the Transcript
### Custom Colors
```css
/* Transcript window */
.vidply-transcript-window {
background: rgba(20, 20, 30, 0.95);
border: 1px solid rgba(255, 255, 255, 0.2);
}
/* Header */
.vidply-transcript-header {
background: rgba(30, 30, 40, 0.95);
border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}
/* Transcript entries */
.vidply-transcript-entry {
padding: 12px;
border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}
/* Active entry */
.vidply-transcript-entry-active {
background: rgba(59, 130, 246, 0.2);
border-left: 3px solid #3b82f6;
}
/* Timestamp */
.vidply-transcript-time {
color: #60a5fa;
font-weight: 600;
}
```
## Complete Example
```html