export const handlePlayPause = (blockElement) => {
  const video = blockElement.querySelector("video");
  const btnPP = blockElement.querySelector(".cbb-video-play-pause");
  if (video && btnPP) {
    const toggleClass = (btnPP, paused) => {
      btnPP.classList.toggle("is-paused", paused);
      btnPP.classList.toggle("is-playing", !paused);
    };

    video.addEventListener("play", () => {
      toggleClass(btnPP, false);
    });

    video.addEventListener("pause", () => {
      toggleClass(btnPP, true);
    });

    btnPP.addEventListener("click", () => {
      if (video?.paused) {
        video.play();
      } else {
        video.pause();
      }
    });
  }
};
