Exemplo n.º 1
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.new_note_layout);
            FindViewById <Button>(Resource.Id.btnPostPrivateNote).Click += Insert;

            FindViewById <Button>(Resource.Id.btncolor8).Click  += Color8;
            FindViewById <Button>(Resource.Id.btncolor9).Click  += Color9;
            FindViewById <Button>(Resource.Id.btncolor10).Click += Color10;
            FindViewById <Button>(Resource.Id.btncolor11).Click += Color11;

            FindViewById <Button>(Resource.Id.btnbacktoprofile).Click += (s, args) => {
                try
                {
                    MediaRecorder.Stop(); MediaRecorder.Release(); MediaRecorder.Dispose(); MediaRecorder = null;
                    Toast.MakeText(this, "Recording was cancelled", ToastLength.Short).Show();
                }
                catch (System.NullReferenceException)
                {
                    StartActivity(typeof(MainActivity));
                }
            };
            FindViewById <EditText>(Resource.Id.privatenotetext).TextChanged        += OnTextChange;
            FindViewById <EditText>(Resource.Id.txtPrivateNoteTagName).TextChanged  += OnTextTagChange;
            FindViewById <EditText>(Resource.Id.PrivateNoteBorderColor).TextChanged += OnTextBorderColorChange;
            FindViewById <Button>(Resource.Id.btnRecordingAction).Click             += NewRecord;



            // Create your application here
        }
 public void Pause()
 {
     if (_recorder != null && _isRecording)
     {
         _recorder.Stop();
         _isRecording = false;
     }
 }
Exemplo n.º 3
0
        public void StopRecord()
        {
            if (_isRecording)
            {
                if (_textureView != null)
                {
                    _textureView.Visibility = ViewStates.Invisible;
                }
                // 録画終了
                _recorder.Stop();
                _recorder.Reset();
                _recorder.Release();
                _recorder = null;

                if (_linearLayout != null)
                {
                    ((ViewGroup)_linearLayout.Parent).RemoveView(_linearLayout);
                    _linearLayout.Dispose();
                    _linearLayout = null;
                }

                if (_listener != null)
                {
                    _listener.StopCamera2();
                    _listener.Dispose();
                    _listener = null;
                }

                _isRecording = false;
            }
        }
Exemplo n.º 4
0
 // 释放资源
 public void Release()
 {
     _mRecorder.Stop();
     _mRecorder.Release();
     _mRecorder.Dispose();
     _mRecorder = null;
 }
Exemplo n.º 5
0
 public string StopRecord()
 {
     _recorder.Stop();
     _recorder.Reset();
     _recorder.Release();
     return(sFileName);
 }
Exemplo n.º 6
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            SetContentView(Resource.Layout.Main);

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

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

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

                _recorder.SetAudioSource(AudioSource.Mic);
                _recorder.SetOutputFormat(OutputFormat.ThreeGpp);
                _recorder.SetAudioEncoder(AudioEncoder.AmrNb);
                _recorder.SetOutputFile(path);
                _recorder.Prepare();
                _recorder.Start();
            };

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

                _recorder.Stop();
                _recorder.Reset();

                _player.SetDataSource(path);
                _player.Prepare();
                _player.Start();
            };
        }
Exemplo n.º 7
0
        private void RecordBtn_Click(object sender, EventArgs e)
        {
            recording = !recording;

            if (recording)
            {
                // Start recording
                recorder.SetAudioSource(AudioSource.Mic);
                recorder.SetOutputFormat(OutputFormat.Mpeg4);
                recorder.SetAudioEncoder(AudioEncoder.Aac);
                recorder.SetAudioSamplingRate(44100);
                recorder.SetAudioEncodingBitRate(96000);
                recorder.SetOutputFile(filePath);
                recorder.Prepare();
                recorder.Start();

                recordBtn.Text = Resources.GetString(Resource.String.StopBtn);
                image.Alpha    = 1f;
                clockThread    = new Thread(UpdateClock);
                clockThread.Start();
            }
            else
            {
                // Stop recording
                recorder.Stop();
                recorder.Reset();

                recordBtn.Text = Resources.GetString(Resource.String.StartBtn);
                image.Alpha    = LowAlpha;
                clockThread.Join();

                PlaybackAcceptPopup();
            }
        }
