解决视频OCX在调用云台指令使用鼠标事件来发起和结束指令动作无效

24 篇文章 2 订阅

如题:OCX在调用云台指令使用mousedown和mouseup来发送指令和结束指令动作不起作用问题(视频播放和检索在requireJS封装都是正常的)。

在项目中使用requireJS封装了视频控件,但是在指令调用这块始终有问题,经过分析和测试发现:

  • mousedown和mouseup间隔时间一般只有100多ms
  • ocx方法直接调用可以请求,说明ocx不能离开上下文
  • mousedown和mouseup事件之间肯定有某种因素干扰了执行(时间、空间皆有可能)

requireJS封装

下面的方法采用requrejs封装调用:

/* $("#yt_direction_top").on('mousedown',function(){
     upstart();
}); */
function upstart(){
    require(['videoStart'],function(video){
        video.upstart();
    });
}
/* $("#yt_direction_top").on('mouseup',function(){
     upstop();
}); */
function upstop(){
    require(['videoStart'],function(video){
        video.upstop();
    });
}
/* $("#yt_direction_bottom").on('mousedown',function(){
     downstart();
}); */
function downstart(){
    require(['videoStart'],function(video){
        video.downstart();
    });
}
/* $("#yt_direction_bottom").on('mouseup',function(){
     downstop();
}); */
function downstop(){
    require(['videoStart'],function(video){
        video.downstop();
    });
}
/* $("#yt_direction_left").on('mousedown',function(){
     leftstart();
}); */
function leftstart(){
    require(['videoStart'],function(video){
        video.leftstart();
    });
}
/* $("#yt_direction_left").on('mouseup',function(){
     leftstop();
});  */
function leftstop(){
    require(['videoStart'],function(video){
        video.leftstop();
    });
}
/* $("#yt_direction_right").on('mousedown',function(){
     rightstart();
}); */
function rightstart(){
    require(['videoStart'],function(video){
        video.rightstart();
    });
}
/* $("#yt_direction_right").on('mouseup',function(){
     rightstop();
}); */
function rightstop(){
    require(['videoStart'],function(video){
        video.rightstop();
    });
}
/* $("#yt_zoom_add").on('mousedown',function(){
     ZOOMstart();
}); */
function ZOOMstart(){
    require(['videoStart'],function(video){
        video.ZOOMstart();
    });
}
/* $("#yt_zoom_add").on('mouseup',function(){
     ZOOMstop();
}); */
function ZOOMstop(){
    require(['videoStart'],function(video){
        video.ZOOMstop();
    });
}
/* $("#yt_zoom_reduce").on('mousedown',function(){
     REDUCEZOOMstart();
}); */
function REDUCEZOOMstart(){
    require(['videoStart'],function(video){
        video.REDUCEZOOMstart();
    });
}
/* $("#yt_zoom_reduce").on('mouseup',function(){
     REDUCEZOOMstop();
});  */
function REDUCEZOOMstop(){
    require(['videoStart'],function(video){
        video.REDUCEZOOMstop();
    });
}
/* $("#yt_focus_add").on('mousedown',function(){
     FOCUSstart();
}); */
function FOCUSstart(){
    require(['videoStart'],function(video){
        video.FOCUSstart();
    });
}
/* $("#yt_focus_add").on('mouseup',function(){
     FOCUSstop();
});  */
function FOCUSstop(){
    require(['videoStart'],function(video){
        video.FOCUSstop();
    });
}
/* $("#yt_focus_reduce").on('mousedown',function(){
     REDUCEFOCUSstart();
}); */
function REDUCEFOCUSstart(){
    require(['videoStart'],function(video){
        video.REDUCEFOCUSstart();
    });
}
/* $("#yt_focus_reduce").on('mouseup',function(){
     REDUCEFOCUSstop();
}); */
function REDUCEFOCUSstop(){
    require(['videoStart'],function(video){
        video.REDUCEFOCUSstop();
    });
}
/* $("#yt_aperture_add").on('mousedown',function(){
     APERTUREstart();
}); */
function APERTUREstart(){
    require(['videoStart'],function(video){
        video.APERTUREstart();
    });
}
/* $("#yt_aperture_add").on('mouseup',function(){
     APERTUREstop();
});  */
function APERTUREstop(){
    require(['videoStart'],function(video){
        video.APERTUREstop();
    });
}
/* $("#yt_aperture_reduce").on('mousedown',function(){
     REDUCEAPERTUREstart();
}); */
function REDUCEAPERTUREstart(){
    require(['videoStart'],function(video){
        video.REDUCEAPERTUREstart();
    });
}
/* $("#yt_aperture_reduce").on('mouseup',function(){
     REDUCEAPERTUREstop();
}); */
function REDUCEAPERTUREstop(){
    require(['videoStart'],function(video){
        video.REDUCEAPERTUREstop();
    });
}

