//nChannel 表示通道号，通道从1开始
//nStreamType的范围如下
//typedef enum eStreamMediaType
//{
//    eStreamMediaTypeBegin			=	0,				/*!< 起始值									*/
//    eMainVideoAndSound            =   1,				/*!< 主码流音视频							*/
//    eMainVideo,                   =   2，				/*!< 主码流视频								*/
//    eMainSound,					=	3，			    /*!< 主码流音频								*/
//    eAssistVideo,					=	4，				/*!< 子码流视频								*/
//    eAssistHDVideo,				=	5，				/*!< 高清子码流视频							*/
//    eStreamMediaTypeEnd,			=	6，				/*!< 结束值									*/
//}eStreamMediaType;
//通常我们使用枚举eMainVideoAndSound打开主码流，使用eAssistVideo打开子码流。rtsp流的URL
//下面的函数可以反复调用来加载不同码流的视频,但是最后退出时要调用UnLoadVideo()函数
function LoadVideoV1(nChannel, nStreamType) {
    var ncx = document.getElementById("previewocx");
    if (ncx == null) {
        bootoast({
            message: 'ActiveX plugin not attached!',
            type: 'danger',
            position: 'bottom-center',
            timeout: true,
            animationDuration: 3000,
            dismissable: true
        });
    }
    var urla = document.URL.split('/');
    var dev = urla.length > 3 ? urla[2] : '192.168.1.168';
    var strIP = dev.split(':')[0];
    var nPort = config.Network.commandPort;
    var strUserName = config.user;
    var strUserPassword = config.password;
    var nRet = ncx.LoadVideoV1(strIP, nPort, strUserName, strUserPassword, nChannel, nStreamType);
    if (nRet == 35) {
        bootoast({
            message: $.i18n.prop('i18n-maxline'),
            type: 'danger',
            position: 'bottom-center',
            timeout: true,
            animationDuration: 3000,
            dismissable: true
        });
    }
}

function InitPreviewParameters(a, b, c) {
    var ncx = document.getElementById("previewocx");
    if (ncx == null) {
        bootoast({
            message: 'ActiveX plugin not attached!',
            type: 'danger',
            position: 'bottom-center',
            timeout: true,
            animationDuration: 3000,
            dismissable: true
        });
    }
    ncx.InitPreviewParameters(a, b, c);
}

function setAdaptiveResolution(n) {
    var ncx = document.getElementById("previewocx");
    if (ncx == null) {
        bootoast({
            message: 'ActiveX plugin not attached!',
            type: 'danger',
            position: 'bottom-center',
            timeout: true,
            animationDuration: 3000,
            dismissable: true
        });
    }
    ncx.AdaptiveResolution(n); //调节适配分辨率的接口
}

function setLanguageResource(xml) {
    var ncx = document.getElementById("dvrocx");
    if (ncx == null) {
        bootoast({
            message: 'ActiveX plugin not attached!',
            type: 'danger',
            position: 'bottom-center',
            timeout: true,
            animationDuration: 3000,
            dismissable: true
        });
    }

    var urla = document.URL.split('/');
    var dev = urla.length > 3 ? urla[2] : '192.168.1.168';
    var nRet = ncx.SetLanaguageResource(xml);

}

//点阵
function setlattice(xml) {
    var ncx = document.getElementById("previewocx");
    if (ncx == null) {
        return null
    } else {
        var nRet = ncx.StringToLattice(xml);
        return nRet
    }

}

//卸载视频流
function UnLoadVideo() {
    var ncx = document.getElementById("previewocx");
    if (ncx == null) {
        bootoast({
            message: 'ActiveX plugin not attached!',
            type: 'danger',
            position: 'bottom-center',
            timeout: true,
            animationDuration: 3000,
            dismissable: true
        });
    }

    var nRet = ncx.UnLoadVideo();

}

//全屏显示流
function FullScreen() {
    var ncx = document.getElementById("previewocx");
    if (ncx == null) {
        bootoast({
            message: 'ActiveX plugin not attached!',
            type: 'danger',
            position: 'bottom-center',
            timeout: true,
            animationDuration: 3000,
            dismissable: true
        });
    }
    ncx.FullScreen();
}

