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

Code before:
            }),
        );

        let task_source = self
            .owner_global()
            .task_manager()
            .media_element_task_source()
            .to_sendable();
        let weak_video_renderer = Arc::downgrade(&self.video_renderer);

        self.video_renderer
            .lock()
            .unwrap()
            .setup(player_id, task_source, weak_video_renderer);

        Ok(())
    }

    fn reset_media_player(&self) {
        if self.player.borrow().is_none() {
            return;
        }

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

        *self.player.borrow_mut() = None;
        self.video_renderer.lock().unwrap().reset();
        self.handle_resize(None, None);
    }

    pub(crate) fn set_audio_track(&self, idx: usize, enabled: bool) {
        if let Some(ref player) = *self.player.borrow() {
            if let Err(err) = player.lock().unwrap().set_audio_track(idx as i32, enabled) {
                warn!("Could not set audio track {:#?}", err);
            }
        }
    }

    pub(crate) fn set_video_track(&self, idx: usize, enabled: bool) {
        if let Some(ref player) = *self.player.borrow() {
            if let Err(err) = player.lock().unwrap().set_video_track(idx as i32, enabled) {
                warn!("Could not set video track {:#?}", err);
            }
        }
    }

    fn end_of_playback_in_forwards_direction(&self, can_gc: CanGc) {

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

Code after:
                    this.root().handle_player_event(player_id, &event, CanGc::note());
                }));
            }),
        );

        let task_source = self
            .owner_global()
            .task_manager()
            .media_element_task_source()
            .to_sendable();
        let weak_video_renderer = Arc::downgrade(&self.video_renderer);

        self.video_renderer
            .lock()
            .unwrap()
            .setup(player_id, task_source, weak_video_renderer);

        Ok(())
    }

    fn reset_media_player(&self) {
        if self.player.borrow().is_none() {
            return;
        }

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

        *self.player.borrow_mut() = None;
        self.video_renderer.lock().unwrap().reset();
        self.handle_resize(None, None);
    }

    pub(crate) fn set_audio_track(&self, idx: usize, enabled: bool) {
        if let Some(ref player) = *self.player.borrow() {
            if let Err(err) = player.lock().unwrap().set_audio_track(idx as i32, enabled) {
                warn!("Could not set audio track {:#?}", err);
            }
        }
    }

    pub(crate) fn set_video_track(&self, idx: usize, enabled: bool) {
        if let Some(ref player) = *self.player.borrow() {
            if let Err(err) = player.lock().unwrap().set_video_track(idx as i32, enabled) {
                warn!("Could not set video track {:#?}", err);
            }
        }
    }