fix: Play remote audio and video through a single media element#152
Merged
Conversation
Emit a fresh MediaStream whenever the remote track set changes so the consumer's element re-reads its tracks. Mutating the stream in place left a late-arriving audio track without an output sink, since assigning the same MediaStream reference is a no-op. This removes the need for LiveKit to attach its own hidden elements.
commit: |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 665551a. Configure here.
VerioN1
approved these changes
May 31, 2026
…layback The connected->generating transition relied on LiveKit's VideoPlaybackStarted event, which is only emitted from track.attach(). After removing attach(), that event never fired and the session was stuck in "connected". Restore the pre-LiveKit websocket signal: transition on `generation_started`, with the first `generation_tick` as a fallback. Drop the now-dead firstFrame / VideoPlaybackStarted proxy.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

What
Remote realtime streams now deliver audio and video as one
MediaStreamthat a host app can render through a single<video>element it owns and controls — both play together, with the app in full control of the playback element. The"generating"connection state is now reported reliably, driven by the server's generation signal rather than as a side effect of internal playback.Why
Previously remote audio only played because the SDK silently spun up its own hidden media elements, leaving apps with no handle on playback (volume, sink device, muting, lifecycle), and a late-arriving audio track could be dropped entirely. Handing the app a single stream resolves both. Removing those hidden elements also meant the
connected → generatingtransition (which had been a side effect of internal video playback) no longer fired, so it's now tied to the server'sgeneration_startedsignal — the same approach used before the move to LiveKit — making the state both correct and decoupled from rendering.No public API changed —
onRemoteStreamstill receives aMediaStream, andonConnectionChangestill reports the same states.