public async Task Stop(string er=null) { if(!isAudioInizialized) { throw new MicRecorderException("InitializeAudioRecording is not inizialized."); } else if(status == MicRecorderStatus.NotRecording) { throw new MicRecorderException("MicRecorder is not recording."); } else { try { timer.Stop(); await mediaCaptureManager.StopRecordAsync(); status = MicRecorderStatus.NotRecording; } catch(Exception e) { throw new MicRecorderException("Internal Exception", e); } } if(er!=null) { throw new MicRecorderException(er); } }
public async Task Start(StorageFolder folder, string filename) { if(!isAudioInizialized) { throw new MicRecorderException("InitializeAudioRecording is not inizialized."); } else if(status == MicRecorderStatus.Recording) { throw new MicRecorderException("MicRecorder is already recording."); } else { try { timer.Start(); recordStorageFile = await folder.CreateFileAsync(filename + ".m4a", CreationCollisionOption.GenerateUniqueName); MediaEncodingProfile recordProfile = MediaEncodingProfile.CreateM4a(AudioEncodingQuality.Auto); await mediaCaptureManager.StartRecordToStorageFileAsync(recordProfile, this.recordStorageFile); status = MicRecorderStatus.Recording; } catch(Exception e) { throw new MicRecorderException("Internal Exception", e); } } }