Vue项目中使用海康安全生产平台播放监控视频

    最近一直在做有关海康监控视频的项目,闲下来写下这篇文章,加深一下印象,同时也和大家交流一下经验,以便更好提升自己。废话不多说,开始正题。。。。

    首先把海康插件引进到项目中来

然后在index.html中引进

最后把完整代码贴出来,不一一介绍了(懒~~~~)

<template>
    <div class="video-player">
        <div id="divPlugin" class="divPlugin" ref="divPlugin" v-if="plugin">
        </div>
        <!-- <div class="down" v-else>
            <a href="http://jbfsys.oss-cn-beijing.aliyuncs.com/download/VideoWebPlugin-1564128302790.exe">下载</a>
        </div> -->
    </div>
</template>
<script>
export default {
name: 'videoPlayer',
props:['cameraIndexCode','layout'],
    data(){
        return {
            plugin:true ,
            oWebControl:null,   //插件对象
            initCount:0,
            pubKey:'',         //公钥加密
            playMode:'',
            video_init_data:{
            appkey:'你的appkey',
            appSecret:'你的appSecret',
            ip:'IP地址',
            port:'端口号',
            snapDir:'D:\\SnapDir',
            videoDir:'D:\\VideoDir',
            layout:'',
            // encryptedFields:'secret',
            // enableHttps:'1',
        },
        video_play_data:{
            cameraIndexCode:"",
            streamMode:0,
            transMode:1,
            gpuMode:0,
            wndId:-1,
        },
        //videoWidth videoHeight screenWidth screenHeight 
        //这四个参数为了使插件大小和屏幕宽度一致变化
        videoWidth:700,
        videoHeight:300,
        screenWidth: document.documentElement.clientWidth,//屏幕宽度
        screenHeight: document.documentElement.clientHeight,//屏幕高度
        //设置窗口遮挡 根据浏览器大小变化视频插件的大小
        iLastCoverLeft : 0,
        iLastCoverTop : 0,
        iLastCoverRight : 0,
        iLastCoverBottom : 0,
        };
  },
  created(){},
  mounted(){
        //插件初始化
        this.initPlugin();
        this.$nextTick(()=>{
            this.videoWidth = this.$refs.divPlugin.offsetWidth;
            this.videoHeight = this.$refs.divPlugin.offsetHeight;
        })
        // 监听窗口变化
        let _this = this;
        window.onresize = function(){
  • 12
    点赞
  • 20
    收藏
    觉得还不错? 一键收藏
  • 9
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 9
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值