|
@@ -12,66 +12,282 @@ export default {
|
|
|
data(){
|
|
|
return{
|
|
|
g_iWndIndex:0,
|
|
|
+ logininfo:[],
|
|
|
}
|
|
|
},
|
|
|
mounted() {
|
|
|
var that=this;
|
|
|
- setTimeout(()=>{
|
|
|
- this.initVideoPlay('192.168.101.64', '80', 'admin', 'zxy123456','divPlugin')
|
|
|
- },2000)
|
|
|
+ // setTimeout(()=>{
|
|
|
+ // let sgse = {
|
|
|
+ // 'ip': response.data.equipmentIp,
|
|
|
+ // 'account': response.data.account,
|
|
|
+ // 'password': response.data.password,
|
|
|
+ // 'port': response.data.port
|
|
|
+ // }
|
|
|
+ // this.initPlugin(sgse)
|
|
|
+ // // this.initVideoPlay('192.168.101.64', '80', 'admin', 'zxy123456','divPlugin')
|
|
|
+ // },2000)
|
|
|
+ var url="rtsp://admin:zxy123456@192.168.101.64:554/h264/ch1/main/av_stream"
|
|
|
+ this.initUrl(url)
|
|
|
|
|
|
},
|
|
|
beforeDestroy() {
|
|
|
|
|
|
},
|
|
|
methods:{
|
|
|
- initVideoPlay(ip, port, username, password,id){
|
|
|
- console.log(2)
|
|
|
- // 初始化插件参数及插入插件
|
|
|
- WebVideoCtrl.I_InitPlugin(500, 300, {
|
|
|
- bWndFull: true, //是否支持单窗口双击全屏,默认支持 true:支持 false:不支持
|
|
|
- iPackageType: 2,
|
|
|
- //szColorProperty:"plugin-background:0000ff; sub-background:0000ff; sub-border:00ffff; sub-border-select:0000ff", //2:PS 11:MP4
|
|
|
- iWndowType: 1,
|
|
|
- cbSelWnd: function (xmlDoc) {
|
|
|
- // g_iWndIndex = parseInt($(xmlDoc).find("SelectWnd").eq(0).text(), 10);
|
|
|
- // var szInfo = "当前选择的窗口编号:" + g_iWndIndex;
|
|
|
- // showCBInfo(szInfo);
|
|
|
- },
|
|
|
- cbDoubleClickWnd: function (iWndIndex, bFullScreen) {
|
|
|
- // var szInfo = "当前放大的窗口编号:" + iWndIndex;
|
|
|
- // if (!bFullScreen) {
|
|
|
- // szInfo = "当前还原的窗口编号:" + iWndIndex;
|
|
|
- // }
|
|
|
- // showCBInfo(szInfo);
|
|
|
- },
|
|
|
- cbEvent: function (iEventType, iParam1, iParam2) {
|
|
|
- // if (2 == iEventType) {// 回放正常结束
|
|
|
- // showCBInfo("窗口" + iParam1 + "回放结束!");
|
|
|
- // } else if (-1 == iEventType) {
|
|
|
- // showCBInfo("设备" + iParam1 + "网络错误!");
|
|
|
- // } else if (3001 == iEventType) {
|
|
|
- // clickStopRecord(g_szRecordType, iParam1);
|
|
|
- // }
|
|
|
- },
|
|
|
- cbRemoteConfig: function () {
|
|
|
- // showCBInfo("关闭远程配置库!");
|
|
|
- },
|
|
|
- cbInitPluginComplete: function () {
|
|
|
- WebVideoCtrl.I_InsertOBJECTPlugin("divPlugin").then(
|
|
|
- ()=>{
|
|
|
-
|
|
|
- }
|
|
|
- );
|
|
|
- console.log(222)
|
|
|
- // 检查插件是否最新
|
|
|
- // if (-1 == WebVideoCtrl.I_CheckPluginVersion()) {
|
|
|
- // alert("检测到新的插件版本,双击开发包目录里的WebComponentsKit.exe升级!");
|
|
|
- // return;
|
|
|
- // }
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
+ initUrl(val){
|
|
|
+ let arra=val.split('/')
|
|
|
+ let arrb=arra[2].split(':')
|
|
|
+ let arrc=arrb[1].split('@')
|
|
|
+ // console.log(arrb[0],arrb[2],arrc)
|
|
|
+ let obj={
|
|
|
+ 'ip':arrc[1],
|
|
|
+ 'account':arrb[0],
|
|
|
+ 'password':arrc[0],
|
|
|
+ 'port':arrb[2]
|
|
|
+ }
|
|
|
+ // if(val.videoAddress == undefined){
|
|
|
+ // let snghs = val.equipmentAddress.split('@')
|
|
|
+ // let snghst = snghs[1].split(':')
|
|
|
+ // let snsgduan = snghst[1].split('/')
|
|
|
+ // console.log(snghs,snghst,snsgduan)
|
|
|
+ // let sgse={'ip':snghst[0],'duank':snsgduan[0],
|
|
|
+ // 'account':val.account,
|
|
|
+ // 'password':val.password,
|
|
|
+ // 'port':val.port
|
|
|
+ // }
|
|
|
+ // this.getVideo(sgse)
|
|
|
+ // WebVideoCtrl.I_ShowPlugin()
|
|
|
+ // }else{
|
|
|
+ // let snghs = val.videoAddress.split('@')
|
|
|
+ // let snghst = snghs[1].split(':')
|
|
|
+ // let snsgduan = snghst[1].split('/')
|
|
|
+ // console.log(snghs,snghst,snsgduan)
|
|
|
+ // let sgse={'ip':snghst[0],'duank':snsgduan[0],
|
|
|
+ // 'account':val.account,
|
|
|
+ // 'password':val.password,
|
|
|
+ // 'port':val.port
|
|
|
+ // }
|
|
|
+ // this.getVideo(sgse)
|
|
|
+ // WebVideoCtrl.I_ShowPlugin()
|
|
|
+ // }
|
|
|
+ },
|
|
|
+ // 播放摄像头
|
|
|
+ getVideo(row) {
|
|
|
+ var that=this;
|
|
|
+ this.isfse = true
|
|
|
+ console.log(row)
|
|
|
+ this.initVideoPlay(row.ip, row.port, row.account, row.password)
|
|
|
+ },
|
|
|
+ //初始化插件参数及插入插件
|
|
|
+ initPlugin(data){
|
|
|
+ var that=this;
|
|
|
+ that.isfse=true
|
|
|
+ WebVideoCtrl.I_InitPlugin({
|
|
|
+ bWndFull: true, //是否支持单窗口双击全屏,默认支持 true:支持 false:不支持
|
|
|
+ iWndowType: 2,
|
|
|
+ // aIframe: ["test"],
|
|
|
+ cbSelWnd: function (xmlDoc) {
|
|
|
+ that.g_iWndIndex= parseInt($(xmlDoc).find("SelectWnd").eq(0).text(), 10);
|
|
|
+ var szInfo = "当前选择的窗口编号:" + that.g_iWndIndex;
|
|
|
+ console.log(szInfo,that.g_iWndIndex)
|
|
|
+ },
|
|
|
+ cbDoubleClickWnd: function (iWndIndex, bFullScreen) {
|
|
|
+ var szInfo = "当前放大的窗口编号:" + iWndIndex;
|
|
|
+ if (!bFullScreen) {
|
|
|
+ szInfo = "当前还原的窗口编号:" + iWndIndex;
|
|
|
+ }
|
|
|
+ },
|
|
|
+ cbEvent: function (iEventType, iParam1, iParam2) {
|
|
|
+ if (2 == iEventType) {// 回放正常结束
|
|
|
+ } else if (-1 == iEventType) {
|
|
|
+ } else if (3001 == iEventType) {
|
|
|
+ // clickStopRecord(g_szRecordType, iParam1);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ cbInitPluginComplete: function () {
|
|
|
+ WebVideoCtrl.I_InsertOBJECTPlugin("divPlugin").then(() => {
|
|
|
+ that.getVideo(data)
|
|
|
+ // 检查插件是否最新
|
|
|
+ WebVideoCtrl.I_CheckPluginVersion().then((bFlag) => {
|
|
|
+ if (bFlag) {
|
|
|
+ alert("检测到新的插件版本,双击开发包目录里的HCWebSDKPluginsUserSetup.exe升级!");
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }, () => {
|
|
|
+ alert("插件初始化失败,请确认是否已安装插件;如果未安装,请双击开发包目录里的HCWebSDKPluginsUserSetup.exe安装!");
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+ //
|
|
|
+ initVideoPlay(szIP, szPort, szUsername, szPassword){
|
|
|
+ // 判断ip是否有登录,
|
|
|
+ var that=this;
|
|
|
+ var szProtoType=1;//protocol 1:http, 2:https
|
|
|
+ let a = szIP
|
|
|
+ let b = szPort
|
|
|
+ var newArr=JSON.parse(JSON.stringify(that.logininfo))
|
|
|
+ var item=newArr.find(ite=>ite.szIP==szIP&&ite.szPort==szPort)
|
|
|
+ if(item&&newArr.length){
|
|
|
+ that.clickStartRealPlay(a, b,1, that.g_iWndIndex, 1);
|
|
|
+ }else{
|
|
|
+ // 登录
|
|
|
+ WebVideoCtrl.I_Login(szIP, szProtoType, szPort, szUsername, szPassword, {
|
|
|
+ timeout: 3000,
|
|
|
+ success: function (xmlDoc) {
|
|
|
+ console.log(" 登录成功!");
|
|
|
+ var szDeviceIdentify = szIP + "_" + szPort;
|
|
|
+ var obj={
|
|
|
+ szIP:szIP,szPort:szPort,szUsername:szUsername,szPassword:szPassword
|
|
|
+ }
|
|
|
+ that.logininfo.push(obj)
|
|
|
+ setTimeout(function () {
|
|
|
+ // 获取通道
|
|
|
+ // that.getChannelInfo(szIP);
|
|
|
+ }, 1000);
|
|
|
+ // 获取端口
|
|
|
+ // that.getDevicePort(szIP);
|
|
|
+ // 预览
|
|
|
+ setTimeout(function() {
|
|
|
+ //调用预览摄像头这里可以循环创建
|
|
|
+ //szIP, szPort, iStreamType:预览类型, iWndIndex, iChannelID:通道列表
|
|
|
+ that.clickStartRealPlay(a, b,1, that.g_iWndIndex, 1);
|
|
|
+ }, 1000);
|
|
|
+ },
|
|
|
+ error: function (oError) {
|
|
|
+ console.log(" 登录失败!", oError);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // 获取通道
|
|
|
+ getChannelInfo(ip) {
|
|
|
+ var szDeviceIdentify = ip,
|
|
|
+ oSel = null; //通道列表
|
|
|
+ if (null == szDeviceIdentify) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ // 模拟通道
|
|
|
+ WebVideoCtrl.I_GetAnalogChannelInfo(szDeviceIdentify, {
|
|
|
+ success: function (xmlDoc) {
|
|
|
+ var oChannels = $(xmlDoc).find("VideoInputChannel");
|
|
|
+
|
|
|
+ $.each(oChannels, function (i) {
|
|
|
+ var id = $(this).find("id").eq(0).text(),
|
|
|
+ name = $(this).find("name").eq(0).text();
|
|
|
+ if ("" == name) {
|
|
|
+ name = "Camera " + (i < 9 ? "0" + (i + 1) : (i + 1));
|
|
|
+ }
|
|
|
+ oSel.append("<option value='" + id + "' bZero='false'>" + name + "</option>");
|
|
|
+ });
|
|
|
+ console.log(szDeviceIdentify + " 获取模拟通道成功!");
|
|
|
+ },
|
|
|
+ error: function (oError) {
|
|
|
+ console.log(szDeviceIdentify + " 获取模拟通道失败!", oError.errorCode, oError.errorMsg);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ // 数字通道
|
|
|
+ WebVideoCtrl.I_GetDigitalChannelInfo(szDeviceIdentify, {
|
|
|
+ success: function (xmlDoc) {
|
|
|
+ var oChannels = $(xmlDoc).find("InputProxyChannelStatus");
|
|
|
+
|
|
|
+ $.each(oChannels, function (i) {
|
|
|
+ var id = $(this).find("id").eq(0).text(),
|
|
|
+ name = $(this).find("name").eq(0).text(),
|
|
|
+ online = $(this).find("online").eq(0).text();
|
|
|
+ if ("false" == online) {// 过滤禁用的数字通道
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ if ("" == name) {
|
|
|
+ name = "IPCamera " + (i < 9 ? "0" + (i + 1) : (i + 1));
|
|
|
+ }
|
|
|
+ });
|
|
|
+ console.log(szDeviceIdentify + " 获取数字通道成功!");
|
|
|
+ },
|
|
|
+ error: function (oError) {
|
|
|
+ console.log(szDeviceIdentify + " 获取数字通道失败!", oError.errorCode, oError.errorMsg);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ // 零通道
|
|
|
+ WebVideoCtrl.I_GetZeroChannelInfo(szDeviceIdentify, {
|
|
|
+ success: function (xmlDoc) {
|
|
|
+ var oChannels = $(xmlDoc).find("ZeroVideoChannel");
|
|
|
+
|
|
|
+ $.each(oChannels, function (i) {
|
|
|
+ var id = $(this).find("id").eq(0).text(),
|
|
|
+ name = $(this).find("name").eq(0).text();
|
|
|
+ if ("" == name) {
|
|
|
+ name = "Zero Channel " + (i < 9 ? "0" + (i + 1) : (i + 1));
|
|
|
+ }
|
|
|
+ if ("true" == $(this).find("enabled").eq(0).text()) {// 过滤禁用的零通道
|
|
|
+
|
|
|
+ }
|
|
|
+ });
|
|
|
+ console.log(szDeviceIdentify + " 获取零通道成功!");
|
|
|
+ },
|
|
|
+ error: function (oError) {
|
|
|
+ console.log(szDeviceIdentify + " 获取零通道失败!", oError.errorCode, oError.errorMsg);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+ // 获取端口
|
|
|
+ getDevicePort(ip) {
|
|
|
+ var that=this;
|
|
|
+ var szDeviceIdentify = ip;
|
|
|
+
|
|
|
+ if (null == szDeviceIdentify) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ WebVideoCtrl.I_GetDevicePort(szDeviceIdentify).then((oPort) => {
|
|
|
+ console.log(szDeviceIdentify + " 获取端口成功!");
|
|
|
+ that.iRtspPort = oPort.iRtspPort
|
|
|
+ }, (oError) => {
|
|
|
+ var szInfo = "获取端口失败!";
|
|
|
+ console.log(szDeviceIdentify + szInfo, oError.errorCode, oError.errorMsg);
|
|
|
+ });
|
|
|
+ },
|
|
|
+ // 5.开始预览
|
|
|
+ clickStartRealPlay(szIP, szPort, iStreamType, iWndIndex, iChannelID) {
|
|
|
+ var that=this;
|
|
|
+ var oWndInfo = WebVideoCtrl.I_GetWindowStatus(this.g_iWndIndex),
|
|
|
+ szDeviceIdentify = szIP + "_" + szPort, //ip
|
|
|
+ iChannelID = iChannelID,
|
|
|
+ bZeroChannel = false,
|
|
|
+ iPort = this.iRtspPort,
|
|
|
+ szInfo = "";
|
|
|
+ iStreamType = parseInt(iStreamType, 10);;
|
|
|
+ if (null == szDeviceIdentify) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ this.szDeviceIdentify = szDeviceIdentify;
|
|
|
+ var startRealPlay = function() {
|
|
|
+ WebVideoCtrl.I_StartRealPlay(szDeviceIdentify, {
|
|
|
+ iStreamType: iStreamType,
|
|
|
+ iChannelID: iChannelID,
|
|
|
+ bZeroChannel: bZeroChannel,
|
|
|
+ iWndIndex: iWndIndex, //要播放的窗口
|
|
|
+ iPort: iPort, //如果多个摄像头需要必填 (RTSP 端口号)
|
|
|
+ success: function() {
|
|
|
+ szInfo = "开始预览窗口" + iWndIndex + "成功!";
|
|
|
+ console.log(szDeviceIdentify + " " + szInfo);
|
|
|
+ },
|
|
|
+ error: function(oError) {
|
|
|
+ console.log(szDeviceIdentify + " 开始预览窗口" + iWndIndex + "失败!", oError
|
|
|
+ .errorCode, oError.errorMsg);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ };
|
|
|
+ if (oWndInfo != null) { // 已经在播放了,先停止
|
|
|
+ WebVideoCtrl.I_Stop({
|
|
|
+ success: function() {
|
|
|
+ startRealPlay();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ startRealPlay();
|
|
|
+ }
|
|
|
+ },
|
|
|
}
|
|
|
}
|
|
|
</script>
|