VideoView.vue 4.74 KB
Newer Older
1 2 3
<!--
 * @Author: your name
 * @Date: 2022-01-26 22:44:02
4 5
 * @LastEditTime: 2024-07-25 17:07:09
 * @LastEditors: 纪泽龙 jizelong@qq.com
6 7 8 9 10 11 12 13
 * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 * @FilePath: /test/hello-world/src/views/components/videoView.vue
-->
<template>
  <div class="box-wrapper">
    <div class="title">{{ deviceData.videoName }}</div>
    <div class="close" @click="close">
      <!-- <img src="@/assets/mapImages/closeBtn.png" alt="" /> -->
14
      <i class="el-icon-close" style="font-size: 20px; color: #49d8ff"></i>
15
    </div>
16 17 18
    <div class="line"></div>


19
    <div class="box videoBox">
20
      <div id="player"></div>
21 22 23 24 25 26 27 28 29 30 31
    </div>
    <span slot="footer" class="dialog-footer">
      <!-- <el-button type="primary" @click="dialogVisible = false"
        >确 定
      </el-button>
      <el-button @click="dialogVisible = false">取 消</el-button> -->
    </span>
  </div>
</template>
<script>
import WasmPlayer from "@easydarwin/easywasmplayer"; //导入WasmPlayer.js
32
import { getPreviewURLs } from "@/api/video/artemis";
33 34
//const IS_MOVE_DEVICE = document.body.clientWidth < 992 // 是否移动设备
const IS_MOVE_DEVICE = true;
35
const MSE_IS_SUPPORT = !!window.MediaSource; // 是否支持mse
36 37 38 39 40 41
export default {
  data() {
    return {
      // dialogVisible: true,
      // AfterClose: true,
      queryParam: {
42
        cameraIndexCode: "",
43 44 45 46
      },
      player: null,
      videoOpenNum: -1,
      queryParam: {
47
        cameraIndexCode: "",
48 49 50 51 52 53
      },
    };
  },
  watch: {},
  mounted() {
    this.$nextTick(() => {
54 55
      if (!window.JSPlugin) {
        this.loadScript("/h5player/h5player.min.js").then(() => {
56
          this.createPlayer();
57 58 59
          this.init();
        });
      } else {
60
        this.createPlayer();
61
        this.init();
62
      }
63
    });
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
    // setTimeout(() => {
    //   this.player = new WasmPlayer(null, "video", this.callBack, {
    //     Height: true,
    //   });
    //   this.player.play(this.deviceData.usr, 1);
    // }, 1);
  },
  methods: {
    show() {
      this.dialogVisible = true;
    },
    // handleClose() {
    //   console.log("关闭");
    //   this.player.destroy(this.deviceData.usr);
    //   // document.body.removeChild(this.$refs.videoBox.$el);
    // },
    init() {
      // 设置播放容器的宽高并监听窗口大小变化
82 83 84
      window.addEventListener("resize", () => {
        this.player.JS_Resize();
      });
85 86 87
    },
    createPlayer() {
      this.player = new window.JSPlugin({
88
        szId: "player",
89 90 91 92 93
        szBasePath: "/h5player",
        iMaxSplit: 4,
        iCurrentSplit: IS_MOVE_DEVICE ? 1 : 2,
        openDebug: true,
        oStyle: {
94 95 96
          borderSelect: IS_MOVE_DEVICE ? "#000" : "#FFCC00",
        },
      });
97 98
      this.open();
    },
99
    open() {
100
      this.queryParam.cameraIndexCode = this.deviceData.resourceId;
101 102 103 104 105 106 107 108 109 110
      getPreviewURLs(this.queryParam).then((response) => {
        if (response.data.code == "0") {
          this.videoOpenNum++;
          let url = response.data.data.url;
          //let index = this.player.currentWindowIndex;
          this.player
            .JS_Play(url, { playURL: url, mode: "0" }, this.videoOpenNum % 4)
            .then(
              () => {
                console.log("realplay success");
111
              },
112 113 114 115 116
              (e) => {
                console.error(e);
              }
            );
        }
117 118
      });
    },
119 120
    loadScript(src) {
      return new Promise((reslove) => {
121
        let scpritE1 = document.createElement("script");
122 123 124 125 126 127 128
        scpritE1.type = "text/javascript";
        scpritE1.src = src;
        scpritE1.onload = () => {
          reslove();
        };
        document.body.appendChild(scpritE1);
      });
129 130 131 132 133 134 135 136 137 138 139
    },
    callBack() {},
    close() {
      //this.handleClose();
      this.mapClass.infowindowClose();
    },
  },
};
</script>

<style lang="scss">
140 141 142
.sub-wnd {
  text-align: center !important;
}
143
.box-wrapper {
144 145 146 147 148
  // box-shadow: 0px 0px 10px #54e0ef inset;
  // background-color: #071738;
  background: rgba(2, 26, 51, 0.9);
  border: 1px solid #127bd1;
  box-shadow: inset 0px 0px 10px 0px #164db2;
149 150 151 152 153 154 155 156 157
  padding: 10px;
  position: relative;
  // width: 670px;
  border-radius: 7px;
  .title {
    padding-left: 10px;
    font-size: 14px;
    line-height: 14px;
    color: #ffffff;
158 159 160 161 162 163 164 165 166 167 168 169 170
  }
    .line {
    width: 50%;
    height: 1px;
    margin-top: 10px;
    background: linear-gradient(
      90deg,
      rgba(29, 33, 41, 0) 0%,
      #568ef6 38%,
      #19d1ed 49%,
      rgba(29, 33, 41, 0) 109%
    );
    // border: 2px solid;
171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188
  }
  .close {
    position: absolute;
    right: 10px;
    top: 5px;
    cursor: pointer;
  }
  .box {
    padding: 5px 12px 10px 10px;
    width: 350px;
    height: 200px;
    margin-top: 5px;
    #player {
      height: 190px;
    }
  }
}
</style>