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 <tin.tun.aung1@huawei.com>
Signed-off-by: Jonathan Schwender <55576758+jschwe@users.noreply.github.com>
Co-authored-by: Jonathan Schwender <55576758+jschwe@users.noreply.github.com>
This commit is contained in:
TIN TUN AUNG 2025-08-05 02:57:20 +08:00 committed by GitHub
parent 391bf5d605
commit 778dc70181
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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);