Exemplo n.º 1
0
        private void OnButtonSelectMicClick(object sender, EventArgs e)
        {
            CloseMic();
            buttonSelectMic.Text = "...";

            ItemPickerForm form = new ItemPickerForm();

            form.KindFilter = Kind.Microphone;
            form.AutoAccept = true;
            form.Init(Configuration.Instance.GetItems());

            // Ask user to select a camera
            if (form.ShowDialog() == DialogResult.OK)
            {
                _selectedItem        = form.SelectedItem;
                buttonSelectMic.Text = _selectedItem.Name;

                _pcmLiveSource = new PcmLiveSource(_selectedItem);
                try
                {
                    _pcmLiveSource.PcmSourceSettings.SamplingRate  = 8000;
                    _pcmLiveSource.PcmSourceSettings.BitsPerSample = PcmSourceSettings.BitsPerSampleType.TwoBytesInt;
                    _pcmLiveSource.PcmSourceSettings.Channels      = PcmSourceSettings.ChannelsType.Mono;
                    _pcmLiveSource.Init();
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Could not Init:" + ex.Message);
                    CloseMic();
                }
            }

            UpdateUiState();
        }
Exemplo n.º 2
0
 private void CloseMic()
 {
     try
     {
         if (_pcmLiveSource != null)
         {
             // Close any current displayed PCM Live Source
             _pcmLiveSource.LiveContentEvent -= PcmLiveContentEvent;
             _pcmLiveSource.LiveStatusEvent  -= PcmLiveStatusEvent;
             _pcmLiveSource.Close();
             _pcmLiveSource = null;
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Could not close:" + ex.Message);
     }
 }