Exemplo n.º 8
0
 public string Stop()
 {
     recorder.Stop();
     recorder.Release();
     isRecording = false;
     return(Path.Combine(mainPath, "audio.wav"));;
 }
        public void StopRecording()
        {
            if (recorder == null)
            {
                return;
            }
            try
            {
                recorder.Stop();
                recorder.Reset();
                recorder.Release();

                if (timer != null && timer.Enabled)
                {
                    timer.Stop();
                }

                if (File.Exists(filePath))
                {
                    byte[] note = File.ReadAllBytes(filePath);
                    OnRecordingCompleted?.Invoke(note, null);
                }
            }
            catch (Exception ex)
            {
                EbLog.Error(ex.Message);
            }
        }
Exemplo n.º 10
0
        public static void Stop()
        {
            _recordingDialog?.Dismiss();
            _recordingDialog = null;

            // stop recording
            try
            {
                _mic.Stop();
            }
            catch (Exception e)
            {
                Device.Log.Warn(e);
            }

            // prepare object for GC by calling dispose
            _mic.Release();
            _mic.Dispose();
            _mic = null;

            if (_callback != null)
            {
                DroidFactory.Navigate(new Link(_callback, new Dictionary <string, string>
                {
                    { CallbackParam, _callbackId },
                }));
            }
        }
Exemplo n.º 11
0
 public void stop()
 {
     if (mStreaming)
     {
         try {
             if (mMode == MODE_MEDIARECORDER_API)
             {
                 mMediaRecorder.Stop();
                 mMediaRecorder.Release();
                 mMediaRecorder = null;
                 closeSockets();
                 mPacketizer.stop();
             }
             else
             {
                 mPacketizer.stop();
                 mMediaCodec.Stop();
                 mMediaCodec.Release();
                 mMediaCodec = null;
             }
         } catch (Exception e) {
             System.Diagnostics.Trace.WriteLine(e.StackTrace.ToString());
         }
         mStreaming = false;
     }
 }
Exemplo n.º 12
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            SetContentView(Resource.Layout.Main);

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

            string path = Android.OS.Environment.ExternalStorageDirectory.AbsolutePath + "/test.mp4";


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

                _recorder.SetAudioSource(AudioSource.Mic);
                _recorder.SetOutputFormat(OutputFormat.ThreeGpp);
                _recorder.SetAudioEncoder(AudioEncoder.AmrNb);
                _recorder.SetOutputFile(path);
                _recorder.Prepare();
                _recorder.Start();
            };

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

                _recorder.Stop();
                _recorder.Reset();

                _player.SetDataSource(path);
                _player.Prepare();
                _player.Start();
            };
        }
Exemplo n.º 13
0
        private void ToggleFlashButtonTapped(object sender, EventArgs e)
        {
            if (recorder != null)
            {
                recorder.Stop();
                recorder.Release();
            }
            //flashOn = !flashOn;
            //if (flashOn) {
            //	if (cameraType == CameraFacing.Back) {
            //		toggleFlashButton.SetBackgroundResource (Resource.Drawable.FlashButton);
            //		cameraType = CameraFacing.Back;

            //		camera.StopPreview ();
            //		camera.Release ();
            //		camera = global::Android.Hardware.Camera.Open ((int) cameraType);
            //		var parameters = camera.GetParameters ();
            //		parameters.FlashMode = global::Android.Hardware.Camera.Parameters.FlashModeTorch;
            //		camera.SetParameters (parameters);
            //		camera.SetPreviewTexture (surfaceTexture);
            //		PrepareAndStartCamera ();
            //	}
            //} else {
            //	toggleFlashButton.SetBackgroundResource (Resource.Drawable.NoFlashButton);
            //	camera.StopPreview ();
            //	camera.Release ();

            //	camera = global::Android.Hardware.Camera.Open ((int) cameraType);
            //	var parameters = camera.GetParameters ();
            //	parameters.FlashMode = global::Android.Hardware.Camera.Parameters.FlashModeOff;
            //	camera.SetParameters (parameters);
            //	camera.SetPreviewTexture (surfaceTexture);
            //	PrepareAndStartCamera ();
            //}
        }