//开启语音对讲
function Playtalkback() {
    var ncx = document.getElementById("previewocx");
    if (ncx == null) {
        bootoast({
            message: 'ActiveX plugin not attached!',
            type: 'danger',
            position: 'bottom-center',
            timeout: true,
            animationDuration: 3000,
            dismissable: true
        });
    }
    ncx.StartVoiceStream(0);
}
//关闭语音对讲
function Stoptalkback() {
    var ncx = document.getElementById("previewocx");
    if (ncx == null) {
        bootoast({
            message: 'ActiveX plugin not attached!',
            type: 'danger',
            position: 'bottom-center',
            timeout: true,
            animationDuration: 3000,
            dismissable: true
        });
    }
    ncx.StopVoiceStream(0);
}

//PlayAudio是在保证LoadVideo之后并且要确保nStreamType 是eMainVideoAndSound的情况下，才能打开音频
//参数nChannel,表示打开的通道号,从1开始
function PlayAudio(nChannel) {
    var ncx = document.getElementById("previewocx");
    if (ncx == null) {
        bootoast({
            message: 'ActiveX plugin not attached!',
            type: 'danger',
            position: 'bottom-center',
            timeout: true,
            animationDuration: 3000,
            dismissable: true
        });
    }
    var nRet = ncx.PlayAudio(nChannel);

}

//StopAudio是在保证LoadVideo之后并且要确保nStreamType 是eMainVideoAndSound的情况下，才能打开音频
//参数nChannel,表示打开的通道号,从1开始
function StopAudio(nChannel) {
    var ncx = document.getElementById("previewocx");
    if (ncx == null) {
        bootoast({
            message: 'ActiveX plugin not attached!',
            type: 'danger',
            position: 'bottom-center',
            timeout: true,
            animationDuration: 3000,
            dismissable: true
        });
    }
    var nRet = ncx.StopAudio(nChannel);

}


//StopDrawRegion是在保证LoadVideo之后，调用该函数之后，不可以在预览界面画区域。
function StopDrawRegion() {
    var ncx = document.getElementById("previewocx");
    if (ncx == null) {
        bootoast({
            message: 'ActiveX plugin not attached!',
            type: 'danger',
            position: 'bottom-center',
            timeout: true,
            animationDuration: 3000,
            dismissable: true
        });
    }
    var nRet = ncx.StopDrawRegion();

}

//AddDrawRegion(nLeft,nTop,nRight,nBottom),是在插件内部画一个区域
//其中nLeft,nRight的范围【0-704】，nTop,nBottom的范围是【0-576】
//nLeft的坐标要小于nRight
//nTop的坐标要小于nBottom
function AddDrawRegion(TopLeftX, TopLeftY, BottomRightX, BottomRightY) {
    var ncx = document.getElementById("previewocx");
    if (ncx == null) {
        bootoast({
            message: 'ActiveX plugin not attached!',
            type: 'danger',
            position: 'bottom-center',
            timeout: true,
            animationDuration: 3000,
            dismissable: true
        });
    }
    var nLeft = TopLeftX;
    var nTop = TopLeftY;
    var nRight = BottomRightX;
    var nBottom = BottomRightY;
    var nRet = ncx.AddDrawRegion(nLeft, nTop, nRight, nBottom);
    if (nRet != 0) {
        //alert("AddDrawRegion failed,nRet=" + nRet);
    } else {
        //alert("AddDrawRegion success");
    }
}


//设置控件模式0，表示普通的预览模式（带右键菜单和码率显示），1表示马赛克，移动侦测，ISP预览模式（不带右键菜单）
//保证登录之后调用才效果
function SetActiveXMode(nmode) {
    var ncx = document.getElementById("dvrocx");
    try {
        ncx.SetActiveXType(nmode);
    } catch (e) {

    }
}

