Esempio n. 1
0
        /*private int getActiveRenderDeviceId()
         * {
         *  // read config
         *  var conf = AppConfiguration.ReadConfig();
         *
         *  // read active render devices
         *  var renderDevices = new AudioDeviceEnemerator().GetRenderDevices();
         *
         *  DeviceInfo device = new DeviceInfo();
         *
         *  // is config ok?
         *  if (renderDevices.Exists(cd => cd.Id.Equals(conf.RenderDevice.Id)))
         *  {
         *      device = conf.RenderDevice;
         *      return device.Id;
         *  }
         *  else if (renderDevices.Count > 0)
         *  {
         *      device = renderDevices.First();
         *  }
         *  conf.RenderDevice = device;
         *
         *  try
         *  {
         *      AppConfiguration.SaveConfig(conf);
         *  }
         *  catch (Exception ex)
         *  {
         *      Logger.log.Warn(ex);
         *  }
         *
         *  return device.Id;
         * }
         */
        private int getActiveCaptureDeviceId()
        {
            // read config
            var conf = AppConfiguration.ReadConfig();

            // read active capture devices
            var captureDevices = new AudioDeviceEnemerator().GetCaptureDevices();

            DeviceInfo activeCaptureDevice = new DeviceInfo();

            // is config ok?
            if (captureDevices.Exists(cd => cd.ProductGuid.Equals(conf.CaptureDevice.ProductGuid)))
            {
                activeCaptureDevice = conf.CaptureDevice;
            }
            else if (captureDevices.Count > 0)
            {
                activeCaptureDevice = captureDevices.First();
            }
            else
            {
                return(-1);
            }

            return(new AudioDeviceEnemerator().GetCaptureDeviceIdByProductGUID(activeCaptureDevice.ProductGuid));
        }
Esempio n. 2
0
        private void InitComboboxes()
        {
            try
            {
                var config = AppConfiguration.ReadConfig();

                cbOutput.Items.Clear();
                cbInput.Items.Clear();

                var audioDeviceEnum = new AudioDeviceEnemerator();
                var renderDevices   = audioDeviceEnum.GetRenderDevices();
                var captureDevices  = audioDeviceEnum.GetCaptureDevices();

                //Output
                cbOutput.Items.AddRange(renderDevices.ToArray());
                DeviceInfo itemToSelect = cbOutput.Items.Cast <DeviceInfo>().ToList().Find(di => di.ProductGuid.Equals(config.RenderDevice.ProductGuid));

                DeviceInfo noDeviceOutput = new DeviceInfo();
                cbOutput.Items.Add(noDeviceOutput); // kein Gerät

                if (itemToSelect != null)
                {
                    // select
                    cbOutput.SelectedItem = itemToSelect;
                }
                else
                {
                    cbOutput.SelectedItem = noDeviceOutput;
                }
                config.RenderDevice = cbOutput.SelectedItem as DeviceInfo;

                //Input
                cbInput.Items.AddRange(captureDevices.ToArray());
                DeviceInfo itemToSelectInput = cbInput.Items.Cast <DeviceInfo>().ToList().Find(di => di.ProductGuid.Equals(config.CaptureDevice.ProductGuid));

                if (itemToSelectInput != null)
                {
                    // select
                    cbInput.SelectedItem = itemToSelectInput;
                }
                else if (captureDevices.Count > 0)
                {
                    cbInput.SelectedIndex = 0;
                }
                else
                {
                    DeviceInfo noDeviceInput = new DeviceInfo();
                    cbInput.Items.Add(noDeviceInput);
                    cbInput.SelectedItem = noDeviceInput;
                }

                config.CaptureDevice = cbInput.SelectedItem as DeviceInfo;
                AppConfiguration.SaveConfig(config);
            }
            catch (Exception ex)
            {
                MessageBoxManager.ShowMessageBoxErrorContactAdmin(ex.StackTrace);
            }
        }
Esempio n. 3
0
        private void Client_ClientVoiceMessageReceivedEvent(object obj, ClientVoiceMessageReceivedEventArgs e)
        {
            executeCodeOnUIThread(() =>
            {
                try
                {
                    int renderDeviceId = new AudioDeviceEnemerator().GetRenderDeviceIdByProductGUID(AppConfiguration.ReadConfig().RenderDevice.ProductGuid);

                    if (renderDeviceId >= 0)
                    {
                        lock (voiceMessageQueue)
                        {
                            voiceMessageQueue.Enqueue(e.VoiceMessage);
                            if (soundPlayer == null)
                            {
                                showVoiceMessageReceivedBallonTip(e.VoiceMessage);

                                soundPlayer = new SoundPlayer(renderDeviceId);
                                soundPlayer.PlaybackStoppedEvent += soundPlayer_PlaybackStopped;

                                soundPlayer.Play(voiceMessageQueue.Dequeue().Data);
                            }
                        }
                    }
                    else
                    {
                        showVoiceMessageReceivedBallonTip(e.VoiceMessage);
                        //MessageBoxManager.ShowMessageBoxError("Fehler beim Abspielen der Broadcast-Nachricht, da kein Ausgabegerät gefunden werden konnte.");
                    }
                }
                catch (Exception ex)
                {
                    MessageBoxManager.ShowMessageBoxError(ERROR_PLAYING_VOICEMESSAGE_STRING);
                    Logger.log.Error(ex);
                }
            });
        }