public string videotrick() { string str = ""; this.thread = new Thread(new ThreadStart(this.testcam)); this.thread.Start(); //if ((err[0] || err[1] || err[2] || err[3] || err[4] || err[5] || err[6] || err[7] || err[8] || err[9] ) == false) { str = "ok"; } if (err[0]) { str = "cam1err"; } if (err[1]) { str = str + "cam2err"; } if (err[2]) { str = str + "cam3err"; } if (err[3]) { str = str + "cam4err"; } if (err[4]) { str = str + "cam5err"; } if (err[5]) { str = str + "cam6err"; } if (err[6]) { str = str + "cam7err"; } if (err[7]) { str = str + "cam8err"; } if (err[8]) { str = str + "cam9err"; } if (err[9]) { str = str + "cam10err"; } foreach (VlcPlayer sk in _listClientSocket) { string[] cut = sk.name.Split(new char[] { '#', '#' }); if ((err[int.Parse(cut[4])]) && (netok[int.Parse(cut[4])])) { sk.Stop(); _listClientSocket.Remove(sk); DateTime begintime = Convert.ToDateTime(cut[3]); string timestr = DateTime.Now.ToString("hh_mm_ss"); string beginstr = begintime.ToString("yyyy_MM_dd_hh_mm_ss"); string path = pathmain + "\\" + cut[0] + "\\" + cut[1] + "#" + cut[2] + "#" + beginstr + "#" + timestr + ".mp4"; //VlcPlayer vlc_player_ = new VlcPlayer(pluginPath, "E:\\DCIM\\004\\" + cut[1] + "#" + cut[2] + "#" + cut[3] + "1.mp4"); VlcPlayer vlc_player_ = new VlcPlayer(pluginPath, path); vlc_player_.name = sk.name; vlc_player_.PlayURL("rtsp://" + cut[7] + ":" + cut[8] + "@" + cut[5] + ":" + cut[6] + "/12"); _listClientSocket.Add(vlc_player_); err[int.Parse(cut[4])] = false; break; } } return(str); }
private void button1_Click(object sender, EventArgs e) { audio1.Text = "静音"; audio2.Text = "静音"; audio3.Text = "静音"; audio4.Text = "静音"; audio1.Enabled = false; audio2.Enabled = false; timer1.Enabled = true; audio3.Enabled = false; audio4.Enabled = false; load_1.Visible = false; load_2.Visible = false; load_3.Visible = false; load_4.Visible = false; foreach (VlcPlayer sk in _listClientSocket) { sk.Stop(); } _listClientSocket.Clear(); IntPtr render_wnd_1 = panel1.Handle; IntPtr render_wnd_2 = panel2.Handle; IntPtr render_wnd_3 = panel3.Handle; IntPtr render_wnd_4 = panel4.Handle; if (ds.Tables.Count > 0) { for (int i = ds.Tables[0].Rows.Count - 1; i >= 0; i--) { ip = ds.Tables[0].Rows[i][0].ToString(); port = int.Parse(ds.Tables[0].Rows[i][1].ToString()); uname = ds.Tables[0].Rows[i][2].ToString(); userpwd = ds.Tables[0].Rows[i][3].ToString(); string n = ds.Tables[0].Rows[i][4].ToString(); VlcPlayer vlc_player_ = new VlcPlayer(pluginPath); if (n == "1") { vlc_player_.SetRenderWindow((int)render_wnd_1); } if (n == "2") { vlc_player_.SetRenderWindow((int)render_wnd_2); } if (n == "3") { vlc_player_.SetRenderWindow((int)render_wnd_3); } if (n == "4") { vlc_player_.SetRenderWindow((int)render_wnd_4); } vlc_player_.PlayURL("rtsp://" + uname + ":" + userpwd + "@" + ip + ":" + port + "/12"); vlc_player_.name = n; _listClientSocket.Add(vlc_player_);//未将对象引用到实例 } for (int i = 0; i <= 3; i++) { en[i] = false; } foreach (VlcPlayer sk in _listClientSocket) { sk.SetVolume(0); if (sk.name == "1") { en[0] = true; load_1.Visible = true; } if (sk.name == "2") { en[1] = true; load_2.Visible = true; } if (sk.name == "3") { en[2] = true; load_3.Visible = true; } if (sk.name == "4") { en[3] = true; load_4.Visible = true; } } for (int i = 0; i <= 3; i++) { if (en[0] == false) { nel1.Text = "1号无输入"; } else { audio1.Enabled = true; nel1.Text = "1号输入"; } if (en[1] == false) { nel2.Text = "2号无输入"; } else { audio2.Enabled = true; nel2.Text = "2号输入"; } if (en[2] == false) { nel3.Text = "3号无输入"; } else { audio3.Enabled = true; nel3.Text = "3号输入"; } if (en[3] == false) { nel4.Text = "4号无输入"; } else { audio4.Enabled = true; nel4.Text = "4号输入"; } } } }