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

Code before:
            }

            player_guard.get_id()
        };

        *self.player.borrow_mut() = Some(player);

        let event_handler = Arc::new(Mutex::new(HTMLMediaElementEventHandler::new(self)));

        let weak_event_handler = Arc::downgrade(&event_handler);

        *self.event_handler.borrow_mut() = Some(event_handler);

        let task_source = self
            .owner_global()
            .task_manager()
            .media_element_task_source()
            .to_sendable();
        ROUTER.add_typed_route(
            action_receiver,
            Box::new(move |message| {
                let event = message.unwrap();
                let weak_event_handler = weak_event_handler.clone();

                task_source.queue(task!(handle_player_event: move || {
                    trace!("Player event {:?}", event);

                    let Some(event_handler) = weak_event_handler.upgrade() else {
                        return;
                    };

                    event_handler.lock().unwrap().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(())
    }


Review comment (suggestion):
```suggestion
                    trace!("HTMLMediaElement event {event:?}");
```

Code after:
            }

            player_guard.get_id()
        };

        *self.player.borrow_mut() = Some(player);

        let event_handler = Arc::new(Mutex::new(HTMLMediaElementEventHandler::new(self)));
        let weak_event_handler = Arc::downgrade(&event_handler);
        *self.event_handler.borrow_mut() = Some(event_handler);

        let task_source = self
            .owner_global()
            .task_manager()
            .media_element_task_source()
            .to_sendable();
        ROUTER.add_typed_route(
            action_receiver,
            Box::new(move |message| {
                let event = message.unwrap();
                let weak_event_handler = weak_event_handler.clone();

                task_source.queue(task!(handle_player_event: move || {
                    trace!("HTMLMediaElement event: {event:?}");

                    let Some(event_handler) = weak_event_handler.upgrade() else {
                        return;
                    };

                    event_handler.lock().unwrap().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() {