<template>
  <div class="pb_content2" style="background: #fff; display: inline">
    <div class="pb_head logo">
      <div class="logoImg"><img src="../../ai/img/logo.png" alt="" /></div>
      <div class="sName">深圳市民治中学</div>
    </div>
    <!-- <div class="pb_content_body">
      <video-player
        class="video-player vjs-custom-skin"
        ref="videoPlayer"
        :playsinline="true"
        :options="playerOptions"
        style="width: 100%; height: 100%"
      ></video-player>
    </div> -->
    <van-overlay
      :show="show"
      @click="overlayShow"
      style="display: flex; align-items: center;background-color: #000 !important;"
    >
      <div class="wrapper" @click.stop>
        <video-player
          class="video-player vjs-custom-skin"
          ref="videoPlayer"
          :playsinline="playsinline"
          :options="playerOption"
          style="width: 100%; height: 100%"
        ></video-player>
      </div>
    </van-overlay>
    <!-- <video src="../../assets/vedio/sSpace.mp4"></video> -->
  </div>
</template>

<script>
import "../../common/aws-sdk-2.235.1.min";

export default {
  data() {
    return {
        show: false,
      playerOptions: {
        playbackRates: [0.7, 1.0, 1.5, 2.0], //播放速度
        autoplay: false, //如果true,浏览器准备好时开始回放。
        muted: false, // 默认情况下将会消除任何音频。
        loop: false, // 导致视频一结束就重新开始。
        preload: "auto", // 建议浏览器在<video>加载元素后是否应该开始下载视频数据。auto浏览器选择最佳行为,立即开始加载视频（如果浏览器支持）
        language: "zh-CN",
        aspectRatio: "16:9", // 将播放器置于流畅模式，并在计算播放器的动态大小时使用该值。值应该代表一个比例 - 用冒号分隔的两个数字（例如"16:9"或"4:3"）
        fluid: true, // 当true时，Video.js player将拥有流体大小。换句话说，它将按比例缩放以适应其容器。
        sources: [
          {
            type: "video/mp4", //这里的种类支持很多种：基本视频格式、直播、流媒体等，具体可以参看git网址项目   || "video/ogg"|| "video/webm"
            src: require("../../assets/vedio/ar.mp4"), //url地址require("../../assets/media/aaa.mp4")
          },
        ],
        // poster: require("../../assets/tu31.png"), //你的封面地址
        // poster: dataRes.imgUrl, //你的封面地址
        notSupportedMessage: "此视频暂无法播放，请稍后再试", //允许覆盖Video.js无法播放媒体源时显示的默认信息。
        controlBar: {
          timeDivider: true, //当前时间和持续时间的分隔符
          durationDisplay: true, //显示持续时间
          remainingTimeDisplay: false, //是否显示剩余时间功能
          fullscreenToggle: true, //全屏按钮
        },
      },
      playerOption: {
        playbackRates: [0.7, 1.0, 1.5, 2.0], //播放速度
        autoplay: false, //如果true,浏览器准备好时开始回放。
        muted: false, // 默认情况下将会消除任何音频。
        loop: false, // 导致视频一结束就重新开始。
        preload: "auto", // 建议浏览器在<video>加载元素后是否应该开始下载视频数据。auto浏览器选择最佳行为,立即开始加载视频（如果浏览器支持）
        language: "zh-CN",
        aspectRatio: "16:9", // 将播放器置于流畅模式，并在计算播放器的动态大小时使用该值。值应该代表一个比例 - 用冒号分隔的两个数字（例如"16:9"或"4:3"）
        fluid: true, // 当true时，Video.js player将拥有流体大小。换句话说，它将按比例缩放以适应其容器。
        sources: [
          {
            type: "video/mp4", //这里的种类支持很多种：基本视频格式、直播、流媒体等，具体可以参看git网址项目   || "video/ogg"|| "video/webm"
            src: require("../../assets/vedio/sSpace.mp4"), //url地址require("../../assets/media/aaa.mp4")
          },
        ],
        // poster: require("../../assets/tu31.png"), //你的封面地址
        // poster: dataRes.imgUrl, //你的封面地址
        notSupportedMessage: "此视频暂无法播放，请稍后再试", //允许覆盖Video.js无法播放媒体源时显示的默认信息。
        controlBar: {
          timeDivider: true, //当前时间和持续时间的分隔符
          durationDisplay: true, //显示持续时间
          remainingTimeDisplay: false, //是否显示剩余时间功能
          fullscreenToggle: true, //全屏按钮
        },
      },
      playerO: {},
      playerOs: {},
      vedio:'',
    };
  },
  computed: {
    playsinline() {
      let ua = navigator.userAgent.toLocaleLowerCase();
      // x5内核
      if (ua.match(/tencenttraveler/) != null || ua.match(/qqbrowse/) != null) {
        return false;
      } else {
        // ios端
        return true;
      }
    },
  },
  methods: {
    overlayShow() {
      this.show = false;
      this.$refs.videoPlayer.player.pause();
    },
    time() {
      if (!this.now) {
        this.now = new Date().getTime();
        return true;
      } else {
        let time = new Date().getTime();
        if (time - this.now > 3000) {
          this.now = time;
          return true;
        } else {
          return false;
        }
      }
    },
    goBack() {
      document.getElementsByClassName("pb_content2")[0].style.display = "block";
      this.$router.isBack = true;
      if (window.history.length <= 1) {
        this.$router.push({ path: "/" });
        return false;
      } else {
        this.$router.go(-1);
      }
    },

    mediaPreview() {
      this.show = true;
      this.playerOptions.sources[0].src = this.vedio;
      this.playerOs = this.playerOption;
    },
    onPlayerCanplay() {},
    switchVideo(media, index) {
      this.playerO = {};
      this.playerOptions.poster = "";
      this.playerOptions.sources[0].src = this.vedio;
      this.playerO = this.playerOptions;
    },
    onPlayerPlay(e) {
        debugger
        e.play();
    },
  },
  created() {
      this.mediaPreview();
    // this.$vConsole
    // this.getCourse();
  },
};
</script>

