Repository: servo/servo
File: components/script/dom/html/htmlmediaelement.rs (Rust)

Code before:

        current_frame
    }

    fn handle_resize(&self, width: Option<u32>, height: Option<u32>) {
        if let Some(video_elem) = self.downcast::<HTMLVideoElement>() {
            video_elem.resize(width, height);
            self.upcast::<Node>().dirty(NodeDamage::Other);
        }
    }

    /// By default the audio is rendered through the audio sink automatically
    /// selected by the servo-media Player instance. However, in some cases, like
    /// the WebAudio MediaElementAudioSourceNode, we need to set a custom audio
    /// renderer.
    pub(crate) fn set_audio_renderer(
        &self,
        audio_renderer: Arc<Mutex<dyn AudioRenderer>>,
        can_gc: CanGc,
    ) {
        *self.audio_renderer.borrow_mut() = Some(audio_renderer);

        let had_player = {
            if let Some(ref player) = *self.player.borrow() {
                if let Err(e) = player.lock().unwrap().stop() {
                    error!("Could not stop player {:?}", e);
                }
                true
            } else {
                false
            }
        };

        if had_player {
            self.media_element_load_algorithm(can_gc);
        }
    }

    fn send_media_session_event(&self, event: MediaSessionEvent) {
        let global = self.global();
        let media_session = global.as_window().Navigator().MediaSession();

        media_session.register_media_instance(self);

        media_session.send_event(event);
    }

    pub(crate) fn set_duration(&self, duration: f64) {
        self.duration.set(duration);
    }


Review comment (suggestion):
```suggestion
                    error!("Could not stop player {err:?}");
```


Code after:

        current_frame
    }

    fn handle_resize(&self, width: Option<u32>, height: Option<u32>) {
        if let Some(video_elem) = self.downcast::<HTMLVideoElement>() {
            video_elem.resize(width, height);
            self.upcast::<Node>().dirty(NodeDamage::Other);
        }
    }

    /// By default the audio is rendered through the audio sink automatically
    /// selected by the servo-media Player instance. However, in some cases, like
    /// the WebAudio MediaElementAudioSourceNode, we need to set a custom audio
    /// renderer.
    pub(crate) fn set_audio_renderer(
        &self,
        audio_renderer: Arc<Mutex<dyn AudioRenderer>>,
        can_gc: CanGc,
    ) {
        *self.audio_renderer.borrow_mut() = Some(audio_renderer);

        let had_player = {
            if let Some(ref player) = *self.player.borrow() {
                if let Err(err) = player.lock().unwrap().stop() {
                    error!("Could not stop player {:?}", err);
                }
                true
            } else {
                false
            }
        };

        if had_player {
            self.media_element_load_algorithm(can_gc);
        }
    }

    fn send_media_session_event(&self, event: MediaSessionEvent) {
        let global = self.global();
        let media_session = global.as_window().Navigator().MediaSession();

        media_session.register_media_instance(self);

        media_session.send_event(event);
    }

    pub(crate) fn set_duration(&self, duration: f64) {
        self.duration.set(duration);
    }