<template>
  <div class="player">
    <div id="player"></div>
  </div>
</template>

<script>
export default {
  name: "Player",
  props: ["videoDatas"],
  data() {
    return {};
  },
  created() {},
  mounted() {
    this.initVideo();
  },
  methods: {
    initVideo() {
      let self = this;
      var player = polyvObject("#player").videoPlayer({
        wrap: "#player",
        width: 520, // 宽度
        height: 480, // 高度
        forceH5: true,
        vid: self.videoDatas.vid,
        playsafe: function (vid, next) {
          // 向后端发送请求获取加密的token
          self.$api
            .polyvVideo(vid)
            .then((res) => {
              self.$api.polyvVideoSign(vid).then((result) => {
                next(result.data);
              });
            })
            .catch((err) => {
              self.$message.error(err);
            });
        },
      });
    },
  },
  computed: {},
};
</script>

<style scoped>
.player {
  width: 520px;
  height: 480px;
}
</style>