From 778dc70181205cd1795b4283f462717c8c641735 Mon Sep 17 00:00:00 2001 From: TIN TUN AUNG <62133983+rayguo17@users.noreply.github.com> Date: Tue, 5 Aug 2025 02:57:20 +0800 Subject: [PATCH] script: fix set muted on html video element creation (#38462) Set muted on html video element creation. On `video` element creation, the `set_mute` function will be called before the media player is created, hence the player will still act as not being muted. This PR fix this behaviour by passing `muted` info after player is created as part of `setup_media_player` process. Testing: Locally test on Windows11 Fixes: https://github.com/servo/servo/issues/38448 --------- Signed-off-by: rayguo17 Signed-off-by: Jonathan Schwender <55576758+jschwe@users.noreply.github.com> Co-authored-by: Jonathan Schwender <55576758+jschwe@users.noreply.github.com> --- components/script/dom/htmlmediaelement.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/components/script/dom/htmlmediaelement.rs b/components/script/dom/htmlmediaelement.rs index 446e1b001d8..dc03af02680 100644 --- a/components/script/dom/htmlmediaelement.rs +++ b/components/script/dom/htmlmediaelement.rs @@ -1445,7 +1445,15 @@ impl HTMLMediaElement { audio_renderer, Box::new(window.get_player_context()), ); - let player_id = player.lock().unwrap().get_id(); + let player_id = { + let player_guard = player.lock().unwrap(); + + if let Err(e) = player_guard.set_mute(self.muted.get()) { + log::warn!("Could not set mute state: {:?}", e); + } + + player_guard.get_id() + }; *self.player.borrow_mut() = Some(player);