// 布防多边形
function PolygonProtectionControl(a, b, c) {
    var ncx = document.getElementById("previewocx");
    if (ncx == null) {
        bootoast({
            message: 'ActiveX plugin not attached!',
            type: 'danger',
            position: 'bottom-center',
            timeout: true,
            animationDuration: 3000,
            dismissable: true
        });
    }
    try {
        return ncx.PolygonProtectionControl(a, b, c);
    } catch (e) {
        // alert(e.description);
    }
}
//绊线设置
function AssisstantLineControl(a) {
    var ncx = document.getElementById("previewocx");
    if (ncx == null) {
        bootoast({
            message: 'ActiveX plugin not attached!',
            type: 'danger',
            position: 'bottom-center',
            timeout: true,
            animationDuration: 3000,
            dismissable: true
        });
    }
    try {
        return ncx.AssisstantLineControl(a);
    } catch (e) {
        // alert(e.description);
    }
}

/**
 * axtive定时刷新码率
 * @param a
 * @param b
 * @param c
 * @constructor
 */

function UpdateStreamBitrate(a, b, c) {
    var ncx = document.getElementById("previewocx");
    if (ncx == null) {
        bootoast({
            message: 'ActiveX plugin not attached!',
            type: 'danger',
            position: 'bottom-center',
            timeout: true,
            animationDuration: 3000,
            dismissable: true
        });
    }
    try {
        ncx.UpdateStreamBitrate(a, b, c);
    } catch (e) {
        // alert(e.description);
    }
}


// 获取路径
function GetLocalSettings() {
    var ncx = document.getElementById("previewocx");
    try {
        var nRet = ncx.GetLocalSettings();
        var xmlDoc = parseXmlFromStr(nRet);
        return xmlDoc.getElementsByTagName("LocalSettings")[0].getAttribute("SelectDiskDriver");
    } catch (e) {}
}



/*******************************************************************************
 * Function ldvideos 功能: 载入视频流
 ******************************************************************************/
function ldvideos(a) {
    var ncx = document.getElementById("dvrocx");
    if (!ncx.object) {
        window.location.href = "login.html?downloaded=iePlugin";
        return;
    }
    var ocxVersion = ncx.GetOCXVersion();
    var versionFlag = true;

    if (compareversion(ocxVersion, config.iePlugVersion) == -1) {
        versionFlag = false;
    }
    if (!versionFlag) { //如果当前版本小于最新版本提示跟新插件
        window.location.href = "login.html?downloaded=iePlugin";
        return;
    }
    SetActiveXMode(0); //先设置插件模式
    InitDevicePreviewParameters(config.deviceInfo.VideoInputChannels, config.Network.commandPort, config.MacAddress);
    InitChannelStreamCount(a + 1, 2);
    DeviceLogin(location.hostname, config.Network.commandPort, config.user, config.password);
    // InitPreviewParameters(config.MacAddress, config.Network.HTTPprot, config.deviceCap.StreamCount);
    // LoadVideoV1(1, 1); // 主码流
    RealtimeViewInitialize()
    var xml = "<LanaguageResource ShowBitrate=" + "\"" + $.i18n.prop('i18n-showbitrate') + "\" " + "MainStream=" + "\"" + $.i18n.prop('i18n-miancodestream') + "\" " + "SubStream=" + "\"" + $.i18n.prop('i18n-codestream1') + "\" " + "MobileStream=" + "\"" + $.i18n.prop('i18n-codestream2') + "\"" + "</LanaguageResource>";
    try {
        if (setLanguageResource && typeof(setLanguageResource) == "function") {
            setLanguageResource(xml);
        }
    } catch (e) {
        //TODO handle the exception
    }
    // setAdaptiveResolution(0);
    // ncx.SetActiveXType(0);
}


/*******************************************************************************
 * Function ldvideos 功能: 载入视频流
 ******************************************************************************/
function ldspecialvideos(id) {
    SetActiveXMode(0);
    setAdaptiveResolution(0);
    var ncx = document.getElementById("previewocx");
    ncx.SetActiveXType(2);
    switch (id) {
        case "1":
            InitPreviewParameters(config.MacAddress, config.Network.HTTPprot, config.deviceCap.StreamCount);
            LoadVideoV1(1, 1); // 主码流
            break;
        case "4":
            InitPreviewParameters(config.MacAddress, config.Network.HTTPprot, config.deviceCap.StreamCount);
            LoadVideoV1(1, 4); // 子码流
            break;
        case "5":
            InitPreviewParameters(config.MacAddress, config.Network.HTTPprot, config.deviceCap.StreamCount);
            LoadVideoV1(1, 5); // 手机码流
            break;
        default:
            InitPreviewParameters(config.MacAddress, config.Network.HTTPprot, config.deviceCap.StreamCount);
            LoadVideoV1(1, 1);
            break;
    }
}

