I wrote this for a desktop app but the same thing should work pretty much anywhere.
private void RecordAudio()
{
var capture = new MediaCapture();
var settings = new MediaCaptureInitializationSettings();
settings.StreamingCaptureMode = StreamingCaptureMode.Audio;
capture.InitializeAsync(settings).Completed = (info, status) =>
{
StorageFolder folder = KnownFolders.DocumentsLibrary;
var op = folder.CreateFileAsync("sample.mp3", CreationCollisionOption.ReplaceExisting);
op.Completed = (
i, s) =>
{
var file = i.GetResults();
var profile = MediaEncodingProfile.CreateMp3(AudioEncodingQuality.High);
capture.StartRecordToStorageFileAsync(profile, file);
};
};
}