Exemplo n.º 14
0
        protected override IEnumerable <Datum> Poll(CancellationToken cancellationToken)
        {
            MediaRecorder recorder = null;

            try
            {
                recorder = new MediaRecorder();
                recorder.SetAudioSource(AudioSource.Mic);
                recorder.SetOutputFormat(OutputFormat.ThreeGpp);
                recorder.SetAudioEncoder(AudioEncoder.AmrNb);
                recorder.SetOutputFile("/dev/null");
                recorder.Prepare();
                recorder.Start();

                // mark start time of amplitude measurement -- MaxAmplitude is always computed from previous call to MaxAmplitude
                int dummy = recorder.MaxAmplitude;

                Thread.Sleep(SampleLengthMS);

                return(new Datum[] { new SoundDatum(DateTimeOffset.UtcNow, 20 * Math.Log10(recorder.MaxAmplitude)) });  // http://www.mathworks.com/help/signal/ref/mag2db.html
            }
            finally
            {
                if (recorder != null)
                {
                    try { recorder.Stop(); }
                    catch (Exception) { }

                    try { recorder.Release(); }
                    catch (Exception) { }
                }
            }
        }
Exemplo n.º 15
0
        public void RecordingFunction(string Action, string Userid)
        {
            if (Action == "Start")
            {
                try
                {
                    var dir = Android.OS.Environment.GetExternalStoragePublicDirectory(Android.OS.Environment.DirectoryDcim);
                    SoundFile = GetTimestamp(DateTime.Now) + ".mp3";
                    var DirectoryPath =
                        new Java.IO.File(dir + "/" + WowonderPhone.Settings.ApplicationName + "/" + SoundFile);
                    if (!Directory.Exists(dir + "/" + WowonderPhone.Settings.ApplicationName))
                    {
                        Directory.CreateDirectory(dir + "/" + WowonderPhone.Settings.ApplicationName);
                    }

                    recorder = new MediaRecorder();
                    recorder.Reset();
                    recorder.SetAudioSource(AudioSource.Mic);
                    recorder.SetOutputFormat(OutputFormat.Default);
                    recorder.SetAudioEncoder(AudioEncoder.AmrNb);
                    recorder.SetOutputFile(DirectoryPath.AbsolutePath);
                    recorder.Prepare();
                    recorder.Start();
                }
                catch (Exception)
                {
                }
            }
            else
            {
                recorder.Stop();
                recorder.Release();
            }
        }
Exemplo n.º 16
0
 private void CaptureBtn_Click(object sender, EventArgs e)
 {
     if (recording)
     {
         mediaRecorder.Stop();
         ReleaseMediaRecorder();
         recording = false;
         ((CameraActivity)Activity).ReturnWithFile(outputPath);
     }
     else
     {
         if (!PrepareMediaRecorder())
         {
             Toast.MakeText(Activity, Resource.String.errorCamera, ToastLength.Long).Show();
             Activity.Finish();
         }
         else
         {
             try
             {
                 mediaRecorder.Start();
                 recording = true;
             }
             catch (Exception ex)
             {
                 Console.WriteLine(ex.Message);
             }
         }
     }
 }
Exemplo n.º 17
0
 public void StopRecorder()
 {
     if (recoder != null)
     {
         recoder.Stop();
         recoder.Release();
     }
 }
