(t)
| 354 | } |
| 355 | |
| 356 | function seek(t) { |
| 357 | const clamped = Math.max(0, Math.min(t, _duration || 0)); |
| 358 | const wasPlaying = playing; |
| 359 | if (wasPlaying) { |
| 360 | _stopNodes(); |
| 361 | playing = false; |
| 362 | _audioStarted = false; |
| 363 | if (rafId) { cancelAnimationFrame(rafId); rafId = null; } |
| 364 | } |
| 365 | _startOffset = clamped; |
| 366 | _scheduledTo = clamped; |
| 367 | // Evict cache for chunks before the new position. |
| 368 | const newIdx = Math.floor(clamped / CHUNK_SEC); |
| 369 | for (const k of _cache.keys()) { |
| 370 | if (k < newIdx) _cache.delete(k); |
| 371 | } |
| 372 | onTime?.(clamped); |
| 373 | if (wasPlaying) play(); |
| 374 | } |
| 375 | |
| 376 | // Initialize: fetch all WAV headers in parallel and load the SoundTouch worklet. |
| 377 | // Chunk 0 is kicked off in the background so ready() resolves quickly (headers |
no test coverage detected