Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Example of how to implement audio recorder in your Xamarin.Forms applications. - http://julianocustodio.com/gravar-audio
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