function compareversion(versionBegin, versionEnd) {
    var temp1;
    var temp2;
    temp1 = versionBegin.split(".");
    temp2 = versionEnd.split(".");
    for (var i = 0; i < 4; i++) {
        if (Number(temp1[i]) > Number(temp2[i])) {
            return 1;
        } else if (Number(temp1[i]) < Number(temp2[i])) {
            return -1;
        }
    }
    return 0;
}


function update() {
    var imgObj = document.getElementById('rimg12');
    imgObj.src = config.ipcsrc + (new Date()).getTime();
}

function onloadMy() {
    var data = "<img src='" + config.ipcsrc + "' id='rimg12' width='100%' height='100%'>";
    $("#axdiv").html(data);
    config.gs_interval = setInterval("update()", 500);
}


function InitPrivatePreviewEvent(a) {
    ldvideos(a); // 载入视频流
    // setAdaptiveResolution(0);
}
// --------------------------------------------NVR相关的
//关闭所有
function CloseAllChannels() {
    var ncx = document.getElementById("dvrocx");
    console.log(ncx, "66666666");
    if (ncx == null) {
        bootoast({
            message: 'ActiveX plugin not attached!',
            type: 'danger',
            position: 'bottom-center',
            timeout: true,
            animationDuration: 3000,
            dismissable: true
        });
    }
    ncx.CloseAllChannels();
}
// 配置出流
function PreviewSpecificChannelInFirstWindow(chn, type) {
    var ncx = document.getElementById("dvrocx");
    if (ncx == null) {
        bootoast({
            message: 'ActiveX plugin not attached!',
            type: 'danger',
            position: 'bottom-center',
            timeout: true,
            animationDuration: 3000,
            dismissable: true
        });
    }
    ncx.PreviewSpecificChannelInFirstWindow(chn, type);
}
// 设置osd配置到插件
function DisplayOsdControl(bool, ch, xml) {
    var ncx = document.getElementById("dvrocx");
    if (ncx == null) {
        bootoast({
            message: 'ActiveX plugin not attached!',
            type: 'danger',
            position: 'bottom-center',
            timeout: true,
            animationDuration: 3000,
            dismissable: true
        });
    }
    ncx.DisplayOsdControl(bool, ch, xml);
}
// 从插件获取osd配置
function GetDisplayOsdPosition(ch) {
    var ncx = document.getElementById("dvrocx");
    if (ncx == null) {
        bootoast({
            message: 'ActiveX plugin not attached!',
            type: 'danger',
            position: 'bottom-center',
            timeout: true,
            animationDuration: 3000,
            dismissable: true
        });
    }
    return ncx.GetDisplayOsdPosition(ch);

}
// 下面三个是nvr设备初始化必须的包含了设备框初始化，具体不清楚分别做什么不清楚
function RealtimeViewInitialize() {
    var ncx = document.getElementById("dvrocx");
    if (ncx == null) {
        bootoast({
            message: 'ActiveX plugin not attached!',
            type: 'danger',
            position: 'bottom-center',
            timeout: true,
            animationDuration: 3000,
            dismissable: true
        });
    }
    ncx.RealtimeViewInitialize();
}

function InitDevicePreviewParameters(a, b, c) {
    var ncx = document.getElementById("dvrocx");
    if (ncx == null) {
        bootoast({
            message: 'ActiveX plugin not attached!',
            type: 'danger',
            position: 'bottom-center',
            timeout: true,
            animationDuration: 3000,
            dismissable: true
        });
    }
    ncx.InitDevicePreviewParameters(a, b, c);
}

