import $ from "jquery";

class VideoStage {
  constructor(videoStage) {
    $(videoStage).addClass("initiated");
    $(videoStage.find(".video--play-pause")).on("click", (e) => {
      e.preventDefault();
      let t = $(e.currentTarget);
      this.playPause(videoStage.find("video")[0], t);
    });
    $(videoStage.find(".video--mute-unmute")).on("click", (e) => {
      e.preventDefault();
      let t = $(e.currentTarget);
      this.muteUnmute(videoStage.find("video")[0], t);
    });
  }

  playPause (video, target) {
    if (video.paused) {
      video.play();
      target.removeClass("paused");
    } else {
      video.pause();
      target.addClass("paused");
    }
  }

  muteUnmute(video, target) {
    if (video.muted) {
      video.muted = false;
      target.addClass("unmuted");
    }
    else {
      video.muted = true;
      target.removeClass("unmuted");
    }
  }
}
export default VideoStage;
