Fix mic feedback in solo calls: force .muted on the local preview tile
Every video tile is built client-side via document.createElement, never parsed from HTML - browsers only seed the live .muted property from the muted attribute for parser-inserted elements, so the attribute alone never actually silenced the local preview. Result: your own mic played back through your own speakers even with no other peers in the call. Now sets el.set_muted(true) directly whenever the preview's srcObject is (re)assigned.
This commit is contained in:
+10
@@ -450,9 +450,19 @@ fn CallPanel(room: Memo<String>, me: String) -> impl IntoView {
|
|||||||
|
|
||||||
// Mirror the local MediaStream into the preview <video> element -
|
// Mirror the local MediaStream into the preview <video> element -
|
||||||
// `srcObject` has no HTML attribute form, has to be set via JS.
|
// `srcObject` has no HTML attribute form, has to be set via JS.
|
||||||
|
//
|
||||||
|
// Also force `.muted` via the JS property here, not just the
|
||||||
|
// `muted` attribute on the element below: every video tile in this
|
||||||
|
// app is built client-side via `document.createElement` (never
|
||||||
|
// parsed from HTML), and browsers only seed the live `.muted`
|
||||||
|
// property from the `muted` *attribute* for parser-inserted
|
||||||
|
// elements. Without this, the local preview plays back the user's
|
||||||
|
// own mic through their speakers - audible as feedback in a
|
||||||
|
// solo call.
|
||||||
Effect::new(move |_| {
|
Effect::new(move |_| {
|
||||||
let stream = call_state.get_value().local_stream().get();
|
let stream = call_state.get_value().local_stream().get();
|
||||||
if let Some(el) = local_video_ref.get() {
|
if let Some(el) = local_video_ref.get() {
|
||||||
|
el.set_muted(true);
|
||||||
el.set_src_object(stream.as_ref());
|
el.set_src_object(stream.as_ref());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user