private void button2_Click(object sender, EventArgs e) { if (isPlayBacking) { MessageBox.Show("请先停止当前回放"); return; } if (!isPlaying) { if (nowDeviceInfo.token != "") { if (LCSDK.LCOpenSDK_startStream(nowDeviceInfo) == 0) { isPlaying = true; button2.Text = "停止播放"; } } else { MessageBox.Show("请先获取设备列表"); } } else { isPlaying = false; LCSDK.LCOpenSDK_stopStream(objectIndex); button2.Text = "开始播放"; } }
private void button3_Click(object sender, EventArgs e) { if (!isRecordying) { isRecordying = true; string videoPath = "D:\\LCVideo\\LCVideo.mp4"; LCSDK.LCOpenSDK_startRecord(objectIndex, System.Text.Encoding.Default.GetBytes(videoPath)); button3.Text = "停止录像"; } else { button3.Text = "开始录像"; LCSDK.LCOpenSDK_stopRecord(objectIndex); isRecordying = false; } }
private void ptzCtrl_Click(object sender, EventArgs e) { if (!isPlaying) { return; } Label obj = (Label)sender; string strType = obj.Name.Replace("ptzCtrl", ""); PTZCtrlType ptzCtrlType = (PTZCtrlType)int.Parse(strType); string errorMsg = ""; if (!LCSDK.LCOpenSDK_PTZCtrl(nowDeviceInfo.token, nowDeviceInfo.deviceID, (int)nowDeviceInfo.channelIndex, ptzCtrlType, ref errorMsg)) { } else { //labelPrompt.Text = "提示信息:" + errorMsg; } }
private void button4_Click(object sender, EventArgs e) { if (!isPlaying) { return; } if (!isTalking) { isTalking = true; LCSDK.LCOpenSDK_playTalk(objectIndex); button4.Text = "停止对讲"; } else { LCSDK.LCOpenSDK_stopTalk(objectIndex); isTalking = false; button4.Text = "开始对讲"; } }
private void button1_Click(object sender, EventArgs e) { this.listBox1.Items.Clear(); string deviceList = ""; if (LCSDK.LCOpenSDK_GetdeviceList(Form1.token, "1-100", ref deviceList, 0)) { JObject jsonObj = (JObject)JsonConvert.DeserializeObject(deviceList); int deviceCount = jsonObj["devices"].Count(); int channelTotalCount = 0; for (int i = 0; i < deviceCount; i++) { deviceJsonObj[i] = (JObject)jsonObj["devices"][i];// int channelCount = deviceJsonObj[i]["channels"].Count(); for (int j = 0; j < channelCount; j++) { string channelId = deviceJsonObj[i]["channels"][j]["channelId"].ToString(); deviceInfoList[channelTotalCount] = new _dhlc_device_t(); deviceInfoList[channelTotalCount].definitionMode = 0; deviceInfoList[channelTotalCount].objectIndex = objectIndex; deviceInfoList[channelTotalCount].channelIndex = int.Parse(channelId); deviceInfoList[channelTotalCount].deviceID = deviceJsonObj[i]["deviceId"].ToString(); deviceInfoList[channelTotalCount].token = Form1.token; deviceInfoList[channelTotalCount].playType = PlayCtrlType.PLAYCTRL_REALPLAY; deviceInfoList[channelTotalCount].hWnd = (int)picVideo.Handle; AddVideo(channelTotalCount, deviceJsonObj[i]["name"].ToString(), channelId , deviceJsonObj[i]["channels"][j]["channelOnline"].ToString(), deviceJsonObj[i]["channels"][j]["channelPicUrl"].ToString()); channelTotalCount++; } } nowDeviceInfo = deviceInfoList[0]; } else { //labelPrompt.Text = "提示信息:" + deviceList; MessageBox.Show(deviceList); } }
private void button1_Click(object sender, EventArgs e) { LCSDK.LCOpenSDK_SetSystem(textBox1.Text, textBox2.Text); //管理员账号模拟登录 if (!LCSDK.LCOpenSDK_GetToken(textBox3.Text, comboBox1.SelectedIndex, ref token)) { MessageBox.Show("得不到token"); return; } //MessageBox.Show(token); OPEN_API_INIT_PARAM initParam; initParam.appId = "lc2e12496fc30a4a7b"; initParam.appSecret = "a4ad8f9063ea47398982a6617c40c8"; initParam.caPath = Application.StartupPath + "\\LCSDK\\222.pem"; initParam.host = "openapi.lechange.cn"; initParam.port = 443; LCSDK.LCOpenSDK_initOpenApi(initParam); frmMain obj = new frmMain(); this.Visible = false; obj.ShowDialog(); this.Close(); }