Created
April 26, 2019 13:14
-
-
Save juucustodio/9c0017e31d7ade7283957cef81913037 to your computer and use it in GitHub Desktop.
Example of how to implement audio recorder in your Xamarin.Forms applications. - http://julianocustodio.com/gravar-audio
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public async void Gravar_Clicked(object sender, EventArgs e) | |
{ | |
try | |
{ | |
if (!gravador.IsRecording) | |
{ | |
gravador.StopRecordingOnSilence = TimeoutSwitch.IsToggled; | |
GravarButton.IsEnabled = false; | |
ReproduzirButton.IsEnabled = false; | |
//Começar gravação | |
var audioRecordTask = await gravador.StartRecording(); | |
GravarButton.Text = "Parar Gravação"; | |
GravarButton.IsEnabled = true; | |
await audioRecordTask; | |
GravarButton.Text = "Gravar"; | |
ReproduzirButton.IsEnabled = true; | |
} | |
else | |
{ | |
GravarButton.IsEnabled = false; | |
//parar a gravação... | |
await gravador.StopRecording(); | |
GravarButton.IsEnabled = true; | |
} | |
} | |
catch (Exception ex) | |
{ | |
await DisplayAlert("Erro", ex.Message, "OK"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment