private void button2_Click(object sender, EventArgs e) { if (streamLocCam.Checked == true) { if (button2.Text == "Start Camera") { kamera = new VideoCaptureDevice(webCams[comboBox1.SelectedIndex].MonikerString); kamera.NewFrame += new NewFrameEventHandler(video_NewFrame); kamera.Start(); button2.Text = "Stop Camera"; } else { kamera.SignalToStop(); kamera = null; button2.Text = "Start Camera"; } } else { if (button2.Text == "Start Camera") { stream = new MJPEGStream("http://" + inputIP.Text + "/video"); stream.NewFrame += new NewFrameEventHandler(video_NewFrame); stream.Start(); button2.Text = "Stop Camera"; } else { stream.SignalToStop(); stream = null; button2.Text = "Start Camera"; } } }
private void btn_playPause_Click(object sender, EventArgs e) { i++; if (i % 2 == 0) { this.btn_playPause.Image = ((System.Drawing.Image)(Properties.Resources.playIcon)); btn_capImage.Enabled = false; videoSource.SignalToStop(); videoSource.WaitForStop(); videoSource.Stop(); } else { new Thread(() => { Thread.CurrentThread.IsBackground = true; btn_capImage.Enabled = true; videoSource.Login = camUsername; videoSource.Password = camPassword; this.btn_playPause.Image = ((System.Drawing.Image)(Properties.Resources.pauseIcon)); videoSource.NewFrame += new NewFrameEventHandler(video_NewFrame); videoSource.Start(); }).Start(); } }
protected override void OnUpdateFrame(FrameEventArgs e) { base.OnUpdateFrame(e); if (Keyboard [Key.Escape]) { Exit(); } if (Keyboard [Key.S]) { videoStream.SignalToStop(); } }
/// <summary> /// Funkcja zatrzymująca działanie kamery. /// </summary> public void StopCamera() { if (stream == null) { return; } else if (stream.IsRunning) { stream.SignalToStop(); } }
private void StopVideo(int cam) { switch (cam) { case 0: vspTarget.SignalToStop(); vspTarget.WaitForStop(); videoSource.SignalToStop(); videoSource.WaitForStop(); break; case 1: case 2: case 3: vspTarget.SignalToStop(); vspTarget.WaitForStop(); stream.SignalToStop(); stream.WaitForStop(); break; } btnCapture.Text = "Start"; capVideoInProgress = false; cmbCamera.Enabled = true; }
private void Form1_FormClosing(object sender, FormClosingEventArgs e) { stream.SignalToStop(); stream.Stop(); }
void stream_VideoError(object sender, VideoSourceErrorEventArgs eventArgs) { stream.SignalToStop(); workCamera = false; MessageBox.Show("Connect camera fail!! " + eventArgs.Description); }
public void SignalToStop() { client.SignalToStop(); }