Clicking the X button should remove the player

I am trying to have this work in the code to remove duplication.

Working Code Example:

In the code below, I was trying to remove at least one player, then I could figure out how to do the others.

I am trying to have this part work in the code:

Code I am working on:

I am thinking it should be able to work in this code.

This is the part from the working code that is responsible for removing the player.

const manageUI = (function makeManageUI() {
  function addExitHandlers(callback) {
    const resetVideo = document.querySelectorAll(".exitA");
    resetVideo.forEach(function resetVideoHandler(video) {
      video.addEventListener("click", callback);

  return {
function removePlayer(wrapper) {
    delete wrapper.player;

  function removePlayerHandler(evt) {
    const el =;
    const container = el.closest(".containerA"); // Changed ".container" to ".containerA"
    const wrapper = container.querySelector(".wrap");
    if (wrapper.player) {
      return removePlayer(wrapper);
const loadPlayer = (function uiLoadPlayer() {
  function addPlayer(playerSelector, playerOptions) {
    const parent = document.querySelector(playerSelector).parentElement;
    const callback = managePlayer.adder(parent, playerOptions);

  return {
    add: addPlayer