private void BtnVoiceOnTouch(object sender, View.TouchEventArgs e)
        {
            try
            {
                var handled = false;

                if (e.Event?.Action == MotionEventActions.Up)
                {
                    try
                    {
                        if (IsRecording)
                        {
                            RecorderService.StopRecording();
                            PathVoice = RecorderService.GetRecorded_Sound_Path();

                            BtnVoice.SetColorFilter(Color.ParseColor(AppSettings.MainColor));
                            BtnVoice.SetImageResource(Resource.Drawable.microphone);

                            if (TextRecorder == "Recording")
                            {
                                if (!string.IsNullOrEmpty(PathVoice))
                                {
                                    Bundle bundle = new Bundle();
                                    bundle.PutString("FilePath", PathVoice);
                                    RecordSoundFragment.Arguments = bundle;
                                    ReplaceTopFragment(RecordSoundFragment);
                                }

                                TextRecorder = "";
                            }

                            IsRecording = false;
                        }
                        else
                        {
                            if (UserDetails.SoundControl)
                            {
                                Methods.AudioRecorderAndPlayer.PlayAudioFromAsset("Error.mp3");
                            }

                            Toast.MakeText(this, GetText(Resource.String.Lbl_HoldToRecord), ToastLength.Short)?.Show();
                        }
                    }
                    catch (Exception exception)
                    {
                        Methods.DisplayReportResultTrack(exception);
                    }

                    BtnVoice.Pressed = false;
                    handled          = true;
                }

                e.Handled = handled;
            }
            catch (Exception exception)
            {
                Methods.DisplayReportResultTrack(exception);
            }
        }
示例#2
0
        private void BtnVoiceOnTouch(object sender, View.TouchEventArgs e)
        {
            try
            {
                var handled = false;

                if (e.Event.Action == MotionEventActions.Up)
                {
                    try
                    {
                        if (IsRecording)
                        {
                            RecorderService.StopRecourding();
                            PathVoice = RecorderService.GetRecorded_Sound_Path();

                            BtnVoice.SetColorFilter(Color.ParseColor(AppSettings.MainColor));
                            BtnVoice.SetImageResource(Resource.Drawable.microphone);

                            if (TextRecorder == "Recording")
                            {
                                if (!string.IsNullOrEmpty(PathVoice))
                                {
                                    Bundle bundle = new Bundle();
                                    bundle.PutString("FilePath", PathVoice);
                                    RecordSoundFragment.Arguments = bundle;
                                    ReplaceTopFragment(RecordSoundFragment);
                                }

                                TextRecorder = "";
                            }

                            IsRecording = false;
                        }
                    }
                    catch (Exception exception)
                    {
                        Console.WriteLine(exception);
                    }

                    BtnVoice.Pressed = false;
                    handled          = true;
                }

                e.Handled = handled;
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception);
            }
        }