///////////////////////////////////////////////////////////////////////// var uMaxID=64; var uPlayFileID=new Array(64); var uRecordID=new Array(64); var uCCSessID=-1; var vConfID=0; var g_interval = 0;//定时器全局变量 var g_msg = false; var isFirefox=navigator.userAgent.toUpperCase().indexOf("FIREFOX")?true:false; var isIE=navigator.userAgent.toUpperCase().indexOf("MSIE")?true:false; var isChrome=navigator.userAgent.toUpperCase().indexOf("CHROME")?true:false; //////////////////////////////////////////////////////////////////////// // //js脚本调用在IE10以上需要IE10兼容模式如例子html否则js脚本会失效, //当然开发者可以重新构造IE10调用activex的js脚本。 // function T_WaitForWin(vWin) { var vTimeout=5000; var vBegintime=new Date(); var vEndtime=new Date(); while(vWin.vInit != 1 && vEndtime.getTime() - vBegintime.getTime() < (vTimeout*2))//ns超时 { if(vEndtime.getTime() - vBegintime.getTime() > vTimeout)//1s还没有完成,使用等待方式 { Sleep(100);//等待100ms } vEndtime=new Date(); } } function I_CheckActiveX() { var iVer = 1;//第一个版本 check_ver(iVer,function(nRet){ var szHint=""; switch(nRet) { case W_OK://检查成功 szHint = "安装成功"; break; case W_TRY://试用 szHint ="试用版本已安装成功"; break; case W_NO_FOUND://没有找到校验服务器 szHint ="没有找到校验服务器"; break; case W_EXCEED_NUM: szHint ="校验服务器超过用户数了"; break; default: szHint ="没有安装本地驱动,请下载"; break; } AppendStatus(szHint); // alert(szHint); }); } function TV_Initialize() { //检测是否安装中间件 //var qnv = document.getElementById('qnviccub'); // qnv.attachEvent("OnQnvEvent", T_GetEvent); DevInfo(0,QNV_DEVINFO_GETCHANNELS,function (nResult){ if(nResult <= 0) { OpenDevice(0,function (nResult){ DevInfo(0,QNV_DEVINFO_GETCHANNELS,function (channels){ if(channels > 0) { //初始化变量 for(i=0;i= 0) { SetParam(nChannel, paramName,nValue,nextFunc);//设置参数 } } //控制设备参数函数 //nChannel通道号 //paramName//参数名 //nValue参数值 function TV_SetDevCtrl(nChannel,paramName,nValue,nextFunc) { return SetDevCtrl(nChannel,paramName,nValue,nextFunc); } function TV_StopConference(nextFunc) { if(vConfID > 0) { Conference(-1,vConfID,QNV_CONFERENCE_DELETECONF,0,0,function(nResult) { nextFunc(nResult); vConfID = 0; AppendStatus("会议停止"); });//删除会议 } } function TV_StartConference() { OpenDevice(ODT_SOUND,0,0,function (nResult){ if(nResult <=0) { AppendStatus("打开声卡模块失败"); } else { TV_StopConference(function (nResult){ Conference(-1,0,QNV_CONFERENCE_CREATE,0,"",function (vConfID){ if(vConfID <= 0) AppendStatus("创建会议失败"); else { Conference(SOUND_CHANNELID,vConfID,QNV_CONFERENCE_ADDTOCONF,0,"",function(vRet){ AppendStatus("加入会议完成,Ret="+vRet); DevInfo(0,QNV_DEVINFO_GETCHANNELS,function(chammels){ for(i=0;i 模拟来电号码:"+szCallID); }); });//设置送码方式为一声后FSK模式,默认为一声前dtmf模式//DIALTYPE_DTMF } }); }else { General(uID,QNV_GENERAL_STOPRING,0,0,function(h){ AppendStatusEx(uID,"停止内线震铃"); }); } } function TV_StartPlayFile(uID,szFile) { // vFilePath ="c:\\test.wav"; vFilePath = "d:\\wyluyin\\20220608191204_13027625915.wav"; // alert("播放文件路径为:"+vFilePath); if(vFilePath.length > 0) { // AppendStatus("选择文件:"+vFilePath); // TV_StopPlayFile(uID);//先停止上次播放的句柄 var vmask=PLAYFILE_MASK_REPEAT;//循环播放 PlayFile(uID,QNV_PLAY_FILE_START,0,vmask,vFilePath,function(id){ console.log(id); // uPlayFileID[uID]=id; // if(id<=0) // { // AppendStatusEx(uID,"播放失败:"+vFilePath); // } // else // { // AppendStatusEx(uID,"开始播放文件:"+vFilePath); // } }); } else { AppendStatus("没有选择文件") } } function TV_StopPlayFile(uID) { if(uPlayFileID[uID] > 0) { PlayFile(uID,QNV_PLAY_FILE_STOP,uPlayFileID[uID],0,0,function (nRet){ AppendStatusEx(uID,"停止播放"); uPlayFileID[uID] =0; }); }else { AppendStatusEx(uID,"未播放的句柄"); uPlayFileID[uID] =0; } } function TV_StopPlayFileEx(uID,nextFunc) { if(uPlayFileID[uID] > 0) { PlayFile(uID,QNV_PLAY_FILE_STOP,uPlayFileID[uID],0,0,function (nRet){ uPlayFileID[uID] =0; nextFunc(); AppendStatusEx(uID,"停止播放"); }); }else { uPlayFileID[uID] =0; nextFunc(); AppendStatusEx(uID,"未播放的句柄"); } } function TV_StartRecordFile(uID,fp) { vFilePath = fp; // vFilePath ="c:\\test.wav"; //有些操作系统c盘保护,保存到c盘可能会失败,可以换到其它盘符 console.log("录音文件路径为:"+vFilePath); if(vFilePath.length > 0) { TV_StopPlayFileEx(uID,function(){ var vFormatID=BRI_WAV_FORMAT_PCM8K16B;//选择使用8K16bit采样 var vmask=RECORD_MASK_ECHO|RECORD_MASK_AGC;//使用回音抵消后并且自动增益的 RecordFile(uID,QNV_RECORD_FILE_START,vFormatID,vmask,vFilePath,function (hRec){ uRecordID[uID] = hRec; if(uRecordID[uID] <= 0) { AppendStatusEx(uID,"录音失败:"+vFilePath); }else { AppendStatusEx(uID,"开始录音文件: id="+uRecordID[uID]+" "+vFilePath); } }); }); } else { AppendStatus("没有选择文件"); } } function TV_StopRecordFile(uID) { if(uRecordID[uID] > 0) { //var vRecPath=GetRecFilePath(uID,uRecordID[uID]); RecordFile(uID,QNV_RECORD_FILE_PATH,uRecordID[uID],0,0,function(vRecPath){ RecordFile(uID,QNV_RECORD_FILE_ELAPSE,uRecordID[uID],0,0,function(vElapse){ RecordFile(uID,QNV_RECORD_FILE_STOP,uRecordID[uID],0,0,function(nRet){ AppendStatusEx(uID,"停止录音:"+vRecPath+" 录音时间:"+vElapse); uRecordID[uID]=0; }); }); }); } } function TV_DeleteRecordFile(uID) { CallLog(uID,QNV_CALLLOG_DELRECFILE,"",0,function(vRet){ if(vRet <= 0) { alert('删除失败:'+vRet); }else alert('删除完成'); }); } function TV_StartDial(uID,szCode) {//正常拨号必须使用 DIALTYPE_DTMF General(uID,QNV_GENERAL_STARTDIAL,DIALTYPE_DTMF,szCode,function (nRet){ if(nRet <= 0) { AppendStatusEx(uID,"拨号失败:"+szCode); } else{ AppendStatusEx(uID,"开始拨号:"+szCode); } }); } function TV_GetDiskList() { Tool(QNV_TOOL_DISKLIST,0,0,0,function(vDiskList){ ; AppendStatus("按逗号分隔的盘符列表:"+vDiskList); }); } function TV_GetFreeSpace(szDiskname) { Tool(QNV_TOOL_DISKFREESPACE,0,szDiskname,0,function (vFreeSpace){ AppendStatus(szDiskname+" 空闲大小为:"+vFreeSpace+"(M)"); }); } function TV_GetTotalSpace(szDiskname) { Tool(QNV_TOOL_DISKTOTALSPACE,0,szDiskname,0,function (vTotalSpace){ AppendStatus(szDiskname+" 总共大小为:"+vTotalSpace+"(M)"); }); } function TV_BrowerPath() { Tool(QNV_TOOL_SELECTDIRECTORY,0,"选择目录",0,function(vPath){ AppendStatus("选择目录:"+vPath); }); } function TV_SelectFile() { Tool(QNV_TOOL_SELECTFILE,0,"wav files|*.wav|all files|*.*||",0,function(vFilePath){ AppendStatus("选择文件:"+vFilePath); }); } function TV_uploadFile(uploadUrl) { //上传文件 vFilePath ="c:\\test.wav"; console.log("上传文件路径为:"+vFilePath); Remote(QNV_REMOTE_UPLOAD_START,0,uploadUrl,vFilePath,0,0, function(nRet){ //nRet <=0表示失败 if(nRet<=0) AppendStatus("上传文件:"+vFilePath+"失败"); else AppendStatus("上传文件:"+vFilePath+"成功"); }); } /*阿里云的URL 可以参照阿里云上传例子把其中的参数签名加密生成如下URL http://post-test.oss-cn-hangzhou.aliyuncs.com/?name=message.wav&key=${filename}&policy=eyJleHBpcmF0aW9uIjoiMjAyMC0wMS0wMVQxMjowMDowMC4wMDBaIiwiY29uZGl0aW9ucyI6W1siY29udGVudC1sZ */ function ali_uploadFile(uploadUrl) { vFilePath ="c:\\test.wav"; alert("上传文件路径为:"+vFilePath); //上传文件 UploadFile(uploadUrl,vFilePath,function(nRet){ //nRet <=0表示失败 if( nRet<=0 ) AppendStatus("上传文件:"+vFilePath+"失败"); else AppendStatus("上传文件:"+vFilePath+"成功"); }); } /* //登陆CC function TV_LoginCC(cc,pwd) { if(CCCtrl(QNV_CCCTRL_ISLOGON,NULL,0) > 0) alert('已经登陆,请先离线'); else { var v=cc+','+pwd; var vret=CCCtrl(QNV_CCCTRL_LOGIN,v,0); if(vret <= 0)//开始登陆 alert('登陆CC失败:'+vret); else AppendStatus("开始登陆CC:"+cc); } } //CC离线 function TV_LogoutCC() { CCCtrl(QNV_CCCTRL_LOGOUT,NULL,0);//离线 AppendStatus("已离线"); } function T_GetMsgValue(vmsg,vkey) { var strs = vmsg.split("\r\n"); for(var i = 0; i < strs.length; i++) { var vline=strs[i]; var vindex=vline.indexOf(vkey); if(vindex != -1) { return vline.slice(vkey.length+1); } } return ""; } */ //编码问题 var base64EncodeChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; var base64DecodeChars = new Array( -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -1, -1, -1, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1, -1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1, -1, -1); function base64encode(str) { var out, i, len; var c1, c2, c3; len = str.length; i = 0; out = ""; while(i < len) { c1 = str.charCodeAt(i++) & 0xff; if(i == len) { out += base64EncodeChars.charAt(c1 >> 2); out += base64EncodeChars.charAt((c1 & 0x3) << 4); out += "=="; break; } c2 = str.charCodeAt(i++); if(i == len) { out += base64EncodeChars.charAt(c1 >> 2); out += base64EncodeChars.charAt(((c1 & 0x3)<< 4) | ((c2 & 0xF0) >> 4)); out += base64EncodeChars.charAt((c2 & 0xF) << 2); out += "="; break; } c3 = str.charCodeAt(i++); out += base64EncodeChars.charAt(c1 >> 2); out += base64EncodeChars.charAt(((c1 & 0x3)<< 4) | ((c2 & 0xF0) >> 4)); out += base64EncodeChars.charAt(((c2 & 0xF) << 2) | ((c3 & 0xC0) >>6)); out += base64EncodeChars.charAt(c3 & 0x3F); } return out; } function base64decode(str) { var c1, c2, c3, c4; var i, len, out; len = str.length; i = 0; out = ""; while(i < len) { /* c1 */ do { c1 = base64DecodeChars[str.charCodeAt(i++) & 0xff]; } while(i < len && c1 == -1); if(c1 == -1) break; /* c2 */ do { c2 = base64DecodeChars[str.charCodeAt(i++) & 0xff]; } while(i < len && c2 == -1); if(c2 == -1) break; out += String.fromCharCode((c1 << 2) | ((c2 & 0x30) >> 4)); /* c3 */ do { c3 = str.charCodeAt(i++) & 0xff; if(c3 == 61) return out; c3 = base64DecodeChars[c3]; } while(i < len && c3 == -1); if(c3 == -1) break; out += String.fromCharCode(((c2 & 0XF) << 4) | ((c3 & 0x3C) >> 2)); /* c4 */ do { c4 = str.charCodeAt(i++) & 0xff; if(c4 == 61) return out; c4 = base64DecodeChars[c4]; } while(i < len && c4 == -1); if(c4 == -1) break; out += String.fromCharCode(((c3 & 0x03) << 6) | c4); } return out; } function utf16to8(str) { var out, i, len, c; out = ""; len = str.length; for(i = 0; i < len; i++) { c = str.charCodeAt(i); if ((c >= 0x0001) && (c <= 0x007F)) { out += str.charAt(i); } else if (c > 0x07FF) { out += String.fromCharCode(0xE0 | ((c >> 12) & 0x0F)); out += String.fromCharCode(0x80 | ((c >> 6) & 0x3F)); out += String.fromCharCode(0x80 | ((c >> 0) & 0x3F)); } else { out += String.fromCharCode(0xC0 | ((c >> 6) & 0x1F)); out += String.fromCharCode(0x80 | ((c >> 0) & 0x3F)); } } return out; } function utf8to16(str) { var out, i, len, c; var char2, char3; out = ""; len = str.length; i = 0; while(i < len) { c = str.charCodeAt(i++); switch(c >> 4) { case 0: case 1: case 2: case 3: case 4: case 5: case 6: case 7: // 0xxxxxxx out += str.charAt(i-1); break; case 12: case 13: // 110x xxxx  10xx xxxx char2 = str.charCodeAt(i++); out += String.fromCharCode(((c & 0x1F) << 6) | (char2 & 0x3F)); break; case 14: // 1110 xxxx 10xx xxxx 10xx xxxx char2 = str.charCodeAt(i++); char3 = str.charCodeAt(i++); out += String.fromCharCode(((c & 0x0F) << 12) | ((char2 & 0x3F) << 6) | ((char3 & 0x3F) << 0)); break; } } return out; } function getCurrentDate(format) { var now = new Date(); var year = now.getFullYear(); //得到年份 var month = now.getMonth();//得到月份 var date = now.getDate();//得到日期 var day = now.getDay();//得到周几 var hour = now.getHours();//得到小时 var minu = now.getMinutes();//得到分钟 var sec = now.getSeconds();//得到秒 month = month + 1; if (month < 10) month = "0" + month; if (date < 10) date = "0" + date; if (hour < 10) hour = "0" + hour; if (minu < 10) minu = "0" + minu; if (sec < 10) sec = "0" + sec; var time = ""; //精确到天 if(format==1){ time = year + "-" + month + "-" + date; } //精确到分 else if(format==2){ time = year + "-" + month + "-" + date+ " " + hour + ":" + minu + ":" + sec; }else if(format==3){ time = year + "" + month + "" + date+ "" + hour + "" + minu + "" + sec; } return time; }