Recording audio with device with xamarin android app.

Hello everyone!

I am making an app for my internship project, and sadly there are no programmers here with any knowledge of apps or c#.

I am trying to make an app which can record sound and put it over an existing video.
First I tried to see if it's even possible at all to record audio, so I tried the sample code given by xamarin. But sadly, even the directly copied code does not work.

(using System;

using Android.App;
using Android.Content;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Android.OS;
using Android.Media;
using System.IO;

namespace test2
[Activity(Label = "test2", MainLauncher = true)]
public class Activity1 : Activity
MediaRecorder _recorder;
MediaPlayer _player;
Button _start;
Button _stop;

    protected override void OnCreate(Bundle savedInstanceState)


        Button _start = FindViewById<Button>(Resource.Id.start);
        Button _stop = FindViewById<Button>(Resource.Id.stop);

        string path = "/sdcard/test.3gpp";

        _start.Click += delegate {
            _stop.Enabled = !_stop.Enabled;
            _start.Enabled = !_start.Enabled;


        _stop.Click += delegate {
            _stop.Enabled = !_stop.Enabled;



    protected override void OnResume()

        _recorder = new MediaRecorder();
        _player = new MediaPlayer();

        _player.Completion += (sender, e) => {
            _start.Enabled = !_start.Enabled;

    protected override void OnPause()


        _player = null;
        _recorder = null;


I am testing on both a Oneplus5 and a Samsung galaxy s7.

Anyone else having this problem or a solution?

Sign In or Register to comment.