<style scoped>
body,
html {
  background: #eee;
}
.myp_parent_textarea {
  width: 95%;
  margin: 0 auto;
  border: 1px solid rgb(207, 207, 207);
  margin-left: 10px !important;
  border-radius: 5px;
  overflow: auto;
}
.van-cell {
  background: #fdfdfd;
}
.pb_content_body {
  font-size: 0.9rem;
  display: flex;
  flex-direction: column;
  /* justify-content: space-around; */
  width: 95%;
  background: #fff;
  padding: 0px 5px;
  margin: 5px 0 0 5px;
  height: auto;
}

.pb_content_body div {
  margin: 0.5rem 0 0;
}
.pb_content_body div > img {
  width: 1.5rem;
}
.pb_content_body .van-cell {
  margin: 0;
}
.sw_select {
  font-size: 16px;
  color: #444;
}
.sw_select >>> .el-input__inner {
  /* border: none !important; */
  border: 1px solid #eee !important;
}
.sw_select >>> .el-select {
  width: 12rem;
}
.class_learn button {
  color: white;
  background: #de8410;
  border: none;
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-size: 1rem;
  text-align: center;
  border-radius: 5px;
  cursor: pointer;
  transition: opacity 0.2s;
  height: 2rem;
  width: 100%;
  font-size: 0.8rem;
  line-height: 1.5rem;
  margin-bottom: 0.5rem;
}
.wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 11rem;
  width: 100%;
}
.dia_title {
  display: flex;
  width: 100%;
  align-items: center;
  height: 2rem;
  justify-content: center;
}
.close {
  position: absolute;
  right: 5%;
  top: 0.5rem;
}
.close img {
  width: 1rem;
}

.dia_content {
  display: flex;
  flex-direction: column;
  align-items: center;
}
.dia_content .score {
  font-size: 1.2rem;
  font-family: "Microsoft JhengHei";
  font-weight: 600;
  color: rgb(39, 39, 39);
  margin: 0.8rem 0;
  display: flex;
  align-items: center;
}
.dia_content .btn {
  font-family: "Microsoft JhengHei";
  font-size: 0.85rem;
  width: 8rem;
  height: 1.8rem;
  line-height: 1.8rem;
  text-align: center;
  background: #58a5e6;
  color: #fff;
  border-radius: 3rem;
}

.scoreInner {
  position: absolute;
  bottom: 0.4rem;
  width: fit-content;
  left: 50%;
  font-size: 1rem;
  color: #fff;
  transform: translateX(-50%);
}
.mask {
  background-color: rgba(0, 0, 0, 0);
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 20000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.progressBox {
  width: 95%;
  height: 6rem;
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 0 6px 1px #bfbfbf;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
}
.progressBox .lbox {
  height: 3rem;
  font-size: 0.8rem;
  display: flex;
  align-items: center;
}

.progressBox .lbox img {
  width: 1.3rem;
  margin-right: 1.2rem;
}

.progressBox >>> .el-progress-bar__outer {
  background-color: #d1dfff !important;
  height: 1.2rem !important;
}

.workDisplay >>> .van-field__value,
.workDDisplay >>> .van-field__value {
  display: flex;
  justify-content: space-between;
}
.workDDisplay >>> .van-field__body {
  width: 100%;
}
.workDDisplay >>> .van-field__control {
  max-height: 200px;
  overflow: auto;
}
.uploadPhoto {
  width: 45%;
  padding-left: 8px;
}
.uploadPhoto >>> .van-uploader__wrapper {
  background: #f2f2f2;
  height: 125px;
}
.uploadPhoto >>> .van-uploader__input-wrapper {
  width: 100%;
  display: flex;
  flex-direction: column;
  flex-wrap: nowrap;
  justify-content: center;
  align-items: center;
}
.uploadPhoto >>> .van-uploader__preview {
  margin: 0;
  width: 100%;
  height: 100%;
}
.uploadPhoto >>> .van-uploader__preview-image {
  width: 100% !important;
  height: 100% !important;
}
.uploadPhotos {
  width: 100%;
}
.uploadPhotos >>> .van-uploader__wrapper {
  width: 100%;
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
}
.uploadPhotos >>> .van-uploader__input-wrapper {
  background: #f2f2f2;
  height: 100px;
  width: 45%;
  display: flex;
  flex-direction: column;
  flex-wrap: nowrap;
  justify-content: center;
  align-items: center;
  margin: 0 0 1rem 8px;
}
.uploadFiles {
  width: 100%;
  padding-left: 8px;
}
.uploadFiles >>> .van-uploader__input-wrapper {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  width: 60%;
  align-items: center;
  justify-content: center;
  background: #f2f2f2;
  height: 65px;
  border-radius: 10px;
}
.uploadFiles >>> .van-uploader__file {
  margin: 0;
}
.uploadFiles >>> .van-uploader__preview-image {
  margin: 0;
}
.uploadFiles >>> .van-uploader__preview-delete {
  margin: 0;
}
.sName {
  color: #fff;
  font-size: 16px;
  margin-left: 10px;
}

.logoImg > img {
  width: 100%;
  height: 100%;
}

.logoImg {
  width: 1.5rem;
  height: 1.5rem;
  margin: 0 0 auto 1rem;
}
.logo {
  display: flex;
  justify-content: start;
  background: #ffbf43;
  height: 2rem;
  align-items: center;
}
</style>