function InitChannelStreamCount(chnel, strom) {
    var ncx = document.getElementById("dvrocx");
    if (ncx == null) {
        bootoast({
            message: 'ActiveX plugin not attached!',
            type: 'danger',
            position: 'bottom-center',
            timeout: true,
            animationDuration: 3000,
            dismissable: true
        });
    }
    ncx.InitChannelStreamCount(chnel, strom);
}
// 这个方法应该是设备登录方法，出流之前需要登录
function DeviceLogin(ip, port, user, password) {
    var ncx = document.getElementById("dvrocx");
    if (ncx == null) {
        bootoast({
            message: 'ActiveX plugin not attached!',
            type: 'danger',
            position: 'bottom-center',
            timeout: true,
            animationDuration: 3000,
            dismissable: true
        });
    }
    ncx.DeviceLogin(ip, port, user, password);

}
// 这个方法是单独预览配置窗口的方法,分屏
function ChangeLayout(nems) {
    var ncx = document.getElementById("dvrocx");
    if (ncx == null) {
        bootoast({
            message: 'ActiveX plugin not attached!',
            type: 'danger',
            position: 'bottom-center',
            timeout: true,
            animationDuration: 3000,
            dismissable: true
        });
    }
    ncx.ChangeLayout(nems);

}
// 播放,预览要用的方法
function PlayVideo(cbns, nstypes) {
    var ncx = document.getElementById("dvrocx");
    if (ncx == null) {
        bootoast({
            message: 'ActiveX plugin not attached!',
            type: 'danger',
            position: 'bottom-center',
            timeout: true,
            animationDuration: 3000,
            dismissable: true
        });
    }
    var playvalue = ncx.PlayVideo(cbns, nstypes);
    if (playvalue == 35) {
        bootoast({
            message: $.i18n.prop("i18n-maxline"),
            type: 'danger',
            position: 'bottom-center',
            timeout: true,
            animationDuration: 3000,
            dismissable: true
        });
        return;
    }
}
// 关比视频，主要也是预览和配置使用
function StopVideo(channel) {
    var ncx = document.getElementById("dvrocx");
    if (ncx == null) {
        bootoast({
            message: 'ActiveX plugin not attached!',
            type: 'danger',
            position: 'bottom-center',
            timeout: true,
            animationDuration: 3000,
            dismissable: true
        });
    }
    ncx.StopVideo(channel);
}
// 声音控制全局不针对某个具体通道,chn为-1，st表示开关1和0
function AudioContrl(chn, st) {
    var ncx = document.getElementById("dvrocx");
    if (ncx == null) {
        bootoast({
            message: 'ActiveX plugin not attached!',
            type: 'danger',
            position: 'bottom-center',
            timeout: true,
            animationDuration: 3000,
            dismissable: true
        });
    }
    var aa = ncx.AudioControl(chn, st);
    console.log(aa, "调用声音控制插件返回值");
}
// 对讲开启
function StartVoiceStream() {
    var ncx = document.getElementById("dvrocx");
    if (ncx == null) {
        bootoast({
            message: 'ActiveX plugin not attached!',
            type: 'danger',
            position: 'bottom-center',
            timeout: true,
            animationDuration: 3000,
            dismissable: true
        });
    }
    ncx.StartVoiceStream(-1);
}
// 对讲关闭
function StopVoiceStream() {
    var ncx = document.getElementById("dvrocx");
    if (ncx == null) {
        bootoast({
            message: 'ActiveX plugin not attached!',
            type: 'danger',
            position: 'bottom-center',
            timeout: true,
            animationDuration: 3000,
            dismissable: true
        });
    }
    ncx.StopVoiceStream(-1);
}
// 全屏
function FullScreenr() {
    var ncx = document.getElementById("dvrocx");
    if (ncx == null) {
        bootoast({
            message: 'ActiveX plugin not attached!',
            type: 'danger',
            position: 'bottom-center',
            timeout: true,
            animationDuration: 3000,
            dismissable: true
        });
    }
    ncx.FullScreen();
}
// 抓图
function CaptureImager(chn) {
    var ncx = document.getElementById("dvrocx");
    if (ncx == null) {
        bootoast({
            message: 'ActiveX plugin not attached!',
            type: 'danger',
            position: 'bottom-center',
            timeout: true,
            animationDuration: 3000,
            dismissable: true
        });
    }
    try {
    ncx.CaptureImage(chn);
    } catch (e) {
        // alert(e.description);
    }
}
// 开启所有预览
function openAllscrn(stremtype) {
    var ncx = document.getElementById("dvrocx");
    if (ncx == null) {
        bootoast({
            message: 'ActiveX plugin not attached!',
            type: 'danger',
            position: 'bottom-center',
            timeout: true,
            animationDuration: 3000,
            dismissable: true
        });
    }
    var clallvalue = ncx.OpenAllChannels(stremtype)
    for (var i = 0; i < config.deviceInfo.VideoInputChannels; i++) {
        var item = clallvalue.getItem(i);
        if (item == 35) {
            bootoast({
                message: $.i18n.prop("i18n-maxline"),
                type: 'danger',
                position: 'bottom-center',
                timeout: true,
                animationDuration: 3000,
                dismissable: true
            });
            return;
        } else if (item == 0) {
            ChannelShowText(i, "CAM" + (i - 0 + 1))
        }
    }
}
// 关闭所有预览
function clooseAllscrn() {
    var ncx = document.getElementById("dvrocx");
    if (ncx == null) {
        bootoast({
            message: 'ActiveX plugin not attached!',
            type: 'danger',
            position: 'bottom-center',
            timeout: true,
            animationDuration: 3000,
            dismissable: true
        });
    }
    ncx.CloseAllChannels()
}
// 展示通道号
function ChannelShowText(num, text) {
    var ncx = document.getElementById("dvrocx");
    if (ncx == null) {
        bootoast({
            message: 'ActiveX plugin not attached!',
            type: 'danger',
            position: 'bottom-center',
            timeout: true,
            animationDuration: 3000,
            dismissable: true
        });
    }
    ncx.SetChannelShowText(num, text)

}
// 开始录像（返回0表示执行正确，返回非0表示执行失败）
// 录像的路径是【X:\\webclient2\\video\\】，其中X是SetLocalSettings()函数设置“SelectDiskDriver”字段的值
function nvrStartRecord(channel) {
    var ncx = document.getElementById("dvrocx");
    if (ncx == null) {
        bootoast({
            message: 'ActiveX plugin not attached!',
            type: 'danger',
            position: 'bottom-center',
            timeout: true,
            animationDuration: 3000,
            dismissable: true
        });
    }
    try {
        ncx.StartRecord(channel);
    } catch (e) {
        // alert(e.description);
    }
}

