private async void RecordButton_Clicked(object sender, EventArgs e) { XAudioButton btn = (XAudioButton)sender; if (btn.ActionType == ACTION_START) { if (await AppPermission.Audio()) { RecordingTimerLabel.IsVisible = true; await audioHelper.StartRecording(); StartRecordingTimer(); SetStopRecordButtonSyle(); } else { Utils.Toast("Microphone permission revoked"); } } else { audioHelper.StopRecording(); SetRecordButtonSyle(); } }
public View CreateView() { Frame container = new Frame { Style = (Style)HelperFunctions.GetResourceValue("AudioRecordFrame") }; var containerInner = new StackLayout { Orientation = Xamarin.Forms.StackOrientation.Horizontal }; slider = new Slider() { Style = (Style)HelperFunctions.GetResourceValue("AudioPlaySlider") }; slider.ValueChanged += SliderPostionValueChanged; playButton = new XAudioButton { Style = (Style)HelperFunctions.GetResourceValue("AudioPlayButton"), Name = Name, Text = "\uf04b", ActionType = ACTION_START, }; playButton.Clicked += PlayButtonClicked; lengthLabel = new Label { VerticalOptions = LayoutOptions.Center, Text = $"0/{(int)player.Duration}", FontSize = 13 }; containerInner.Children.Add(playButton); containerInner.Children.Add(slider); containerInner.Children.Add(lengthLabel); if (AllowDelete) { Button delete = new Button { VerticalOptions = LayoutOptions.Center, Style = (Style)HelperFunctions.GetResourceValue("AudioPlayButton"), HorizontalOptions = LayoutOptions.End, Text = "\uf1f8", TextColor = Color.Red }; delete.Clicked += Delete_Clicked; containerInner.Children.Add(delete); } container.Content = containerInner; return(container); }