public CaptureTest() { // // Required for Windows Form Designer support // InitializeComponent(); // Start with the first video/audio devices // Don't do this in the Release build in case the // first devices cause problems. #if DEBUG capture = new Capture( filters.VideoInputDevices[0], filters.AudioInputDevices[0] ); capture.CaptureComplete += new EventHandler( OnCaptureComplete ); #endif // Update the main menu // Much of the interesting work of this sample occurs here try { updateMenu(); } catch {} }
private void mnuAudioDevices_Click(object sender, System.EventArgs e) { try { // Get current devices and dispose of capture object // because the video and audio device can only be changed // by creating a new Capture object. Filter videoDevice = null; Filter audioDevice = null; if ( capture != null ) { videoDevice = capture.VideoDevice; audioDevice = capture.AudioDevice; capture.Dispose(); capture = null; } // Get new audio device MenuItem m = sender as MenuItem; audioDevice = ( m.Index>0 ? filters.AudioInputDevices[m.Index-1] : null ); // Create capture object if ( ( videoDevice != null ) || ( audioDevice != null ) ) { capture = new Capture( videoDevice, audioDevice ); capture.CaptureComplete += new EventHandler( OnCaptureComplete ); } // Update the menu updateMenu(); } catch (Exception ex) { MessageBox.Show( "Audio device not supported.\n\n" + ex.Message + "\n\n" + ex.ToString() ); } }