Exemplo n.º 18
0
 public void StopRecorder()
 {
     if (_recorder != null)
     {
         _recorder.Stop();
         _recorder.Release();
         _recorder = null;
     }
 }
 public void StopRecording()
 {
     if (recorder != null)
     {
         recorder.Stop();
         recorder.Release();
         recorder = null;
     }
 }
 public void StopRecord()
 {
     recorder.Stop();
     recorder.Reset();
     if (mCamera != null)
     {
         mCamera.Lock();
     }
 }
Exemplo n.º 21
0
 public static void StopRecording()
 {
     if (_recorder != null)
     {
         _recorder.Stop();
         _recorder.Release();
         _recorder.Dispose();
     }
 }
Exemplo n.º 22
0
        private void StopRecording()
        {
            timer.Stop();
            timer.Visibility = ViewStates.Invisible;
            //--------------------------------------------------
            isVideoStarted = false;
            recorder.Stop();
            recorder.Release();
            camera.Lock();
            camera.StopPreview();
            camera.Release();


            FileInputStream inputStream = null;

            inputStream = new FileInputStream(path);
            byte[] bytes;
            byte[] buffer = new byte[8192];
            int    bytesRead;


            ByteArrayOutputStream output = new ByteArrayOutputStream();

            try
            {
                while ((bytesRead = inputStream.Read(buffer)) != -1)
                {
                    output.Write(buffer, 0, bytesRead);
                }
            }
            catch (Java.Lang.Exception exception)
            {
                //  e.PrintStackTrace();
            }
            bytes = output.ToByteArray();
            string attachedFile = Base64.EncodeToString(bytes, Base64.Default);

            captureButton.RemoveFromParent();

            //on the CameraPage you can get base64 and video path
            MessagingCenter.Send <string, string>("VideoBase64Ready", "VideoIsReady", attachedFile);

            MessagingCenter.Send <string, string>("VideoPathReady", "VideoPathReady", path);
        }
Exemplo n.º 23
0
        private void StopRecorder()
        {
            mediaRecorder.Stop();
            btnRecord.Enabled     = true;
            btnStopRecord.Enabled = false;
            btnStopPlay.Enabled   = false;
            btnPlay.Enabled       = true;

            Toast.MakeText(this, "Stop Recording...", ToastLength.Short).Show();
        }
Exemplo n.º 24
0
 public void StopRecord()
 {
     if (recorder != null)
     {
         recorder.Stop();
         recorder.Release();
         camera.StopPreview();
         camera.Release();
     }
 }
Exemplo n.º 25
0
 public void stoprecorder()
 {
     // _stop.Enabled = !_stop.Enabled;
     _recorder.Stop();
     _recorder.Reset();
     _player.SetDataSource(filePath);
     _player.Prepare();
     _player.Start();
     //mikestop.Visibility = ViewStates.Invisible;
 }
Exemplo n.º 26
0
 public void StopRecording(bool Flag)
 {
     try
     {
         mMediaRecorder.Stop();
     }
     catch (Exception ex)
     {
     }
 }
Exemplo n.º 27
0
 void StopRecording()
 {
     if (_isrecording)
     {
         _isrecording = false;
         _recorder.Stop();
         _recorder.Reset();
         LOG_EVENT("STOP_RECORDING");
     }
 }
 public void StopRecording()
 {
     if (_recorder == null)
     {
         return;
     }
     _recorder.Stop();
     _recorder.Release();
     _recorder = null;
 }
Exemplo n.º 29
0
 public void StopRecord()
 {
     try
     {
         recorder?.Stop();
     }
     catch (Exception)
     {
     }
 }
Exemplo n.º 30
0
        public Task <AudioRecording> StopAsync()
        {
            if (isRecording)
            {
                mediaRecorder.Stop();
                mediaRecorder.Reset();
            }

            return(Task.FromResult(GetRecording()));
        }