Beispiel #1
0
        /// <summary>
        /// Starts recording audio.
        /// </summary>
        /// <returns>A <see cref="Task"/> that will complete when recording is finished.
        /// The task result will be the path to the recorded audio file, or null if no audio was recorded.</returns>
        public async Task <Task <string> > StartRecording()
        {
            if (FilePath == null)
            {
                FilePath = await GetDefaultFilePath();
            }

            ResetAudioDetection();
            OnRecordingStarting();

            InitializeStream(PreferredSampleRate);

            await recorder.StartRecorder(audioStream, FilePath);

            AudioStreamDetails = new AudioStreamDetails
            {
                ChannelCount  = audioStream.ChannelCount,
                SampleRate    = audioStream.SampleRate,
                BitsPerSample = audioStream.BitsPerSample
            };

            startTime  = DateTime.Now;
            recordTask = new TaskCompletionSource <string> ();

            Debug.WriteLine("AudioRecorderService.StartRecording() complete.  Audio is being recorded.");

            return(recordTask.Task);
        }
Beispiel #2
0
        /// <summary>
        /// Starts recording audio.
        /// </summary>
        /// <returns>A <see cref="Task"/> that will complete when recording is finished.
        /// The task result will be the path to the recorded audio file, or null if no audio was recorded.</returns>
        public async Task <Task <string> > StartRecording()
        {
            ResetAudioDetection();

            InitializeStream(PreferredSampleRate);

            await recorder.StartRecorder(audioStream, filePath);

            AudioStreamDetails = new AudioStreamDetails
            {
                ChannelCount  = audioStream.ChannelCount,
                SampleRate    = audioStream.SampleRate,
                BitsPerSample = audioStream.BitsPerSample
            };

            startTime  = DateTime.Now;
            recordTask = new TaskCompletionSource <string> ();

            System.Diagnostics.Debug.WriteLine("AudioRecorderService.StartRecording() complete.  Audio is being recorded.");

            return(recordTask.Task);
        }