// 停止录像（返回0表示执行正确，返回非0表示执行失败）
function nvrStopRecord(channel) {
    var ncx = document.getElementById("dvrocx");
    if (ncx == null) {
        bootoast({
            message: 'ActiveX plugin not attached!',
            type: 'danger',
            position: 'bottom-center',
            timeout: true,
            animationDuration: 3000,
            dismissable: true
        });
    }
  ncx.StopRecord(channel);
}
// 回放初始化
function initPlayback() {
    var ncx = document.getElementById("dvrocx");
    if (ncx == null) {
        bootoast({
            message: 'ActiveX plugin not attached!',
            type: 'danger',
            position: 'bottom-center',
            timeout: true,
            animationDuration: 3000,
            dismissable: true
        });
    }
    ncx.HistroyViewInitialize();
}
// 回放播放
function playbackstart(req) {
    var ncx = document.getElementById("dvrocx");
    if (ncx == null) {
        bootoast({
            message: 'ActiveX plugin not attached!',
            type: 'danger',
            position: 'bottom-center',
            timeout: true,
            animationDuration: 3000,
            dismissable: true
        });
    }
    ncx.StartRemotePlayback(req);

}
// 回放停止播放
function StopRemotePlayback() {
    var ncx = document.getElementById("dvrocx");
    if (ncx == null) {
        bootoast({
            message: 'ActiveX plugin not attached!',
            type: 'danger',
            position: 'bottom-center',
            timeout: true,
            animationDuration: 3000,
            dismissable: true
        });
    }
    ncx.StopRemotePlayback();
}
// 回放暂停
function RemotePlaybackSuspend(num, chn) {
    var ncx = document.getElementById("dvrocx");
    if (ncx == null) {
        bootoast({
            message: 'ActiveX plugin not attached!',
            type: 'danger',
            position: 'bottom-center',
            timeout: true,
            animationDuration: 3000,
            dismissable: true
        });
    }
    ncx.RemotePlaybackSuspend(num, chn);

}
// 单帧
function PlayByFrameRemotePlayback(chn, rn) {
    var ncx = document.getElementById("dvrocx");
    if (ncx == null) {
        bootoast({
            message: 'ActiveX plugin not attached!',
            type: 'danger',
            position: 'bottom-center',
            timeout: true,
            animationDuration: 3000,
            dismissable: true
        });
    }
    ncx.PlayByFrameRemotePlayback(chn, rn);
}
// 回放声音控制is取值0和1，chn通道号
function PlaySoundRemotePlayback(is, chn) {
    var ncx = document.getElementById("dvrocx");
    if (ncx == null) {
        bootoast({
            message: 'ActiveX plugin not attached!',
            type: 'danger',
            position: 'bottom-center',
            timeout: true,
            animationDuration: 3000,
            dismissable: true
        });
    }
    ncx.PlaySoundRemotePlayback(is, chn);
}
// 回放抓图
function CaptureImageRemotePlayback(chn) {
    var ncx = document.getElementById("dvrocx");
    if (ncx == null) {
        bootoast({
            message: 'ActiveX plugin not attached!',
            type: 'danger',
            position: 'bottom-center',
            timeout: true,
            animationDuration: 3000,
            dismissable: true
        });
    }
    var nRet = ncx.CaptureImageRemotePlayback(chn);
    // var str = ncx.GetLocalSettings();
    // var xmlDoc = parseXmlFromStr(str);
    // var strTemp = xmlDoc.getElementsByTagName("LocalSettings")[0].getAttribute("SelectDiskDriver");
    var xmlDoc = parseXmlFromStr(nRet);
    if (0 != nRet && nRet == "") {
        bootoast({
            message: 'ActiveX plugin not attached!',
            type: 'danger',
            position: 'bottom-center',
            timeout: true,
            animationDuration: 3000,
            dismissable: true
        });
    } else {
        console.log("zhuatu chenggon");
    }
}
// 回放定位点跳转
function RemotePlaybackSetPos(chn, req) {
    var ncx = document.getElementById("dvrocx");
    if (ncx == null) {
        bootoast({
            message: 'ActiveX plugin not attached!',
            type: 'danger',
            position: 'bottom-center',
            timeout: true,
            animationDuration: 3000,
            dismissable: true
        });
    }
    ncx.RemotePlaybackSetPos(chn, req);
}
// 回放路线下载
function StartHistroyStreamDownload(req) {
    var ncx = document.getElementById("dvrocx");
    if (ncx == null) {
        bootoast({
            message: 'ActiveX plugin not attached!',
            type: 'danger',
            position: 'bottom-center',
            timeout: true,
            animationDuration: 3000,
            dismissable: true
        });
    }
    return ncx.StartHistroyStreamDownload(req);
}
// 回放录像下载进度查询
function GetRemoteDownloadPercent() {
    var ncx = document.getElementById("dvrocx");
    if (ncx == null) {
        bootoast({
            message: 'ActiveX plugin not attached!',
            type: 'danger',
            position: 'bottom-center',
            timeout: true,
            animationDuration: 3000,
            dismissable: true
        });
    }
    return ncx.GetRemoteDownloadPercent();

}
// 这个暂时不知道干嘛的但是应该是空值速度啥的
function RemotePlaybackSuspend(num, chn) {
    var ncx = document.getElementById("dvrocx");
    if (ncx == null) {
        bootoast({
            message: 'ActiveX plugin not attached!',
            type: 'danger',
            position: 'bottom-center',
            timeout: true,
            animationDuration: 3000,
            dismissable: true
        });
    }
    ncx.RemotePlaybackSuspend(num, chn);
}
// 改变预览比例
function AspectRatioControl(ratio, chn) {
    var ncx = document.getElementById("dvrocx");
    if (ncx == null) {
        bootoast({
            message: 'ActiveX plugin not attached!',
            type: 'danger',
            position: 'bottom-center',
            timeout: true,
            animationDuration: 3000,
            dismissable: true
        });
    }
    ncx.AspectRatioControl(ratio, chn);
}
//StartDrawRegion预览界面画选中区域，供移动侦测或者马赛克画区域使用
function StartDrawRegion(ch) {
    var ncx = document.getElementById("dvrocx");
    if (ncx == null) {
        bootoast({
            message: 'ActiveX plugin not attached!',
            type: 'danger',
            position: 'bottom-center',
            timeout: true,
            animationDuration: 3000,
            dismissable: true
        });
    }
    ncx.StartDrawRegion(ch);
}
//SetBrushColor的nR,nG,nB的范围都是【0-255】用来设置画刷的颜色，供移动侦测或者马赛克画区域使用
function SetBrushColor(ch, cl) {
    var ncx = document.getElementById("dvrocx");
    if (ncx == null) {
        bootoast({
            message: 'ActiveX plugin not attached!',
            type: 'danger',
            position: 'bottom-center',
            timeout: true,
            animationDuration: 3000,
            dismissable: true
        });
    }
    var nRet = ncx.SetBrushColor(ch, cl);
}
//显示选中的区域，供移动侦测或隐私遮蔽使用
function SetDisplayRegionsEnable(chn, en) {
    var ncx = document.getElementById("dvrocx");
    if (ncx == null) {
        bootoast({
            message: 'ActiveX plugin not attached!',
            type: 'danger',
            position: 'bottom-center',
            timeout: true,
            animationDuration: 3000,
            dismissable: true
        });
    }
    try {
        var nRet = ncx.SetDisplayRegionsEnable(chn, en);

    } catch (e) {
        // alert(e.description);
    }
}
//AddDrawRegion(nLeft,nTop,nRight,nBottom),是在插件内部画一个区域
//其中nLeft,nRight的范围【0-704】，nTop,nBottom的范围是【0-576】
//nLeft的坐标要小于nRight
//nTop的坐标要小于nBottom
function AddDrawRegion(ch, TopLeftX, TopLeftY, BottomRightX, BottomRightY) {
    var ncx = document.getElementById("dvrocx");
    if (ncx == null) {
        bootoast({
            message: 'ActiveX plugin not attached!',
            type: 'danger',
            position: 'bottom-center',
            timeout: true,
            animationDuration: 3000,
            dismissable: true
        });
    }
    var nLeft = TopLeftX;
    var nTop = TopLeftY;
    var nRight = BottomRightX;
    var nBottom = BottomRightY;
    ncx.AddDrawRegion(ch, nLeft, nTop, nRight, nBottom);
}
//清除选中的区域
function ClearDrawRegions(chs) {
    var ncx = document.getElementById("dvrocx");
    if (ncx == null) {
        bootoast({
            message: 'ActiveX plugin not attached!',
            type: 'danger',
            position: 'bottom-center',
            timeout: true,
            animationDuration: 3000,
            dismissable: true
        });
    }
    ncx.ClearDrawRegions(chs);
}
//返回的是当前选中的区域
function GetDrawRegions(cn) {
    var ncx = document.getElementById("dvrocx");
    if (ncx == null) {
        bootoast({
            message: 'ActiveX plugin not attached!',
            type: 'danger',
            position: 'bottom-center',
            timeout: true,
            animationDuration: 3000,
            dismissable: true
        });
    }
    return ncx.GetDrawRegions(cn);
}
//获取流比特率
function UpdateStreamBitrate(chn, manin, sub1, sub2) {
    var ncx = document.getElementById("dvrocx");
    if (ncx == null) {
        bootoast({
            message: 'ActiveX plugin not attached!',
            type: 'danger',
            position: 'bottom-center',
            timeout: true,
            animationDuration: 3000,
            dismissable: true
        });
    }
    ncx.UpdateStreamBitrate(chn, manin, sub1, sub2);
}
