예제 #1
0
        /// <summary>
        /// When the window size changes, stop the video, resize then restart the video.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void MainForm_SizeChanged(object sender, EventArgs e)
        {
            MainVideoPlayer.SignalToStop();
            MainVideoPlayer.WaitForStop();

            ResizeVideoPlayer();

            MainVideoPlayer.Start();
        }
예제 #2
0
        /// <summary>
        /// Assures that everything is stopped before exiting.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
        {
            // Stop audio components.
            CurrentWaveOut.Stop();
            CurrentWaveIn.StopRecording();

            // Stop video components.
            MainVideoPlayer.SignalToStop();
            MainVideoPlayer.WaitForStop();
        }
예제 #3
0
        /// <summary>
        /// Activates or desactivates the video and audio player.
        /// </summary>
        private void TogglePlayerState()
        {
            if (IsPlaying)
            {
                // Link video input device.
                VideoCaptureDevice videoCaptureDevice = new VideoCaptureDevice(VideoDevices[VideoSourceSelector.SelectedIndex].MonikerString);
                VideoSourceWHRatio          = ((float)(videoCaptureDevice.VideoCapabilities.FirstOrDefault().FrameSize.Width)) / ((float)(videoCaptureDevice.VideoCapabilities.FirstOrDefault().FrameSize.Height));
                MainVideoPlayer.VideoSource = videoCaptureDevice;

                // Link audio input device to WaveIn.
                CurrentWaveIn.DeviceNumber = AudioSourceSelector.SelectedIndex;

                // Create WaveBuffer with the WaveIn.
                WaveBuffer = new BufferedWaveProvider(CurrentWaveIn.WaveFormat);
                WaveBuffer.DiscardOnBufferOverflow = true;

                // Initialize WaveOut with the WaveBuffer.
                CurrentWaveOut.Init(WaveBuffer);

                // Start playing the video and audio.
                ResizeVideoPlayer();
                MainVideoPlayer.Start();
                CurrentWaveIn.StartRecording();
                CurrentWaveOut.Play();
            }
            else
            {
                // Stop audio components.
                CurrentWaveOut.Stop();
                CurrentWaveIn.StopRecording();

                // Stop video components.
                MainVideoPlayer.SignalToStop();
                MainVideoPlayer.WaitForStop();
            }
        }