public void Stop()
 {
     if (_recorder != null)
     {
         _recorder.Stop();
         ClearTimer();
     }
 }
示例#2
0
        public static void StopBackgroundMode()
        {
            if (audioRecorder.Recording)
            {
                audioRecorder.Stop();
            }

            if (File.Exists(Manager.AudioFile))
            {
                File.Delete(Manager.AudioFile);
            }
        }
            public byte[] StopRecord()
            {
                if (_recorder == null || !_isRecord)
                {
                    return(default(byte[]));
                }

                _recorder.Stop();
                _isRecord = false;


                var bytes = default(byte[]);

                using (var streamReader = new StreamReader(_path))
                {
                    using (var memstream = new MemoryStream())
                    {
                        streamReader.BaseStream.CopyTo(memstream);
                        bytes = memstream.ToArray();
                    }
                }

                File.Delete(_path);

                return(bytes);
            }
示例#4
0
 public void Stop()
 {
     if (recorder != null)
     {
         recorder.Stop();
     }
 }
示例#5
0
 public string StopRecord()
 {
     recorder.Stop();
     recorder.Dispose();
     recorder = null;
     return(sFileName);
 }
示例#6
0
        public static void StopBackgroundMode()
        {
            BackgroundTypes mode = (BackgroundTypes)(int)NSUserDefaults.StandardUserDefaults.IntForKey(UserDefaultsKeys.BackgroundModeType);

            switch (mode)
            {
            case BackgroundTypes.Microphone:
                if (audioRecorder != null && audioRecorder.Recording)
                {
                    audioRecorder.Stop();
                }

                if (File.Exists(Manager.AudioFile))
                {
                    File.Delete(Manager.AudioFile);
                }
                break;

            case BackgroundTypes.Music:
                if (audioObserver != null)
                {
                    NSNotificationCenter.DefaultCenter.RemoveObserver(audioObserver);
                    audioObserver = null;
                    audioPlayer.Stop();
                }
                break;
            }
            backgroundRunning = false;
        }
示例#7
0
        protected override bool NativeStopRecording()
        {
            AudioRecorder?.Stop();
            AudioRecorder = null;

            return(true);
        }
        partial void RecButtonPressed(NSObject sender)
        {
            Console.WriteLine("Pressed button");
            if (!recording)
            {
                Console.WriteLine("Starting recording");
                ImageService.Instance.LoadCompiledResource("StopButton").Into(RecButton);
                recorder.Record();
                recording   = true;
                clockThread = new Thread(UpdateClock);
                clockThread.Start();
            }
            else
            {
                Console.WriteLine("stopping recording");
                recorder.Stop();
                ImageService.Instance.LoadCompiledResource("RecordButton").IntoAsync(RecButton);
                recording = false;
                clockThread.Join();

                Console.WriteLine("Saved audio to: " + filePath);

                innerPath = Path.Combine(Directory.GetParent(filePath).Name, Path.GetFileName(filePath));

                if (createMode)
                {
                    PerformSegue("UnwindToCreateListenAudio", this);
                }
                else
                {
                    ReturnWithData(innerPath);
                }
            }
        }
示例#9
0
        public void Stop()
        {
            _cts?.Cancel();
            _recorder.Stop();

            byte[] audioBytes = null;
            if (_options.StreamFormat == AudioRecordOptions.Format.Wave)
            {
                audioBytes = File.ReadAllBytes(_audioFilePath);
            }
            else if (_options.StreamFormat == AudioRecordOptions.Format.Flac)
            {
                // encode audio into flac
                using (var fr = File.OpenRead(_audioFilePath))
                {
                    using (var ms = new MemoryStream())
                    {
                        using (var what = new WaveOverFlacStream(ms, WaveOverFlacStreamMode.Encode, true))
                        {
                            fr.CopyTo(what);
                        }

                        ms.Flush();
                        ms.Seek(0, SeekOrigin.Begin);
                        audioBytes = ms.ToArray();
                    }
                }
            }

            File.Delete(_audioFilePath);

            _tcs.TrySetResult(new AudioRecordResult(audioBytes));
        }
示例#10
0
        public Task <AudioRecording> StopAsync()
        {
            recorder.Stop();

            var recording = new AudioRecording(recorder.Url.Path);

            return(Task.FromResult(recording));
        }
 public void StopRecording()
 {
     if (recorder == null)
     {
         throw new Exception("Start recording first.");
     }
     recorder.Stop();
 }
示例#12
0
 public static void StopRecording(Action finishedRecording)
 {
     _recorder.Stop();
     _recorder.FinishedRecording += delegate {
         _recorder.Dispose();
         finishedRecording();
     };
 }
示例#13
0
 /// <summary>
 /// Stops recording and sets session back to playback mode.
 /// </summary>
 public void StopRecording()
 {
     if (recorder != null)
     {
         Console.WriteLine("stopped recording");
         recorder.Stop();
         AVAudioSession.SharedInstance().SetCategory(AVAudioSession.CategoryPlayback, out NSError error);
     }
 }
示例#14
0
        public void StopRecording()
        {
            if (recorder == null)
            {
                throw new Exception("You must first start recording.");
            }

            recorder.Stop();
        }
示例#15
0
 public void StopRecording()
 {
     if (_recorder == null)
     {
         return;
     }
     _recorder.Stop();
     _recorder = null;
 }
示例#16
0
        public Recording StopRecording()
        {
            _recorder.Stop();
            Recording r = new Recording();

            r.CreationTime = DateTime.Now;
            r.FileName     = _audioFileName;
            r.FilePath     = _audioFilePath;
            return(r);
        }
