@moq/watch: expose AudioContext on the audio backend#1365
Conversation
The WebCodecs decoder owns its own AudioContext but doesn't surface it past the Decoder class. Browsers create the context in `suspended` state when there's no user gesture, and applications need a handle on it to prompt the user (e.g. a "click to enable audio" button) and call `resume()` from within a real gesture handler. Add `context: Getter<AudioContext | undefined>` to `Audio.Backend` and proxy it from the WebCodecs path in `MultiBackend`. The MSE backend plays through the `<video>` element rather than WebAudio, so its `context` signal stays undefined.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughA 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
✨ Simplify code
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Review rate limit: 7/8 reviews remaining, refill in 7 minutes and 30 seconds.Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@js/watch/src/backend.ts`:
- Line 186: The call to effect.proxy(this.audio.context, audioSource.context)
can leave this.audio.context bound to a stale/closed AudioContext when switching
to the MSE (video) path because `#runMse` never rebinds or clears it; update
`#runMse` (or the MSE initialization path) to explicitly reset/unproxy
this.audio.context (e.g., call effect.proxy(undefined, this.audio.context) or
set this.audio.context = undefined before/after entering the MSE flow) so
consumers don’t see an old AudioContext, and ensure any existing bindings
between effect.proxy and audioSource.context are removed when switching to MSE.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: fd20bfff-bb06-49ae-b33d-ff368d36478d
📒 Files selected for processing (3)
js/watch/src/audio/backend.tsjs/watch/src/audio/mse.tsjs/watch/src/backend.ts
kixelated
left a comment
There was a problem hiding this comment.
One thing code rabbit called out
The WebCodecs decoder owns its own AudioContext but doesn't surface it past the Decoder class. Browsers create the context in
suspendedstate when there's no user gesture, and applications need a handle on it to prompt the user (e.g. a "click to enable audio" button) and callresume()from within a real gesture handler.Add
context: Getter<AudioContext | undefined>toAudio.Backendand proxy it from the WebCodecs path inMultiBackend. The MSE backend plays through the<video>element rather than WebAudio, so itscontextsignal stays undefined.