Commit 4a45ccf
authored
feat: add Web Audio routing to MediaElementTrack for fades (#318)
* feat: add Web Audio routing to MediaElementTrack for fades
Extract fade utilities from playout to core package so they can be
shared with media-element-playout. Add optional AudioContext support
to MediaElementTrack that routes audio through a Web Audio graph
(source → fadeGain → volumeGain → destination) enabling fade in/out
effects without Tone.js dependency.
Rewrite FadesExample and StylingExample to use MediaElementPlaylistProvider
with pre-computed peaks, giving each player instance independent playback
(no shared Tone.js Transport singleton).
* feat: add showFades prop to MediaElementWaveform
Expose fadeIn/fadeOut config via MediaElementDataContext and render
FadeOverlay components in MediaElementPlaylist when showFades is
enabled. Update FadesExample with show fades checkbox and lower
samplesPerPixel for visible fade curve shapes. Make StylingExample
theme descriptions explicit about color names and add boldTheme
with transparent progress for Extra Wide Bars.
* feat: add Tone.js effect bridging to MediaElement example
Add a third player to the media-element example demonstrating BitCrusher
effect via native→Tone.js bridge pattern. Tone.js is dynamically imported
after AudioContext is running to avoid AudioWorklet errors on page load.
- Add outputNode getter to MediaElementPlayout for effects wiring
- Add EffectWiring component with statechange-based lazy initialization
- Update guide, API docs, and llms.txt for audioContext prop, fades,
and Tone.js effect bridging
* docs: document WaveformPlaylistProvider single-instance constraint
Add caution admonition to WaveformPlaylistProvider API doc explaining
the shared Tone.js Transport singleton. Add Instances row to
MediaElementPlaylistProvider comparison table. Update llms.txt and
CLAUDE.md files with Tone.js dynamic import and effect bridging patterns.
* fix: address PR review issues for MediaElement fades and effects
- Fix partial fade resume to use actual curve interpolation via generateCurve()
- Add error handling to wireEffect() with fallback reconnection
- Add console.warn diagnostics to all empty catch blocks
- Wrap createMediaElementSource() in try-catch with descriptive error
- Handle AudioContext.resume() promise rejection
- Separate disconnect/reconnect in cleanup with individual try-catch
- Fix stale JSDoc (PingPongDelay → BitCrusher)
- Deduplicate FadeConfig into @waveform-playlist/core as type alias
- Lazy AudioContext creation in FadesExample via useRef
- Use String(err) instead of passing error objects to console.warn
- Wrap disconnect() in try-catch for connectOutput/disconnectOutput
- Add reconnection to guide doc cleanup example
* fix: partial fade curve shape, resume race, and guide cleanup
- Partial fades now slice the original curve instead of generating a
fresh one, preserving the correct curve shape for sCurve/logarithmic
types when seeking mid-fade
- Await AudioContext.resume() before scheduling fades to prevent
fades from being scheduled at currentTime=0 (in the past)
- Guide doc now removes statechange listener on cleanup, matching
the actual implementation in MediaElementExample
- Document why MediaElementExample uses eager AudioContext (single
context, always needed)
* fix: share single AudioContext across all fade players
Multiple AudioContexts per page is wasteful — createMediaElementSource
is per-element, not per-context, so all players can share one.1 parent d947a92 commit 4a45ccf
File tree
24 files changed
+1335
-398
lines changed- packages
- browser/src
- components
- core/src
- __tests__
- types
- media-element-playout/src
- playout/src
- website
- docs
- api
- providers
- guides
- src
- components/examples
- pages/examples
- static
24 files changed
+1335
-398
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
350 | 350 | | |
351 | 351 | | |
352 | 352 | | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
353 | 356 | | |
354 | 357 | | |
355 | 358 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
| 12 | + | |
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
30 | 34 | | |
31 | 35 | | |
32 | 36 | | |
| |||
73 | 77 | | |
74 | 78 | | |
75 | 79 | | |
| 80 | + | |
| 81 | + | |
76 | 82 | | |
77 | 83 | | |
78 | 84 | | |
| |||
111 | 117 | | |
112 | 118 | | |
113 | 119 | | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
114 | 130 | | |
115 | 131 | | |
116 | 132 | | |
| |||
145 | 161 | | |
146 | 162 | | |
147 | 163 | | |
| 164 | + | |
148 | 165 | | |
149 | 166 | | |
150 | 167 | | |
| |||
235 | 252 | | |
236 | 253 | | |
237 | 254 | | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
238 | 258 | | |
239 | 259 | | |
240 | 260 | | |
| |||
266 | 286 | | |
267 | 287 | | |
268 | 288 | | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
269 | 292 | | |
270 | 293 | | |
271 | 294 | | |
| |||
497 | 520 | | |
498 | 521 | | |
499 | 522 | | |
| 523 | + | |
| 524 | + | |
500 | 525 | | |
501 | 526 | | |
502 | 527 | | |
| |||
509 | 534 | | |
510 | 535 | | |
511 | 536 | | |
| 537 | + | |
| 538 | + | |
512 | 539 | | |
513 | 540 | | |
514 | 541 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
| |||
75 | 76 | | |
76 | 77 | | |
77 | 78 | | |
| 79 | + | |
| 80 | + | |
78 | 81 | | |
79 | 82 | | |
80 | 83 | | |
| |||
96 | 99 | | |
97 | 100 | | |
98 | 101 | | |
| 102 | + | |
99 | 103 | | |
100 | 104 | | |
101 | 105 | | |
| |||
117 | 121 | | |
118 | 122 | | |
119 | 123 | | |
| 124 | + | |
| 125 | + | |
120 | 126 | | |
121 | 127 | | |
122 | 128 | | |
| |||
327 | 333 | | |
328 | 334 | | |
329 | 335 | | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
330 | 354 | | |
331 | 355 | | |
332 | 356 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
| 38 | + | |
| 39 | + | |
38 | 40 | | |
39 | 41 | | |
40 | 42 | | |
| |||
60 | 62 | | |
61 | 63 | | |
62 | 64 | | |
| 65 | + | |
63 | 66 | | |
64 | 67 | | |
65 | 68 | | |
| |||
72 | 75 | | |
73 | 76 | | |
74 | 77 | | |
| 78 | + | |
75 | 79 | | |
76 | 80 | | |
77 | 81 | | |
| |||
0 commit comments