private async void StartRecording() { try { if (BtnVoice.Tag?.ToString() == "Free") { //Set Record Style IsRecording = true; if (UserDetails.SoundControl) { Methods.AudioRecorderAndPlayer.PlayAudioFromAsset("RecourdVoiceButton.mp3"); } if (TextRecorder != null && TextRecorder != "Recording") { TextRecorder = "Recording"; } BtnVoice.SetColorFilter(Color.White); BtnVoice.SetImageResource(Resource.Drawable.ic_stop_white_24dp); AudioPlayerClass = new Methods.AudioRecorderAndPlayer(""); //Start Audio record await Task.Delay(600); AudioPlayerClass.StartRecording(); } } catch (Exception e) { Methods.DisplayReportResultTrack(e); } }
private void RecordCloseButtonClick(object sender, EventArgs e) { try { if (!string.IsNullOrEmpty(RecordFilePath)) { AudioPlayerClass.StopAudioPlay(); } if (UserDetails.SoundControl) { Methods.AudioRecorderAndPlayer.PlayAudioFromAsset("Error.mp3"); } AudioPlayerClass.Delete_Sound_Path(RecordFilePath); RecordLayout.Visibility = ViewStates.Gone; BtnVoice.SetImageResource(0); BtnVoice.Tag = "Free"; RecordFilePath = ""; } catch (Exception exception) { Methods.DisplayReportResultTrack(exception); } }
private void BtnVoiceOnTouch(object sender, View.TouchEventArgs e) { try { var handled = false; if (e?.Event?.Action == MotionEventActions.Up) { try { if (IsRecording) { AudioPlayerClass.StopRecording(); RecordFilePath = AudioPlayerClass.GetRecorded_Sound_Path(); BtnVoice.SetColorFilter(Color.ParseColor(AppSettings.MainColor)); BtnVoice.SetImageResource(0); BtnVoice.Tag = "tick"; if (TextRecorder == "Recording") { if (!string.IsNullOrEmpty(RecordFilePath)) { Console.WriteLine("FilePath" + RecordFilePath); RecordLayout.Visibility = ViewStates.Visible; } TextRecorder = ""; } IsRecording = false; } else { if (UserDetails.SoundControl) { Methods.AudioRecorderAndPlayer.PlayAudioFromAsset("Error.mp3"); } Toast.MakeText(Activity, Activity.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); } }
private void BtnVoiceOnTouch(object sender, View.TouchEventArgs e) { try { var handled = false; if (e.Event.Action == MotionEventActions.Up) { try { if (IsRecording) { AudioPlayerClass.StopRecourding(); RecordFilePath = AudioPlayerClass.GetRecorded_Sound_Path(); BtnVoice.SetColorFilter(Color.ParseColor(AppSettings.MainColor)); BtnVoice.SetImageResource(0); BtnVoice.Tag = "tick"; if (TextRecorder == "Recording") { if (!string.IsNullOrEmpty(RecordFilePath)) { Console.WriteLine("FilePath" + RecordFilePath); RecordLayout.Visibility = ViewStates.Visible; } TextRecorder = ""; } IsRecording = false; } } catch (Exception exception) { Console.WriteLine(exception); } BtnVoice.Pressed = false; handled = true; } e.Handled = handled; } catch (Exception exception) { Console.WriteLine(exception); } }