海康视频WEB插件

引入相关依赖

index.html

html 复制代码
<script src="/video/web-control_1.2.5.min.js"></script>
<script src="/video/jquery-1.12.4.min.js" type="text/javascript"></script>
<script src="/video/jsencrypt.min.js" type="text/javascript"></script>

全局配置参数

javascript 复制代码
<script>
    window._CONFIG = {
        appKey:"XXXXXXXXX",
        secret:"XXXXXXXXXXXX",
        hikIp:'xxx.xxx.xxx.xx',
        apiPort:'XXXX',
};
</script>

页面

html 复制代码
<div class="backWidth play_box" ref="backWidth">
	<a-row type="flex" justify="space-around" align="middle">
		<a-spin v-show="spinFlag" tip="加载中请稍后......" />
	</a-row>
	<a-row class="play_box">
		<div id="playWnd" class="playWnd" ref="barparent"></div>
	</a-row>
</div>
javascript 复制代码
<script>
import {playMixin} from '@/utils/playMixinNew.js';
export default {
    mixins: [playMixin],
    data() {
        return {
            windowHeight: 0,
            curPlayMode:0,
        },
    mounted() {
        //计算窗口高度
        this.getWindowHeight();
        // 在窗口大小改变时重新获取窗口高度
        window.addEventListener('resize', this.getWindowHeight);
    },
    methods: {
        getWindowHeight() {
            this.windowHeight = window.innerHeight - 355;
        },
        // 切换实时视频和历史视频
        changePlay(value,playMode){
            if(playMode !== this.curPlayMode){
              this.closeWindow();
              setTimeout(()=>{
                this.openPlayer(value,playMode)
              },200)
            }
        },
        // 打开海康视频插件
        openPlayer(value,playMode=0){
            this.curPlayMode = playMode;
            this.$nextTick(()=>{
                this.initparam.layout = '1x1'
                this.spinFlag = true;
                this.initPlugin({playMode:this.curPlayMode});
                setTimeout(()=>{
                    if(this.curPlayMode){
                        console.log('进入视频回放')
                        this.startPlayBack(value)
                    }else{
                        console.log('进入视频预览')
                        this.startpreview(value);
                    }
                },2000)
            })
        },
    }
相关推荐
Hilaku几秒前
深入background-image:你可能不知道的几个性能优化与高级技巧
前端·css
南岸月明3 分钟前
副业自媒体1年终于明白:为什么会表达的人,能量越来越强,更能赚到钱?
前端
Danny_FD17 分钟前
Vue + Element UI 实现模糊搜索自动补全
前端·javascript
gnip21 分钟前
闭包实现一个简单Vue3的状态管理
前端·javascript
斐济岛上有一只斐济27 分钟前
后端程序员的CSS复习
前端
Enddme30 分钟前
《面试必问!JavaScript 中this 全方位避坑指南 (含高频题解析)》
前端·javascript·面试
有梦想的程序员31 分钟前
微信小程序使用 Tailwind CSS version 3
前端
溟洵1 小时前
Qt 窗口 工具栏QToolBar、状态栏StatusBar
开发语言·前端·数据库·c++·后端·qt
用户2519162427111 小时前
Canvas之图像合成
前端·javascript·canvas
每天开心1 小时前
噜噜旅游App(4)——构建旅游智能客服模块,实现AI聊天
前端·微信小程序·前端框架