feat: add custom audio player with visual timeline
Browse filesImplements comprehensive audio player enhancements:
Player Improvements:
- Replace native HTML5 audio controls with custom player
- Full-width responsive design that adapts to screen size
- Modern UI with gradients and smooth animations
- Enhanced controls: play/pause, seek, volume
Visual Timeline Features:
- Display each utterance as a colored segment in timeline
- Segments positioned based on start/end times
- Click any segment to seek to that utterance
- Hover segments to see speaker name and text preview
Speaker Diarization Integration:
- 10 unique colors for different speakers (red, blue, green, etc.)
- Color-coded segments when diarization is enabled
- Active segment highlighting synchronized with playback
- Visual distinction between speakers at a glance
Additional Features:
- Keyboard shortcuts: Space (play/pause), Arrow keys (seek Β±5s)
- Drag timeline handle for precise seeking
- Volume control with mute toggle and slider
- Time displays (current/duration) with tabular numbers
- Responsive mobile layout with timeline wrap
Technical Implementation:
- initCustomAudioPlayer() for player initialization
- renderTimelineSegments() creates visual segments
- updateActiveSegment() syncs timeline with playback
- Integration with existing bidirectional sync
- Incremental rendering support maintained
- DocumentFragment for efficient DOM updates
All existing features preserved:
β
Bidirectional player β transcript sync
β
Click-to-seek from transcript
β
Drag-to-seek functionality
β
Real-time highlight
β
Edit functionality
Fixes #2.1, #2.2.1, #2.2.2
- CUSTOM_AUDIO_PLAYER.md +520 -0
- frontend/app.js +228 -1
- frontend/index.html +30 -2
- frontend/styles.css +239 -0
|
@@ -0,0 +1,520 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# π΅ Custom Audio Player with Visual Timeline
|
| 2 |
+
|
| 3 |
+
## Overview
|
| 4 |
+
|
| 5 |
+
Complete replacement of the native HTML5 audio player with a custom-built player featuring:
|
| 6 |
+
- β
Full-width responsive design
|
| 7 |
+
- β
Visual timeline with utterance segments
|
| 8 |
+
- β
Color-coded speaker segments (when diarization is enabled)
|
| 9 |
+
- β
Enhanced controls (play/pause, volume, seek)
|
| 10 |
+
- β
Keyboard shortcuts
|
| 11 |
+
- β
All existing functionality preserved
|
| 12 |
+
|
| 13 |
+
---
|
| 14 |
+
|
| 15 |
+
## Features
|
| 16 |
+
|
| 17 |
+
### 1. Responsive Full-Width Player β
|
| 18 |
+
|
| 19 |
+
The new player automatically fills the available width, providing a better visual experience on all screen sizes.
|
| 20 |
+
|
| 21 |
+
```css
|
| 22 |
+
.audio-player-panel {
|
| 23 |
+
width: 100%;
|
| 24 |
+
}
|
| 25 |
+
|
| 26 |
+
.custom-audio-player {
|
| 27 |
+
width: 100%;
|
| 28 |
+
}
|
| 29 |
+
```
|
| 30 |
+
|
| 31 |
+
### 2. Visual Timeline with Utterance Segments β
|
| 32 |
+
|
| 33 |
+
Each utterance is visualized as a colored segment in the timeline:
|
| 34 |
+
- **Position**: Exact start/end time as percentage of total duration
|
| 35 |
+
- **Width**: Duration of the utterance
|
| 36 |
+
- **Hover**: Shows speaker name and text preview
|
| 37 |
+
- **Click**: Seeks to that utterance
|
| 38 |
+
|
| 39 |
+
```javascript
|
| 40 |
+
function renderTimelineSegments() {
|
| 41 |
+
state.utterances.forEach((utt, index) => {
|
| 42 |
+
const startPercent = (utt.start / audio.duration) * 100;
|
| 43 |
+
const endPercent = (utt.end / audio.duration) * 100;
|
| 44 |
+
// Create visual segment...
|
| 45 |
+
});
|
| 46 |
+
}
|
| 47 |
+
```
|
| 48 |
+
|
| 49 |
+
### 3. Speaker Color-Coding β
|
| 50 |
+
|
| 51 |
+
When speaker diarization is enabled, each speaker gets a unique color:
|
| 52 |
+
- Speaker 0: Red (#ef4444)
|
| 53 |
+
- Speaker 1: Blue (#3b82f6)
|
| 54 |
+
- Speaker 2: Green (#10b981)
|
| 55 |
+
- Speaker 3: Amber (#f59e0b)
|
| 56 |
+
- Speaker 4: Purple (#8b5cf6)
|
| 57 |
+
- Speaker 5: Pink (#ec4899)
|
| 58 |
+
- Speaker 6: Teal (#14b8a6)
|
| 59 |
+
- Speaker 7: Orange (#f97316)
|
| 60 |
+
- Speaker 8: Cyan (#06b6d4)
|
| 61 |
+
- Speaker 9: Lime (#84cc16)
|
| 62 |
+
|
| 63 |
+
```css
|
| 64 |
+
.speaker-0 { background-color: #ef4444; }
|
| 65 |
+
.speaker-1 { background-color: #3b82f6; }
|
| 66 |
+
/* ... etc ... */
|
| 67 |
+
```
|
| 68 |
+
|
| 69 |
+
### 4. Active Segment Highlighting β
|
| 70 |
+
|
| 71 |
+
The currently playing utterance segment is highlighted in the timeline:
|
| 72 |
+
- Higher opacity
|
| 73 |
+
- Inner shadow effect
|
| 74 |
+
- Synchronized with transcript highlighting
|
| 75 |
+
|
| 76 |
+
```javascript
|
| 77 |
+
function updateActiveSegment() {
|
| 78 |
+
const currentIndex = findActiveUtterance(audio.currentTime);
|
| 79 |
+
const activeSegment = document.querySelector(`.timeline-segment[data-index="${currentIndex}"]`);
|
| 80 |
+
activeSegment.classList.add('active');
|
| 81 |
+
}
|
| 82 |
+
```
|
| 83 |
+
|
| 84 |
+
### 5. Enhanced Controls β
|
| 85 |
+
|
| 86 |
+
**Play/Pause Button**:
|
| 87 |
+
- Circular gradient button
|
| 88 |
+
- Smooth icon transition
|
| 89 |
+
- Hover effects with glow
|
| 90 |
+
|
| 91 |
+
**Timeline**:
|
| 92 |
+
- Click anywhere to seek
|
| 93 |
+
- Drag handle to seek
|
| 94 |
+
- Visual progress bar
|
| 95 |
+
- Segments overlay
|
| 96 |
+
|
| 97 |
+
**Volume Control**:
|
| 98 |
+
- Mute/unmute button with dynamic icon
|
| 99 |
+
- Slider for precise control
|
| 100 |
+
- Smooth animations
|
| 101 |
+
|
| 102 |
+
**Time Displays**:
|
| 103 |
+
- Current time (left)
|
| 104 |
+
- Total duration (right)
|
| 105 |
+
- Tabular numbers for consistent width
|
| 106 |
+
|
| 107 |
+
### 6. Keyboard Shortcuts β
|
| 108 |
+
|
| 109 |
+
- `Space`: Play/Pause
|
| 110 |
+
- `Arrow Left`: Rewind 5 seconds
|
| 111 |
+
- `Arrow Right`: Forward 5 seconds
|
| 112 |
+
- Only active when not typing in input/textarea
|
| 113 |
+
|
| 114 |
+
```javascript
|
| 115 |
+
document.addEventListener('keydown', (e) => {
|
| 116 |
+
if (e.target.tagName === 'INPUT' || e.target.tagName === 'TEXTAREA') return;
|
| 117 |
+
|
| 118 |
+
if (e.code === 'Space') {
|
| 119 |
+
audio.paused ? audio.play() : audio.pause();
|
| 120 |
+
}
|
| 121 |
+
// ... arrow keys ...
|
| 122 |
+
});
|
| 123 |
+
```
|
| 124 |
+
|
| 125 |
+
---
|
| 126 |
+
|
| 127 |
+
## Technical Implementation
|
| 128 |
+
|
| 129 |
+
### HTML Structure
|
| 130 |
+
|
| 131 |
+
```html
|
| 132 |
+
<section class="panel audio-player-panel">
|
| 133 |
+
<h2>Audio Player</h2>
|
| 134 |
+
<div class="custom-audio-player">
|
| 135 |
+
<audio id="audio-player" preload="auto"></audio>
|
| 136 |
+
|
| 137 |
+
<div class="player-controls">
|
| 138 |
+
<!-- Play/Pause Button -->
|
| 139 |
+
<button id="play-pause-btn">
|
| 140 |
+
<span class="play-icon">βΆ</span>
|
| 141 |
+
<span class="pause-icon hidden">βΈ</span>
|
| 142 |
+
</button>
|
| 143 |
+
|
| 144 |
+
<!-- Current Time -->
|
| 145 |
+
<span id="current-time">0:00</span>
|
| 146 |
+
|
| 147 |
+
<!-- Timeline Container -->
|
| 148 |
+
<div class="timeline-container">
|
| 149 |
+
<canvas id="waveform-canvas"></canvas>
|
| 150 |
+
<div id="timeline-bar">
|
| 151 |
+
<div id="timeline-progress"></div>
|
| 152 |
+
<div id="timeline-segments"></div>
|
| 153 |
+
<div id="timeline-handle"></div>
|
| 154 |
+
</div>
|
| 155 |
+
</div>
|
| 156 |
+
|
| 157 |
+
<!-- Duration -->
|
| 158 |
+
<span id="duration-time">0:00</span>
|
| 159 |
+
|
| 160 |
+
<!-- Volume Control -->
|
| 161 |
+
<div class="volume-control">
|
| 162 |
+
<button id="volume-btn">π</button>
|
| 163 |
+
<input id="volume-slider" type="range" />
|
| 164 |
+
</div>
|
| 165 |
+
</div>
|
| 166 |
+
</div>
|
| 167 |
+
</section>
|
| 168 |
+
```
|
| 169 |
+
|
| 170 |
+
### CSS Styling
|
| 171 |
+
|
| 172 |
+
**Responsive Layout**:
|
| 173 |
+
```css
|
| 174 |
+
.player-controls {
|
| 175 |
+
display: flex;
|
| 176 |
+
align-items: center;
|
| 177 |
+
gap: 1rem;
|
| 178 |
+
}
|
| 179 |
+
|
| 180 |
+
.timeline-container {
|
| 181 |
+
flex: 1; /* Takes all available space */
|
| 182 |
+
height: 48px;
|
| 183 |
+
}
|
| 184 |
+
|
| 185 |
+
@media (max-width: 1100px) {
|
| 186 |
+
.player-controls {
|
| 187 |
+
flex-wrap: wrap;
|
| 188 |
+
}
|
| 189 |
+
|
| 190 |
+
.timeline-container {
|
| 191 |
+
width: 100%;
|
| 192 |
+
flex-basis: 100%; /* Full width on mobile */
|
| 193 |
+
}
|
| 194 |
+
}
|
| 195 |
+
```
|
| 196 |
+
|
| 197 |
+
**Timeline Segments**:
|
| 198 |
+
```css
|
| 199 |
+
.timeline-segment {
|
| 200 |
+
position: absolute;
|
| 201 |
+
height: 100%;
|
| 202 |
+
opacity: 0.4;
|
| 203 |
+
transition: opacity 0.2s ease;
|
| 204 |
+
}
|
| 205 |
+
|
| 206 |
+
.timeline-segment.active {
|
| 207 |
+
opacity: 0.8;
|
| 208 |
+
box-shadow: inset 0 0 10px rgba(255, 255, 255, 0.2);
|
| 209 |
+
}
|
| 210 |
+
```
|
| 211 |
+
|
| 212 |
+
### JavaScript Functions
|
| 213 |
+
|
| 214 |
+
**1. Initialization**:
|
| 215 |
+
```javascript
|
| 216 |
+
function initCustomAudioPlayer() {
|
| 217 |
+
// Set up event listeners for:
|
| 218 |
+
// - Play/Pause
|
| 219 |
+
// - Timeline seeking (click & drag)
|
| 220 |
+
// - Volume control
|
| 221 |
+
// - Keyboard shortcuts
|
| 222 |
+
// - Time updates
|
| 223 |
+
}
|
| 224 |
+
```
|
| 225 |
+
|
| 226 |
+
**2. Timeline Rendering**:
|
| 227 |
+
```javascript
|
| 228 |
+
function renderTimelineSegments() {
|
| 229 |
+
// Clear existing segments
|
| 230 |
+
// For each utterance:
|
| 231 |
+
// - Calculate position as percentage
|
| 232 |
+
// - Apply speaker color
|
| 233 |
+
// - Add tooltip with preview
|
| 234 |
+
// - Make clickable for seeking
|
| 235 |
+
}
|
| 236 |
+
```
|
| 237 |
+
|
| 238 |
+
**3. Position Updates**:
|
| 239 |
+
```javascript
|
| 240 |
+
function updateTimelinePosition() {
|
| 241 |
+
const percent = (audio.currentTime / audio.duration) * 100;
|
| 242 |
+
timelineProgress.style.width = `${percent}%`;
|
| 243 |
+
timelineHandle.style.left = `${percent}%`;
|
| 244 |
+
}
|
| 245 |
+
```
|
| 246 |
+
|
| 247 |
+
**4. Seeking**:
|
| 248 |
+
```javascript
|
| 249 |
+
function seekToPosition(e) {
|
| 250 |
+
const rect = timelineBar.getBoundingClientRect();
|
| 251 |
+
const percent = (e.clientX - rect.left) / rect.width;
|
| 252 |
+
audio.currentTime = percent * audio.duration;
|
| 253 |
+
}
|
| 254 |
+
```
|
| 255 |
+
|
| 256 |
+
---
|
| 257 |
+
|
| 258 |
+
## Integration with Existing Features
|
| 259 |
+
|
| 260 |
+
### 1. Bidirectional Synchronization β
|
| 261 |
+
|
| 262 |
+
**Player β Transcript**:
|
| 263 |
+
```javascript
|
| 264 |
+
// Already working via timeupdate event
|
| 265 |
+
audio.addEventListener('timeupdate', () => {
|
| 266 |
+
updateActiveUtterance();
|
| 267 |
+
updateActiveSegment(); // NEW: Also update timeline
|
| 268 |
+
});
|
| 269 |
+
```
|
| 270 |
+
|
| 271 |
+
**Transcript β Player**:
|
| 272 |
+
```javascript
|
| 273 |
+
// Click on utterance still works
|
| 274 |
+
// Click on timeline segment ALSO works now
|
| 275 |
+
segment.addEventListener('click', () => {
|
| 276 |
+
seekToTime(utt.start);
|
| 277 |
+
});
|
| 278 |
+
```
|
| 279 |
+
|
| 280 |
+
### 2. Drag-to-Seek β
|
| 281 |
+
|
| 282 |
+
Both drag mechanisms work:
|
| 283 |
+
- **Native progress bar**: Removed (using custom timeline)
|
| 284 |
+
- **Custom timeline**: Click and drag supported
|
| 285 |
+
|
| 286 |
+
```javascript
|
| 287 |
+
let isDragging = false;
|
| 288 |
+
|
| 289 |
+
timelineBar.addEventListener('mousedown', (e) => {
|
| 290 |
+
isDragging = true;
|
| 291 |
+
seekToPosition(e);
|
| 292 |
+
});
|
| 293 |
+
|
| 294 |
+
document.addEventListener('mousemove', (e) => {
|
| 295 |
+
if (isDragging) seekToPosition(e);
|
| 296 |
+
});
|
| 297 |
+
```
|
| 298 |
+
|
| 299 |
+
### 3. Incremental Rendering β
|
| 300 |
+
|
| 301 |
+
Timeline segments are updated when transcript changes:
|
| 302 |
+
|
| 303 |
+
```javascript
|
| 304 |
+
function renderTranscript() {
|
| 305 |
+
// ... existing logic ...
|
| 306 |
+
|
| 307 |
+
// NEW: Update timeline after transcript changes
|
| 308 |
+
renderTimelineSegments();
|
| 309 |
+
}
|
| 310 |
+
```
|
| 311 |
+
|
| 312 |
+
---
|
| 313 |
+
|
| 314 |
+
## Visual Design
|
| 315 |
+
|
| 316 |
+
### Color Palette
|
| 317 |
+
|
| 318 |
+
**Player Background**: `rgba(15, 23, 42, 0.5)` - Semi-transparent dark
|
| 319 |
+
**Timeline Base**: `rgba(15, 23, 42, 0.6)` - Darker for contrast
|
| 320 |
+
**Progress**: `linear-gradient(90deg, rgba(56, 189, 248, 0.3), rgba(129, 140, 248, 0.3))` - Blue gradient
|
| 321 |
+
**Handle**: `#38bdf8` - Bright cyan
|
| 322 |
+
**Active Segment**: `opacity: 0.8` + inner shadow
|
| 323 |
+
|
| 324 |
+
### Gradients
|
| 325 |
+
|
| 326 |
+
**Play/Pause Button**:
|
| 327 |
+
```css
|
| 328 |
+
background: linear-gradient(135deg, #38bdf8 0%, #818cf8 100%);
|
| 329 |
+
```
|
| 330 |
+
|
| 331 |
+
**Hover Effects**:
|
| 332 |
+
```css
|
| 333 |
+
box-shadow: 0 0 20px rgba(56, 189, 248, 0.4);
|
| 334 |
+
```
|
| 335 |
+
|
| 336 |
+
---
|
| 337 |
+
|
| 338 |
+
## Performance Considerations
|
| 339 |
+
|
| 340 |
+
### 1. DOM Manipulation
|
| 341 |
+
|
| 342 |
+
**Segments created once per utterance**:
|
| 343 |
+
- Uses DocumentFragment for batch insertion
|
| 344 |
+
- Only re-renders when utterances change
|
| 345 |
+
- Not updated on every timeupdate (too expensive)
|
| 346 |
+
|
| 347 |
+
**Active segment update**:
|
| 348 |
+
- Only changes CSS class (cheap)
|
| 349 |
+
- No DOM manipulation during playback
|
| 350 |
+
|
| 351 |
+
### 2. Event Listeners
|
| 352 |
+
|
| 353 |
+
**Throttling not needed**:
|
| 354 |
+
- `timeupdate` fires ~4x/second (native throttling)
|
| 355 |
+
- Segment updates use simple class toggle
|
| 356 |
+
- No performance issues observed
|
| 357 |
+
|
| 358 |
+
### 3. Responsive Behavior
|
| 359 |
+
|
| 360 |
+
**CSS-based responsive**:
|
| 361 |
+
- No JavaScript media queries
|
| 362 |
+
- Pure CSS flexbox
|
| 363 |
+
- Smooth transitions
|
| 364 |
+
|
| 365 |
+
---
|
| 366 |
+
|
| 367 |
+
## Browser Compatibility
|
| 368 |
+
|
| 369 |
+
| Feature | Support |
|
| 370 |
+
|---------|---------|
|
| 371 |
+
| HTML5 Audio | β
All modern browsers |
|
| 372 |
+
| Flexbox Layout | β
All modern browsers |
|
| 373 |
+
| CSS Gradients | β
All modern browsers |
|
| 374 |
+
| input[type="range"] | β
All modern browsers |
|
| 375 |
+
| DocumentFragment | β
All modern browsers |
|
| 376 |
+
| Keyboard Events | β
All modern browsers |
|
| 377 |
+
|
| 378 |
+
---
|
| 379 |
+
|
| 380 |
+
## Future Enhancements (Optional)
|
| 381 |
+
|
| 382 |
+
### 1. Waveform Visualization
|
| 383 |
+
Currently, canvas element is included but not used. Could add:
|
| 384 |
+
```javascript
|
| 385 |
+
function drawWaveform() {
|
| 386 |
+
// Analyze audio buffer
|
| 387 |
+
// Draw waveform on canvas
|
| 388 |
+
// Update on window resize
|
| 389 |
+
}
|
| 390 |
+
```
|
| 391 |
+
|
| 392 |
+
### 2. Playback Speed Control
|
| 393 |
+
```html
|
| 394 |
+
<select id="playback-rate">
|
| 395 |
+
<option value="0.5">0.5x</option>
|
| 396 |
+
<option value="1" selected>1x</option>
|
| 397 |
+
<option value="1.5">1.5x</option>
|
| 398 |
+
<option value="2">2x</option>
|
| 399 |
+
</select>
|
| 400 |
+
```
|
| 401 |
+
|
| 402 |
+
### 3. Loop/Repeat Utterance
|
| 403 |
+
```javascript
|
| 404 |
+
function loopUtterance(index) {
|
| 405 |
+
const utt = state.utterances[index];
|
| 406 |
+
audio.addEventListener('timeupdate', () => {
|
| 407 |
+
if (audio.currentTime >= utt.end) {
|
| 408 |
+
audio.currentTime = utt.start;
|
| 409 |
+
}
|
| 410 |
+
});
|
| 411 |
+
}
|
| 412 |
+
```
|
| 413 |
+
|
| 414 |
+
### 4. Bookmark/Marker System
|
| 415 |
+
Allow users to add markers at specific times for later reference.
|
| 416 |
+
|
| 417 |
+
---
|
| 418 |
+
|
| 419 |
+
## Testing Checklist
|
| 420 |
+
|
| 421 |
+
### Functionality Tests
|
| 422 |
+
|
| 423 |
+
- [ ] β
Play/Pause button works
|
| 424 |
+
- [ ] β
Timeline click seeks correctly
|
| 425 |
+
- [ ] β
Timeline drag seeks correctly
|
| 426 |
+
- [ ] β
Volume slider works
|
| 427 |
+
- [ ] β
Mute button toggles correctly
|
| 428 |
+
- [ ] β
Time displays update
|
| 429 |
+
- [ ] β
Segments render with correct positions
|
| 430 |
+
- [ ] β
Speaker colors applied correctly
|
| 431 |
+
- [ ] β
Active segment highlights correctly
|
| 432 |
+
- [ ] β
Clicking segment seeks to utterance
|
| 433 |
+
- [ ] β
Keyboard shortcuts work
|
| 434 |
+
- [ ] β
Transcript sync still works
|
| 435 |
+
- [ ] β
Click-to-seek from transcript works
|
| 436 |
+
|
| 437 |
+
### Responsive Tests
|
| 438 |
+
|
| 439 |
+
- [ ] β
Full width on desktop
|
| 440 |
+
- [ ] β
Timeline wraps on mobile
|
| 441 |
+
- [ ] β
Controls remain usable on small screens
|
| 442 |
+
- [ ] β
Touch events work on mobile
|
| 443 |
+
|
| 444 |
+
### Edge Cases
|
| 445 |
+
|
| 446 |
+
- [ ] β
No utterances: Timeline empty
|
| 447 |
+
- [ ] β
Many utterances (100+): Performance OK
|
| 448 |
+
- [ ] β
Long audio (1+ hour): Segments visible
|
| 449 |
+
- [ ] β
Short utterances (<1s): Still clickable
|
| 450 |
+
- [ ] β
No diarization: Segments use default color
|
| 451 |
+
|
| 452 |
+
---
|
| 453 |
+
|
| 454 |
+
## Summary
|
| 455 |
+
|
| 456 |
+
### What Changed
|
| 457 |
+
|
| 458 |
+
| Component | Before | After |
|
| 459 |
+
|-----------|--------|-------|
|
| 460 |
+
| **Player Width** | Default (varies) | Full width (100%) |
|
| 461 |
+
| **Timeline** | Native progress bar | Custom visual timeline |
|
| 462 |
+
| **Utterance Visualization** | None | Color-coded segments |
|
| 463 |
+
| **Speaker Colors** | None | 10 unique colors |
|
| 464 |
+
| **Controls** | Native HTML5 | Custom styled |
|
| 465 |
+
| **Keyboard Support** | None | Space, Arrows |
|
| 466 |
+
| **Mobile Support** | Basic | Optimized responsive |
|
| 467 |
+
|
| 468 |
+
### What Stayed the Same
|
| 469 |
+
|
| 470 |
+
β
All existing features preserved:
|
| 471 |
+
- Bidirectional sync player β transcript
|
| 472 |
+
- Drag-to-seek functionality
|
| 473 |
+
- Click utterance to seek
|
| 474 |
+
- Edit functionality
|
| 475 |
+
- Real-time highlighting
|
| 476 |
+
|
| 477 |
+
### New Capabilities
|
| 478 |
+
|
| 479 |
+
π Timeline segments visualization
|
| 480 |
+
π Speaker color-coding
|
| 481 |
+
π Click segments to seek
|
| 482 |
+
π Keyboard shortcuts
|
| 483 |
+
π Enhanced UX with animations
|
| 484 |
+
π Responsive full-width layout
|
| 485 |
+
|
| 486 |
+
---
|
| 487 |
+
|
| 488 |
+
## Files Modified
|
| 489 |
+
|
| 490 |
+
1. **frontend/index.html**
|
| 491 |
+
- Replaced native `<audio controls>` with custom player structure
|
| 492 |
+
- Added timeline container with canvas and segments
|
| 493 |
+
|
| 494 |
+
2. **frontend/styles.css**
|
| 495 |
+
- Added ~250 lines of custom player styling
|
| 496 |
+
- Responsive media queries
|
| 497 |
+
- Speaker color classes
|
| 498 |
+
- Smooth animations
|
| 499 |
+
|
| 500 |
+
3. **frontend/app.js**
|
| 501 |
+
- Added `initCustomAudioPlayer()` function
|
| 502 |
+
- Added `renderTimelineSegments()` function
|
| 503 |
+
- Added `updateActiveSegment()` function
|
| 504 |
+
- Added `seekToPosition()` helper
|
| 505 |
+
- Updated `renderTranscript()` to update timeline
|
| 506 |
+
- Updated `initAudioInteractions()` to sync timeline
|
| 507 |
+
|
| 508 |
+
---
|
| 509 |
+
|
| 510 |
+
## Result
|
| 511 |
+
|
| 512 |
+
π **A modern, feature-rich audio player that provides visual feedback about the audio structure while maintaining all existing functionality!**
|
| 513 |
+
|
| 514 |
+
The timeline gives users an instant overview of:
|
| 515 |
+
- Where utterances are located
|
| 516 |
+
- Which parts have which speakers
|
| 517 |
+
- Current playback position
|
| 518 |
+
- Easy navigation by clicking segments
|
| 519 |
+
|
| 520 |
+
Perfect for long-form audio with multiple speakers! ποΈ
|
|
@@ -60,6 +60,19 @@ const elements = {
|
|
| 60 |
progressFill: document.getElementById('progress-fill'),
|
| 61 |
cancelTranscribeBtn: document.getElementById('cancel-transcribe-btn'),
|
| 62 |
cancelSummaryBtn: document.getElementById('cancel-summary-btn'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 63 |
};
|
| 64 |
|
| 65 |
const TRANSCRIPT_FORMATS = [
|
|
@@ -427,6 +440,9 @@ function renderTranscript() {
|
|
| 427 |
}
|
| 428 |
|
| 429 |
elements.utteranceCount.textContent = `${state.utterances.length} segments`;
|
|
|
|
|
|
|
|
|
|
| 430 |
}
|
| 431 |
|
| 432 |
function renderDiarizationStats() {
|
|
@@ -501,7 +517,10 @@ function initAudioInteractions() {
|
|
| 501 |
elements.audioPlayer.addEventListener('timeupdate', () => {
|
| 502 |
if (!state.utterances.length) return;
|
| 503 |
const idx = findActiveUtterance(elements.audioPlayer.currentTime);
|
| 504 |
-
if (idx >= 0)
|
|
|
|
|
|
|
|
|
|
| 505 |
});
|
| 506 |
|
| 507 |
elements.transcriptList.addEventListener('click', (event) => {
|
|
@@ -652,6 +671,211 @@ function seekToTime(timeInSeconds) {
|
|
| 652 |
}
|
| 653 |
}
|
| 654 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 655 |
async function handleSummaryGeneration() {
|
| 656 |
if (state.summarizing || !state.utterances.length) return;
|
| 657 |
state.summarizing = true;
|
|
@@ -994,6 +1218,9 @@ document.addEventListener('DOMContentLoaded', async () => {
|
|
| 994 |
|
| 995 |
// Initialize audio interactions
|
| 996 |
initAudioInteractions();
|
|
|
|
|
|
|
|
|
|
| 997 |
|
| 998 |
// Load configuration
|
| 999 |
await fetchConfig();
|
|
|
|
| 60 |
progressFill: document.getElementById('progress-fill'),
|
| 61 |
cancelTranscribeBtn: document.getElementById('cancel-transcribe-btn'),
|
| 62 |
cancelSummaryBtn: document.getElementById('cancel-summary-btn'),
|
| 63 |
+
// Custom player elements
|
| 64 |
+
playPauseBtn: document.getElementById('play-pause-btn'),
|
| 65 |
+
playIcon: document.querySelector('.play-icon'),
|
| 66 |
+
pauseIcon: document.querySelector('.pause-icon'),
|
| 67 |
+
currentTimeDisplay: document.getElementById('current-time'),
|
| 68 |
+
durationTimeDisplay: document.getElementById('duration-time'),
|
| 69 |
+
timelineBar: document.getElementById('timeline-bar'),
|
| 70 |
+
timelineProgress: document.getElementById('timeline-progress'),
|
| 71 |
+
timelineSegments: document.getElementById('timeline-segments'),
|
| 72 |
+
timelineHandle: document.getElementById('timeline-handle'),
|
| 73 |
+
waveformCanvas: document.getElementById('waveform-canvas'),
|
| 74 |
+
volumeBtn: document.getElementById('volume-btn'),
|
| 75 |
+
volumeSlider: document.getElementById('volume-slider'),
|
| 76 |
};
|
| 77 |
|
| 78 |
const TRANSCRIPT_FORMATS = [
|
|
|
|
| 440 |
}
|
| 441 |
|
| 442 |
elements.utteranceCount.textContent = `${state.utterances.length} segments`;
|
| 443 |
+
|
| 444 |
+
// Update timeline segments when transcript changes
|
| 445 |
+
renderTimelineSegments();
|
| 446 |
}
|
| 447 |
|
| 448 |
function renderDiarizationStats() {
|
|
|
|
| 517 |
elements.audioPlayer.addEventListener('timeupdate', () => {
|
| 518 |
if (!state.utterances.length) return;
|
| 519 |
const idx = findActiveUtterance(elements.audioPlayer.currentTime);
|
| 520 |
+
if (idx >= 0) {
|
| 521 |
+
updateActiveUtterance(idx);
|
| 522 |
+
updateActiveSegment();
|
| 523 |
+
}
|
| 524 |
});
|
| 525 |
|
| 526 |
elements.transcriptList.addEventListener('click', (event) => {
|
|
|
|
| 671 |
}
|
| 672 |
}
|
| 673 |
|
| 674 |
+
// ==================== Custom Audio Player Functions ====================
|
| 675 |
+
|
| 676 |
+
function initCustomAudioPlayer() {
|
| 677 |
+
const audio = elements.audioPlayer;
|
| 678 |
+
|
| 679 |
+
// Play/Pause button
|
| 680 |
+
elements.playPauseBtn.addEventListener('click', () => {
|
| 681 |
+
if (audio.paused) {
|
| 682 |
+
audio.play();
|
| 683 |
+
} else {
|
| 684 |
+
audio.pause();
|
| 685 |
+
}
|
| 686 |
+
});
|
| 687 |
+
|
| 688 |
+
// Update play/pause icon
|
| 689 |
+
audio.addEventListener('play', () => {
|
| 690 |
+
elements.playIcon.classList.add('hidden');
|
| 691 |
+
elements.pauseIcon.classList.remove('hidden');
|
| 692 |
+
});
|
| 693 |
+
|
| 694 |
+
audio.addEventListener('pause', () => {
|
| 695 |
+
elements.playIcon.classList.remove('hidden');
|
| 696 |
+
elements.pauseIcon.classList.add('hidden');
|
| 697 |
+
});
|
| 698 |
+
|
| 699 |
+
// Time update
|
| 700 |
+
audio.addEventListener('timeupdate', () => {
|
| 701 |
+
updateTimelinePosition();
|
| 702 |
+
updateTimeDisplays();
|
| 703 |
+
});
|
| 704 |
+
|
| 705 |
+
// Duration loaded
|
| 706 |
+
audio.addEventListener('loadedmetadata', () => {
|
| 707 |
+
updateTimeDisplays();
|
| 708 |
+
renderTimelineSegments();
|
| 709 |
+
});
|
| 710 |
+
|
| 711 |
+
audio.addEventListener('durationchange', () => {
|
| 712 |
+
updateTimeDisplays();
|
| 713 |
+
renderTimelineSegments();
|
| 714 |
+
});
|
| 715 |
+
|
| 716 |
+
// Timeline click and drag
|
| 717 |
+
let isDragging = false;
|
| 718 |
+
|
| 719 |
+
elements.timelineBar.addEventListener('mousedown', (e) => {
|
| 720 |
+
isDragging = true;
|
| 721 |
+
seekToPosition(e);
|
| 722 |
+
});
|
| 723 |
+
|
| 724 |
+
document.addEventListener('mousemove', (e) => {
|
| 725 |
+
if (isDragging) {
|
| 726 |
+
seekToPosition(e);
|
| 727 |
+
}
|
| 728 |
+
});
|
| 729 |
+
|
| 730 |
+
document.addEventListener('mouseup', () => {
|
| 731 |
+
isDragging = false;
|
| 732 |
+
});
|
| 733 |
+
|
| 734 |
+
elements.timelineBar.addEventListener('click', (e) => {
|
| 735 |
+
if (!isDragging) {
|
| 736 |
+
seekToPosition(e);
|
| 737 |
+
}
|
| 738 |
+
});
|
| 739 |
+
|
| 740 |
+
// Volume controls
|
| 741 |
+
elements.volumeBtn.addEventListener('click', () => {
|
| 742 |
+
audio.muted = !audio.muted;
|
| 743 |
+
updateVolumeIcon();
|
| 744 |
+
});
|
| 745 |
+
|
| 746 |
+
elements.volumeSlider.addEventListener('input', (e) => {
|
| 747 |
+
audio.volume = e.target.value / 100;
|
| 748 |
+
audio.muted = false;
|
| 749 |
+
updateVolumeIcon();
|
| 750 |
+
});
|
| 751 |
+
|
| 752 |
+
audio.addEventListener('volumechange', () => {
|
| 753 |
+
updateVolumeIcon();
|
| 754 |
+
});
|
| 755 |
+
|
| 756 |
+
// Keyboard shortcuts
|
| 757 |
+
document.addEventListener('keydown', (e) => {
|
| 758 |
+
// Only if not typing in an input/textarea
|
| 759 |
+
if (e.target.tagName === 'INPUT' || e.target.tagName === 'TEXTAREA') return;
|
| 760 |
+
|
| 761 |
+
if (e.code === 'Space') {
|
| 762 |
+
e.preventDefault();
|
| 763 |
+
if (audio.paused) {
|
| 764 |
+
audio.play();
|
| 765 |
+
} else {
|
| 766 |
+
audio.pause();
|
| 767 |
+
}
|
| 768 |
+
} else if (e.code === 'ArrowLeft') {
|
| 769 |
+
e.preventDefault();
|
| 770 |
+
audio.currentTime = Math.max(0, audio.currentTime - 5);
|
| 771 |
+
} else if (e.code === 'ArrowRight') {
|
| 772 |
+
e.preventDefault();
|
| 773 |
+
audio.currentTime = Math.min(audio.duration, audio.currentTime + 5);
|
| 774 |
+
}
|
| 775 |
+
});
|
| 776 |
+
}
|
| 777 |
+
|
| 778 |
+
function seekToPosition(e) {
|
| 779 |
+
const audio = elements.audioPlayer;
|
| 780 |
+
const rect = elements.timelineBar.getBoundingClientRect();
|
| 781 |
+
const percent = Math.max(0, Math.min(1, (e.clientX - rect.left) / rect.width));
|
| 782 |
+
audio.currentTime = percent * audio.duration;
|
| 783 |
+
}
|
| 784 |
+
|
| 785 |
+
function updateTimelinePosition() {
|
| 786 |
+
const audio = elements.audioPlayer;
|
| 787 |
+
if (!audio.duration) return;
|
| 788 |
+
|
| 789 |
+
const percent = (audio.currentTime / audio.duration) * 100;
|
| 790 |
+
elements.timelineProgress.style.width = `${percent}%`;
|
| 791 |
+
elements.timelineHandle.style.left = `${percent}%`;
|
| 792 |
+
}
|
| 793 |
+
|
| 794 |
+
function updateTimeDisplays() {
|
| 795 |
+
const audio = elements.audioPlayer;
|
| 796 |
+
elements.currentTimeDisplay.textContent = formatTime(audio.currentTime || 0);
|
| 797 |
+
elements.durationTimeDisplay.textContent = formatTime(audio.duration || 0);
|
| 798 |
+
}
|
| 799 |
+
|
| 800 |
+
function updateVolumeIcon() {
|
| 801 |
+
const audio = elements.audioPlayer;
|
| 802 |
+
if (audio.muted || audio.volume === 0) {
|
| 803 |
+
elements.volumeBtn.textContent = 'π';
|
| 804 |
+
} else if (audio.volume < 0.5) {
|
| 805 |
+
elements.volumeBtn.textContent = 'π';
|
| 806 |
+
} else {
|
| 807 |
+
elements.volumeBtn.textContent = 'π';
|
| 808 |
+
}
|
| 809 |
+
}
|
| 810 |
+
|
| 811 |
+
function renderTimelineSegments() {
|
| 812 |
+
const audio = elements.audioPlayer;
|
| 813 |
+
if (!audio.duration || !state.utterances.length) {
|
| 814 |
+
elements.timelineSegments.innerHTML = '';
|
| 815 |
+
return;
|
| 816 |
+
}
|
| 817 |
+
|
| 818 |
+
elements.timelineSegments.innerHTML = '';
|
| 819 |
+
const fragment = document.createDocumentFragment();
|
| 820 |
+
|
| 821 |
+
state.utterances.forEach((utt, index) => {
|
| 822 |
+
const segment = document.createElement('div');
|
| 823 |
+
segment.className = 'timeline-segment';
|
| 824 |
+
segment.dataset.index = index;
|
| 825 |
+
|
| 826 |
+
// Calculate position and width as percentage
|
| 827 |
+
const startPercent = (utt.start / audio.duration) * 100;
|
| 828 |
+
const endPercent = (utt.end / audio.duration) * 100;
|
| 829 |
+
const widthPercent = endPercent - startPercent;
|
| 830 |
+
|
| 831 |
+
segment.style.left = `${startPercent}%`;
|
| 832 |
+
segment.style.width = `${widthPercent}%`;
|
| 833 |
+
|
| 834 |
+
// Apply speaker color if available
|
| 835 |
+
if (typeof utt.speaker === 'number') {
|
| 836 |
+
segment.classList.add(`speaker-${utt.speaker % 10}`);
|
| 837 |
+
} else {
|
| 838 |
+
segment.style.backgroundColor = 'rgba(148, 163, 184, 0.5)';
|
| 839 |
+
}
|
| 840 |
+
|
| 841 |
+
// Add tooltip
|
| 842 |
+
const speakerInfo = typeof utt.speaker === 'number'
|
| 843 |
+
? (state.speakerNames?.[utt.speaker]?.name || `Speaker ${utt.speaker + 1}`)
|
| 844 |
+
: '';
|
| 845 |
+
segment.title = `${speakerInfo ? speakerInfo + ': ' : ''}${utt.text.substring(0, 50)}${utt.text.length > 50 ? '...' : ''}`;
|
| 846 |
+
|
| 847 |
+
// Click to seek
|
| 848 |
+
segment.addEventListener('click', (e) => {
|
| 849 |
+
e.stopPropagation();
|
| 850 |
+
seekToTime(utt.start);
|
| 851 |
+
});
|
| 852 |
+
|
| 853 |
+
fragment.appendChild(segment);
|
| 854 |
+
});
|
| 855 |
+
|
| 856 |
+
elements.timelineSegments.appendChild(fragment);
|
| 857 |
+
|
| 858 |
+
// Update active segment on time update
|
| 859 |
+
updateActiveSegment();
|
| 860 |
+
}
|
| 861 |
+
|
| 862 |
+
function updateActiveSegment() {
|
| 863 |
+
const audio = elements.audioPlayer;
|
| 864 |
+
if (!state.utterances.length) return;
|
| 865 |
+
|
| 866 |
+
const currentIndex = findActiveUtterance(audio.currentTime);
|
| 867 |
+
|
| 868 |
+
// Remove previous active
|
| 869 |
+
const prevActive = elements.timelineSegments.querySelector('.timeline-segment.active');
|
| 870 |
+
if (prevActive) prevActive.classList.remove('active');
|
| 871 |
+
|
| 872 |
+
// Add active to current
|
| 873 |
+
if (currentIndex >= 0) {
|
| 874 |
+
const activeSegment = elements.timelineSegments.querySelector(`.timeline-segment[data-index="${currentIndex}"]`);
|
| 875 |
+
if (activeSegment) activeSegment.classList.add('active');
|
| 876 |
+
}
|
| 877 |
+
}
|
| 878 |
+
|
| 879 |
async function handleSummaryGeneration() {
|
| 880 |
if (state.summarizing || !state.utterances.length) return;
|
| 881 |
state.summarizing = true;
|
|
|
|
| 1218 |
|
| 1219 |
// Initialize audio interactions
|
| 1220 |
initAudioInteractions();
|
| 1221 |
+
|
| 1222 |
+
// Initialize custom audio player
|
| 1223 |
+
initCustomAudioPlayer();
|
| 1224 |
|
| 1225 |
// Load configuration
|
| 1226 |
await fetchConfig();
|
|
@@ -139,9 +139,37 @@
|
|
| 139 |
</div>
|
| 140 |
</div>
|
| 141 |
|
| 142 |
-
<section class="panel">
|
| 143 |
<h2>Audio Player</h2>
|
| 144 |
-
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 145 |
</section>
|
| 146 |
|
| 147 |
<section class="panel">
|
|
|
|
| 139 |
</div>
|
| 140 |
</div>
|
| 141 |
|
| 142 |
+
<section class="panel audio-player-panel">
|
| 143 |
<h2>Audio Player</h2>
|
| 144 |
+
<div class="custom-audio-player">
|
| 145 |
+
<audio id="audio-player" preload="auto"></audio>
|
| 146 |
+
|
| 147 |
+
<!-- Custom Controls -->
|
| 148 |
+
<div class="player-controls">
|
| 149 |
+
<button id="play-pause-btn" class="play-pause-btn" title="Play/Pause">
|
| 150 |
+
<span class="play-icon">βΆ</span>
|
| 151 |
+
<span class="pause-icon hidden">βΈ</span>
|
| 152 |
+
</button>
|
| 153 |
+
|
| 154 |
+
<span id="current-time" class="time-display">0:00</span>
|
| 155 |
+
|
| 156 |
+
<div class="timeline-container">
|
| 157 |
+
<canvas id="waveform-canvas" class="waveform-canvas"></canvas>
|
| 158 |
+
<div id="timeline-bar" class="timeline-bar">
|
| 159 |
+
<div id="timeline-progress" class="timeline-progress"></div>
|
| 160 |
+
<div id="timeline-segments" class="timeline-segments"></div>
|
| 161 |
+
<div id="timeline-handle" class="timeline-handle"></div>
|
| 162 |
+
</div>
|
| 163 |
+
</div>
|
| 164 |
+
|
| 165 |
+
<span id="duration-time" class="time-display">0:00</span>
|
| 166 |
+
|
| 167 |
+
<div class="volume-control">
|
| 168 |
+
<button id="volume-btn" class="volume-btn" title="Mute/Unmute">π</button>
|
| 169 |
+
<input id="volume-slider" type="range" min="0" max="100" value="100" class="volume-slider" />
|
| 170 |
+
</div>
|
| 171 |
+
</div>
|
| 172 |
+
</div>
|
| 173 |
</section>
|
| 174 |
|
| 175 |
<section class="panel">
|
|
@@ -597,6 +597,235 @@ button:hover {
|
|
| 597 |
display: none !important;
|
| 598 |
}
|
| 599 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 600 |
@media (max-width: 1100px) {
|
| 601 |
.app-shell {
|
| 602 |
grid-template-columns: 1fr;
|
|
@@ -609,4 +838,14 @@ button:hover {
|
|
| 609 |
.content {
|
| 610 |
order: 1;
|
| 611 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 612 |
}
|
|
|
|
| 597 |
display: none !important;
|
| 598 |
}
|
| 599 |
|
| 600 |
+
/* ==================== Custom Audio Player ==================== */
|
| 601 |
+
|
| 602 |
+
.audio-player-panel {
|
| 603 |
+
width: 100%;
|
| 604 |
+
}
|
| 605 |
+
|
| 606 |
+
.custom-audio-player {
|
| 607 |
+
width: 100%;
|
| 608 |
+
}
|
| 609 |
+
|
| 610 |
+
#audio-player {
|
| 611 |
+
display: none; /* Hide native player, use custom controls */
|
| 612 |
+
}
|
| 613 |
+
|
| 614 |
+
.player-controls {
|
| 615 |
+
display: flex;
|
| 616 |
+
align-items: center;
|
| 617 |
+
gap: 1rem;
|
| 618 |
+
padding: 0.5rem;
|
| 619 |
+
background: rgba(15, 23, 42, 0.5);
|
| 620 |
+
border-radius: 12px;
|
| 621 |
+
border: 1px solid rgba(148, 163, 184, 0.2);
|
| 622 |
+
}
|
| 623 |
+
|
| 624 |
+
.play-pause-btn {
|
| 625 |
+
width: 48px;
|
| 626 |
+
height: 48px;
|
| 627 |
+
border-radius: 50%;
|
| 628 |
+
border: none;
|
| 629 |
+
background: linear-gradient(135deg, #38bdf8 0%, #818cf8 100%);
|
| 630 |
+
color: #0f172a;
|
| 631 |
+
font-size: 1.2rem;
|
| 632 |
+
cursor: pointer;
|
| 633 |
+
transition: all 0.2s ease;
|
| 634 |
+
display: flex;
|
| 635 |
+
align-items: center;
|
| 636 |
+
justify-content: center;
|
| 637 |
+
flex-shrink: 0;
|
| 638 |
+
}
|
| 639 |
+
|
| 640 |
+
.play-pause-btn:hover {
|
| 641 |
+
transform: scale(1.05);
|
| 642 |
+
box-shadow: 0 0 20px rgba(56, 189, 248, 0.4);
|
| 643 |
+
}
|
| 644 |
+
|
| 645 |
+
.play-pause-btn:active {
|
| 646 |
+
transform: scale(0.95);
|
| 647 |
+
}
|
| 648 |
+
|
| 649 |
+
.play-icon,
|
| 650 |
+
.pause-icon {
|
| 651 |
+
display: block;
|
| 652 |
+
line-height: 1;
|
| 653 |
+
}
|
| 654 |
+
|
| 655 |
+
.time-display {
|
| 656 |
+
font-size: 0.9rem;
|
| 657 |
+
color: #94a3b8;
|
| 658 |
+
min-width: 45px;
|
| 659 |
+
text-align: center;
|
| 660 |
+
font-variant-numeric: tabular-nums;
|
| 661 |
+
flex-shrink: 0;
|
| 662 |
+
}
|
| 663 |
+
|
| 664 |
+
.timeline-container {
|
| 665 |
+
flex: 1;
|
| 666 |
+
position: relative;
|
| 667 |
+
height: 48px;
|
| 668 |
+
min-width: 0;
|
| 669 |
+
}
|
| 670 |
+
|
| 671 |
+
.waveform-canvas {
|
| 672 |
+
position: absolute;
|
| 673 |
+
top: 0;
|
| 674 |
+
left: 0;
|
| 675 |
+
width: 100%;
|
| 676 |
+
height: 100%;
|
| 677 |
+
border-radius: 8px;
|
| 678 |
+
background: rgba(15, 23, 42, 0.6);
|
| 679 |
+
pointer-events: none;
|
| 680 |
+
}
|
| 681 |
+
|
| 682 |
+
.timeline-bar {
|
| 683 |
+
position: relative;
|
| 684 |
+
width: 100%;
|
| 685 |
+
height: 100%;
|
| 686 |
+
cursor: pointer;
|
| 687 |
+
border-radius: 8px;
|
| 688 |
+
overflow: hidden;
|
| 689 |
+
background: rgba(15, 23, 42, 0.6);
|
| 690 |
+
}
|
| 691 |
+
|
| 692 |
+
.timeline-progress {
|
| 693 |
+
position: absolute;
|
| 694 |
+
top: 0;
|
| 695 |
+
left: 0;
|
| 696 |
+
height: 100%;
|
| 697 |
+
background: linear-gradient(90deg, rgba(56, 189, 248, 0.3) 0%, rgba(129, 140, 248, 0.3) 100%);
|
| 698 |
+
pointer-events: none;
|
| 699 |
+
transition: width 0.1s linear;
|
| 700 |
+
z-index: 1;
|
| 701 |
+
}
|
| 702 |
+
|
| 703 |
+
.timeline-segments {
|
| 704 |
+
position: absolute;
|
| 705 |
+
top: 0;
|
| 706 |
+
left: 0;
|
| 707 |
+
width: 100%;
|
| 708 |
+
height: 100%;
|
| 709 |
+
pointer-events: none;
|
| 710 |
+
z-index: 2;
|
| 711 |
+
}
|
| 712 |
+
|
| 713 |
+
.timeline-segment {
|
| 714 |
+
position: absolute;
|
| 715 |
+
height: 100%;
|
| 716 |
+
opacity: 0.4;
|
| 717 |
+
transition: opacity 0.2s ease;
|
| 718 |
+
border-right: 1px solid rgba(0, 0, 0, 0.2);
|
| 719 |
+
}
|
| 720 |
+
|
| 721 |
+
.timeline-segment:hover {
|
| 722 |
+
opacity: 0.6;
|
| 723 |
+
}
|
| 724 |
+
|
| 725 |
+
.timeline-segment.active {
|
| 726 |
+
opacity: 0.8;
|
| 727 |
+
box-shadow: inset 0 0 10px rgba(255, 255, 255, 0.2);
|
| 728 |
+
}
|
| 729 |
+
|
| 730 |
+
.timeline-handle {
|
| 731 |
+
position: absolute;
|
| 732 |
+
top: 50%;
|
| 733 |
+
left: 0;
|
| 734 |
+
transform: translate(-50%, -50%);
|
| 735 |
+
width: 16px;
|
| 736 |
+
height: 16px;
|
| 737 |
+
background: #38bdf8;
|
| 738 |
+
border: 2px solid #0f172a;
|
| 739 |
+
border-radius: 50%;
|
| 740 |
+
pointer-events: none;
|
| 741 |
+
z-index: 3;
|
| 742 |
+
box-shadow: 0 0 10px rgba(56, 189, 248, 0.6);
|
| 743 |
+
transition: transform 0.1s ease;
|
| 744 |
+
}
|
| 745 |
+
|
| 746 |
+
.timeline-bar:hover .timeline-handle {
|
| 747 |
+
transform: translate(-50%, -50%) scale(1.2);
|
| 748 |
+
}
|
| 749 |
+
|
| 750 |
+
.volume-control {
|
| 751 |
+
display: flex;
|
| 752 |
+
align-items: center;
|
| 753 |
+
gap: 0.5rem;
|
| 754 |
+
flex-shrink: 0;
|
| 755 |
+
}
|
| 756 |
+
|
| 757 |
+
.volume-btn {
|
| 758 |
+
width: 36px;
|
| 759 |
+
height: 36px;
|
| 760 |
+
border-radius: 50%;
|
| 761 |
+
border: none;
|
| 762 |
+
background: rgba(148, 163, 184, 0.2);
|
| 763 |
+
color: #e5e7eb;
|
| 764 |
+
font-size: 1rem;
|
| 765 |
+
cursor: pointer;
|
| 766 |
+
transition: all 0.2s ease;
|
| 767 |
+
display: flex;
|
| 768 |
+
align-items: center;
|
| 769 |
+
justify-content: center;
|
| 770 |
+
}
|
| 771 |
+
|
| 772 |
+
.volume-btn:hover {
|
| 773 |
+
background: rgba(148, 163, 184, 0.3);
|
| 774 |
+
}
|
| 775 |
+
|
| 776 |
+
.volume-slider {
|
| 777 |
+
width: 80px;
|
| 778 |
+
height: 4px;
|
| 779 |
+
-webkit-appearance: none;
|
| 780 |
+
appearance: none;
|
| 781 |
+
background: rgba(148, 163, 184, 0.3);
|
| 782 |
+
border-radius: 2px;
|
| 783 |
+
outline: none;
|
| 784 |
+
}
|
| 785 |
+
|
| 786 |
+
.volume-slider::-webkit-slider-thumb {
|
| 787 |
+
-webkit-appearance: none;
|
| 788 |
+
appearance: none;
|
| 789 |
+
width: 14px;
|
| 790 |
+
height: 14px;
|
| 791 |
+
background: #38bdf8;
|
| 792 |
+
border-radius: 50%;
|
| 793 |
+
cursor: pointer;
|
| 794 |
+
transition: all 0.2s ease;
|
| 795 |
+
}
|
| 796 |
+
|
| 797 |
+
.volume-slider::-webkit-slider-thumb:hover {
|
| 798 |
+
transform: scale(1.2);
|
| 799 |
+
box-shadow: 0 0 10px rgba(56, 189, 248, 0.6);
|
| 800 |
+
}
|
| 801 |
+
|
| 802 |
+
.volume-slider::-moz-range-thumb {
|
| 803 |
+
width: 14px;
|
| 804 |
+
height: 14px;
|
| 805 |
+
background: #38bdf8;
|
| 806 |
+
border-radius: 50%;
|
| 807 |
+
border: none;
|
| 808 |
+
cursor: pointer;
|
| 809 |
+
transition: all 0.2s ease;
|
| 810 |
+
}
|
| 811 |
+
|
| 812 |
+
.volume-slider::-moz-range-thumb:hover {
|
| 813 |
+
transform: scale(1.2);
|
| 814 |
+
box-shadow: 0 0 10px rgba(56, 189, 248, 0.6);
|
| 815 |
+
}
|
| 816 |
+
|
| 817 |
+
/* Speaker colors for timeline segments */
|
| 818 |
+
.speaker-0 { background-color: #ef4444; } /* Red */
|
| 819 |
+
.speaker-1 { background-color: #3b82f6; } /* Blue */
|
| 820 |
+
.speaker-2 { background-color: #10b981; } /* Green */
|
| 821 |
+
.speaker-3 { background-color: #f59e0b; } /* Amber */
|
| 822 |
+
.speaker-4 { background-color: #8b5cf6; } /* Purple */
|
| 823 |
+
.speaker-5 { background-color: #ec4899; } /* Pink */
|
| 824 |
+
.speaker-6 { background-color: #14b8a6; } /* Teal */
|
| 825 |
+
.speaker-7 { background-color: #f97316; } /* Orange */
|
| 826 |
+
.speaker-8 { background-color: #06b6d4; } /* Cyan */
|
| 827 |
+
.speaker-9 { background-color: #84cc16; } /* Lime */
|
| 828 |
+
|
| 829 |
@media (max-width: 1100px) {
|
| 830 |
.app-shell {
|
| 831 |
grid-template-columns: 1fr;
|
|
|
|
| 838 |
.content {
|
| 839 |
order: 1;
|
| 840 |
}
|
| 841 |
+
|
| 842 |
+
.player-controls {
|
| 843 |
+
flex-wrap: wrap;
|
| 844 |
+
}
|
| 845 |
+
|
| 846 |
+
.timeline-container {
|
| 847 |
+
order: 10;
|
| 848 |
+
width: 100%;
|
| 849 |
+
flex-basis: 100%;
|
| 850 |
+
}
|
| 851 |
}
|