示例#17
0
        public string StopRecording()
        {
            if (_recorder == null)
            {
                throw new Exception("You must first start recording.");
            }

            _recorder.Stop();
            return(_currentRecordUrl.Path);
        }
示例#18
0
        partial void StopRecording(UIButton sender)
        {
            if (recorder != null)
            {
                recorder.Stop();
                stopwatch?.Stop();

                Status = Status.Recorded;
            }
        }
示例#19
0
 public void RecordStop()
 {
     System.Diagnostics.Debug.WriteLine("*** AudioService.RecordStop - Preparing to end recording");
     if (!_Recorder.Recording)
     {
         return;
     }
     System.Diagnostics.Debug.WriteLine("*** AudioService.RecordStop - Stopping");
     _Recorder.Stop();
 }
示例#20
0
 ///
 /// Name            AudioRecordStop
 ///
 /// <summary>       Stop the recoreder if it is in recording.
 /// </summary>
 ///
 public void AudioRecordStop()
 {
     try
     {
         recorder?.Stop();
     }
     catch (Exception ex)
     {
         LogTracking.LogTrace(ex.ToString());
     }
 }
        void OnStopRecording(object sender, EventArgs e)
        {
            recorder.Stop();
            stopwatch.Stop();

            LengthOfRecordingLabel.Text     = string.Format("{0:hh\\:mm\\:ss}", stopwatch.Elapsed);
            RecordingStatusLabel.Text       = "";
            StartRecordingButton.Enabled    = true;
            StopRecordingButton.Enabled     = false;
            PlayRecordedSoundButton.Enabled = true;
        }
示例#22
0
        /// <summary>
        /// Views the will disappear.
        /// </summary>
        /// <param name="animated">If set to <c>true</c> animated.</param>
        public override void ViewWillDisappear(Boolean animated)
        {
            base.ViewDidDisappear(animated);

            //
            if (m_audioPlayer != null)
            {
                m_audioPlayer.Delegate = null;
                m_audioPlayer.Stop();
                m_audioPlayer = null;
            }

            if (m_audioRecorder != null)
            {
                m_audioRecorder.Delegate = null;
                m_audioRecorder.Stop();
                m_audioRecorder = null;
            }
            StopUpdatingMeter();
        }
示例#23
0
        private static void DoneRecording()
        {
            audioRecorder.Stop();

            string path       = Path.GetFileName(audioRecorder.Url.AbsoluteString);
            var    parameters = new Dictionary <string, string>()
            {
                { "AudioId", path }
            };

            iApp.Navigate(callback, parameters);
        }
示例#24
0
 public void StopRecording()
 {
     try
     {
         if (recorder != null)
         {
             recorder.Stop();
             recorder.Dispose();
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
     }
 }
示例#25
0
        public Stream EndCaptureAudio()
        {
            if (_audioRecorder == null)
            {
                return(null);
            }

            _audioRecorder.Stop();

            var path = _audioRecorder.Url.Path;

            return(new DelegateStream(
                       () => File.OpenRead(path),
                       () => File.Delete(path)));
        }
示例#26
0
        public Task <FileData> PlatformStopAsync()
        {
            if (_recorder == null)
            {
                return(Task.FromResult(default(FileData)));
            }

            _recorder.Stop();
            _recorder.Dispose();
            _recorder = null;
            AVAudioSession.SharedInstance().SetActive(false);

            FileInfo fi = new FileInfo(_audioFilePath);

            return(Task.FromResult(new FileData(_audioFilePath, fi.Name, (ulong)fi.Length)));
        }
示例#27
0
        public void StopRecord()
        {
            audioRecorder.Stop();
            bt_Record.SetImage(UIImage.FromBundle("recordbtn"), UIControlState.Normal);
            isRecording = false;
            var audioSession = AVAudioSession.SharedInstance();

            NSError error = audioSession.SetCategory(AVAudioSessionCategory.Playback);

            error = audioSession.SetActive(false);

            if (error != null)
            {
                Console.WriteLine(error.LocalizedDescription);
            }
        }
示例#28
0
        public void Stop()
        {
            if (recorder == null)
            {
                return;
            }

            recorder.Stop();

            NSData audioData = NSData.FromFile(audioFilePath.Path, 0, out NSError error);

            if (error != null)
            {
                Console.WriteLine(error);
                return;
            }

            audioDataBytes = new byte[audioData.Length];
            System.Runtime.InteropServices.Marshal.Copy(audioData.Bytes, audioDataBytes, 0, Convert.ToInt32(audioData.Length));
        }
示例#29
0
        public void Stop(out byte[] fileData)
        {
            try
            {
                recorder.Stop();
                recorder.Dispose();
                //_recorder.Reset();
                //recorder.Release();
                using (var streamReader = new StreamReader(path))
                {
                    var bytes = default(byte[]);
                    using (var memstream = new MemoryStream())
                    {
                        streamReader.BaseStream.CopyTo(memstream);
                        fileData = memstream.ToArray();
                    }
                }
            }
            catch (Exception e)
            {
                string error = e.ToString();
                Console.WriteLine(e);
                fileData = null;
            }


            recorder = null;

            //Bitmap bmThumbnail;
            //bmThumbnail = ThumbnailUtils.CreateVideoThumbnail(path, ThumbnailKind.MiniKind);
            //imageThumbnail.setImageBitmap(bmThumbnail);



            //_player.SetDataSource(path);
            //_player.Prepare();
            //_player.Start();
        }
 public void StopRecording()
 {
     _audioRecorder.Stop();
 }