OCX html页面的纯调用方式

下面的跟<object > 控件在同一页面声明调用:

    function getChannelId(){
        return mini.get("CHANNEL_LIST").getValue();
    }
    function upstart() {
        //第二个参数 1 上 1下  2 左 3 右 4        
        var Res = ocx.PTZControl(getChannelId(), 1, 6, 0);
 
    }
    function upstop() {
        var Res = ocx.PTZControl(getChannelId(), 1, 6, 1);
 
    }
    function downstart() {
        var Res = ocx.PTZControl(getChannelId(), 1, 6, 0);
    }
    function downstop() {
        var Res = ocx.PTZControl(getChannelId(), 1, 6, 1);
    }
 
    function leftstart() {
        var Res = ocx.PTZControl(getChannelId(), 2, 6, 0);
    }
    function leftstop() {
        var Res = ocx.PTZControl(getChannelId(), 2, 6, 1);
    }
 
    function rightstart() {
        var Res = ocx.PTZControl(getChannelId(), 3, 6, 0);
    }
    function rightstop() {
        var Res = ocx.PTZControl(getChannelId(), 3, 6, 1);
    }
 
    function ZOOMstart() {
        var Res = ocx.PTZControl(getChannelId(), 8, 6, 0);
    }
    function ZOOMstop() {
        var Res = ocx.PTZControl(getChannelId(), 8, 6, 1);
    }
    function REDUCEZOOMEstart() {
        var Res = ocx.PTZControl(getChannelId(), 11, 6, 0);
    }
    function REDUCEZOOMstop() {
        var Res = ocx.PTZControl(getChannelId(), 11, 6, 1);
    }
 
    function FOCUSstart() {
        var Res = ocx.PTZControl(getChannelId(), 9, 6, 0);
    }
    function FOCUSstop() {
        var Res = ocx.PTZControl(getChannelId(), 9, 6, 1);
    }
    function REDUCEFOCUSEstart() {
        var Res = ocx.PTZControl(getChannelId(), 12, 6, 0);
    }
    function REDUCEFOCUSstop() {
        var Res = ocx.PTZControl(getChannelId(), 12, 6, 1);
    }
 
    function APERTUREstart() {
        var Res = ocx.PTZControl(getChannelId(), 10, 6, 0);
    }
    function APERTUREstop() {
        var Res = ocx.PTZControl(getChannelId(), 10, 6, 1);
    }
    function REDUCEAPERTUREstart() {
        var Res = ocx.PTZControl(getChannelId(), 13, 6, 0);
    }
    function REDUCEAPERTUREstop() {
        var Res = ocx.PTZControl(getChannelId(), 13, 6, 1);
    }
 
    function startTalk() {
        var Res = ocx.TalkControl(getChannelId(), 0);
    }
 
    function stopTalk() {
        var Res = ocx.TalkControl(getChannelId(), 1);
    }

解决方法:抽离这部分mousedown和mouseup方法在页面中直接调用,不需要再封装处理。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值