private void CloseVideoSource() { if (!bOpsStopped) { videoPlayer.SignalToStop(); if (videoPlayer.IsRunning) { videoPlayer.WaitForStop(); Thread.Sleep(150); videoPlayer.Stop(); } if (motionDetector != null) { motionDetector.Reset(); } bOpsStopped = true; this.lblInfotext.Text.ToUpper(); this.lblInfotext.Text = "You can safely exit the App now."; this.lblInfotext.Text.ToLower(); } }
private void CloseCurrentVideoSource() { if (VideoSourcePlayer.VideoSource != null) { VideoSourcePlayer.SignalToStop(); // wait ~ 3 seconds for (int i = 0; i < 30; i++) { if (!VideoSourcePlayer.IsRunning) { break; } Thread.Sleep(100); } if (VideoSourcePlayer.IsRunning) { VideoSourcePlayer.Stop(); } VideoSourcePlayer.VideoSource = null; } }
/// <summary> /// 打开/关闭视频事件 /// </summary> private static void video_event_func() { if (NCVM_Form.isopen) { try { videoSource = new VideoCaptureDevice(videoDevices[capset / 100].MonikerString); videoSource.DesiredFrameSize = videoSource.VideoCapabilities[capset % 100].FrameSize; videoSource.NewFrame += show_video; videoSource.Start(); videoSourcePlayer.VideoSource = videoSource; videoSourcePlayer.Start(); timer_rec.Start(); } catch (Exception ex) { MessageBox.Show("错误:" + ex.Message); } } else { stop_flag = true; videoSource.Stop(); videoSourcePlayer.Stop(); } }
public static VideoSourcePlayer stop(this VideoSourcePlayer videoPlayer) { videoPlayer.invokeOnThread( () => { videoPlayer.Stop(); }); return(videoPlayer); }
/// <summary> /// 关闭摄像头设备 /// </summary> public static void CloseDevice() { if (div != null && div.IsRunning) { sourcePlayer.Stop(); div.SignalToStop(); div = null; CameraDevices = null; } }
private void buttonItem1_Click(object sender, EventArgs e) { try { currentplayer.Stop(); } catch { } }
private void OpenVideoSource(VideoCaptureDevice device) { // Close Old Video Source and writer if (videoSourcePlayer.IsRunning) { videoSourcePlayer.Stop(); } CloseVideoSource(); // Close the writer if it is already open so it can be re-opened with the new source if (vwriter != null && vwriter.IsOpen) { vwriter.Close(); } // Open New Video Source videoSourcePlayer.VideoSource = device; videoSourcePlayer.Start(); // Create new video file // Video file is .avi file. Title has "M-Fly Flight Video" followed by date and time vwriter = new VideoFileWriter(); vwriter.Open("M-Fly Flight Video " + DateTime.Now.ToString("yyyy MMMM dd hh mm") + ".avi", device.VideoResolution.FrameSize.Width, device.VideoResolution.FrameSize.Height, device.VideoResolution.AverageFrameRate); }
private void CloseVideoSource() { videoPlayer.SignalToStop(); if (videoPlayer.IsRunning) { videoPlayer.WaitForStop(); Thread.Sleep(150); videoPlayer.Stop(); this.txtBoxInfo.Text = "You can exit Splash now."; } //if (motionDetector != null) // motionDetector.Reset(); }
//void fileSource_NewFrame(object sender, AForge.Video.NewFrameEventArgs eventArgs) //{ // pictureBox1.Image = (Bitmap)eventArgs.Frame.Clone(); //} private void Form1_FormClosed(object sender, FormClosedEventArgs e) { try { if (pla.IsRunning) { pla.Stop(); } } catch { } try { if (FinalVideoSource.IsRunning) { FinalVideoSource.Stop(); } } catch { } }
// Close video source if it is running private void CloseCurrentVideoSource(VideoSourcePlayer player) { if (player.VideoSource != null) { player.SignalToStop(); // wait ~ 3 seconds for (int i = 0; i < 30; i++) { if (!player.IsRunning) { break; } System.Threading.Thread.Sleep(100); } if (player.IsRunning) { player.Stop(); } player.VideoSource = null; } }
private void frmMain_FormClosing(object sender, FormClosingEventArgs e) { videoSourcePlayer.Stop(); }
public void Shutdown() { VideoSourcePlayer.Stop(); }
private void Form1_FormClosing(object sender, FormClosingEventArgs e) { player.Stop(); player.Dispose(); }
/// <summary> 关闭摄像头 /// </summary> /// <param name="vSource">摄像头显示控件</param> public void Stop(VideoSourcePlayer vSource) { vSource.Stop();//关闭摄像头 }