Exemple #1
0
 private void SoundRecorder_RecordingStoppedEvent(object obj, NAudioWrapper.SoundRecordingStoppedEventArgs e)
 {
     if (e.SoundeData.Length >= 10000 /*more than ~ 500 ms of recording time*/)
     {
         if (client.IsConnected)
         {
             try
             {
                 client.SendVoiceMessage(new VoiceMessage(broadcastClient, e.SoundeData));
             }
             catch (Exception ex)
             {
                 executeCodeOnUIThread(() =>
                 {
                     MessageBoxManager.ShowMessageBoxError("Fehler beim übertragen der Broadcast-Nachricht.\n\n\n" + ex.StackTrace);
                 });
             }
         }
         else
         {
             executeCodeOnUIThread(() =>
             {
                 MessageBoxManager.ShowMessageBoxError("Ihre Broadcast-Nachricht konnte nicht versendet werden, da es keine Verbindung zum Server besteht.");
             });
         }
     }
 }
Exemple #2
0
        private void startRecording()
        {
            int captureDeviceId = getActiveCaptureDeviceId();

            if (captureDeviceId >= 0)
            {
                try
                {
                    btnRecord.Image = Properties.Resources.Speak_Off;

                    soundRecorder = new SoundRecorder(captureDeviceId);
                    soundRecorder.RecordingStoppedEvent += SoundRecorder_RecordingStoppedEvent;

                    startTimerRecordingDuration();
                    soundRecorder.Start();
                }
                catch (Exception ex)
                {
                    stopTimerRecordingDuration();
                    soundRecorder = null;
                    throw ex;
                }
            }
            else
            {
                MessageBoxManager.ShowMessageBoxError(MESSAGE_NO_CAPTUREDEVICE_FOUND_STRING);
            }
        }
Exemple #3
0
        private void soundPlayer_PlaybackStopped(object sender, EventArgs e)
        {
            lock (voiceMessageQueue)
            {
                if (voiceMessageQueue.Count > 0) // voicemessage data are in queue
                {
                    VoiceMessage voiceMessage = voiceMessageQueue.Dequeue();

                    executeCodeOnUIThread(() => {
                        showVoiceMessageReceivedBallonTip(voiceMessage);
                        try
                        {
                            soundPlayer.Play(voiceMessage.Data);
                        }
                        catch (Exception ex)
                        {
                            Logger.log.Error(ex);
                            MessageBoxManager.ShowMessageBoxError(ERROR_PLAYING_VOICEMESSAGE_STRING);
                        }
                    });
                }
                else
                {
                    soundPlayer.Stop();
                    soundPlayer = null;
                }
            }
        }
Exemple #4
0
 private void btnRecord_MouseUp(object sender, MouseEventArgs e)
 {
     try
     {
         stopRecording();
     }
     catch (Exception ex)
     {
         executeCodeOnUIThread(() =>
         {
             MessageBoxManager.ShowMessageBoxError("Fehler bei der Aufnahme.\n\n\n" + ex.StackTrace);
         });
     }
 }
Exemple #5
0
 private void TrayIcon_MouseClick(object sender, MouseEventArgs e)
 {
     if (e.Button == MouseButtons.Left)
     {
         int captureDeviceId = getActiveCaptureDeviceId();
         if (!client.IsConnected)
         {
             MessageBoxManager.ShowMessageBoxError("Voicebroadcast hat keine Verbindung zum Server!");
         }
         else if (captureDeviceId >= 0)
         {
             setAppTaskbarIconState(true);
             showForm();
         }
         else
         {
             MessageBoxManager.ShowMessageBoxError(MESSAGE_NO_CAPTUREDEVICE_FOUND_STRING);
         }
     }
 }
Exemple #6
0
        private void ok_Click(object sender, EventArgs e)
        {
            IPAddress ipTemp;

            if (IPAddress.TryParse(tbServerIP.Text, out ipTemp))
            {
                Cursor.Current = Cursors.WaitCursor;
                try
                {
                    AppConfiguration.SaveConfig(
                        new AppConfiguration(tbServerIP.Text, (int)nudServerPort.Value, tbClientName.Text, cbInput.SelectedItem as DeviceInfo, cbOutput.SelectedItem as DeviceInfo));
                    Close();
                }
                catch (Exception ex)
                {
                    MessageBoxManager.ShowMessageBoxErrorContactAdmin(ex.StackTrace);
                }
            }
            else
            {
                MessageBoxManager.ShowMessageBoxError("Bitte geben Sie eine gültige IP-Adresse ein.");
            }
        }
Exemple #7
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);
                }
            });
        }