()
| 298 | } |
| 299 | |
| 300 | function togglePlay() { |
| 301 | if (!state.current) return; |
| 302 | ensureAudioCtx(); // unlock audio within this gesture |
| 303 | // Engine not loaded for this track yet → load then autoplay. |
| 304 | if (!engine || engineTrackId !== state.current.id) { |
| 305 | openTrack(state.current, { autoplay: true }); |
| 306 | return; |
| 307 | } |
| 308 | // Decode still in flight → remember the intent and play once ready. |
| 309 | if (!engineReady) { |
| 310 | pendingPlay = true; |
| 311 | return; |
| 312 | } |
| 313 | if (engine.isPlaying()) engine.pause(); |
| 314 | else engine.play(); |
| 315 | state.playing = engine.isPlaying(); |
| 316 | render(); |
| 317 | } |
| 318 | |
| 319 | function seekToFraction(frac) { |
| 320 | if (!engine) return; |
no test coverage detected