示例#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
        }
示例#2
0
 public void StopRecord()
 {
     if (recorder != null)
     {
         recorder.Stop();
         recorder.Release();
         camera.StopPreview();
         camera.Release();
     }
 }
示例#3
0
        void StopRecording()
        {
            if (_recorder == null)
            {
                return;
            }
            _recorder.Stop();
            _recorder.Release();
            _recorder = null;

            if (File.Exists(this.GetFileNameForRecording()))
            {
                _startPlaying = true;
            }
        }
示例#4
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 ();
            //}
        }
示例#5
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 },
                }));
            }
        }
示例#6
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;
     }
 }
示例#7
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();
            }
        }
示例#8
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;
            }
        }
示例#9
0
 // 释放资源
 public void Release()
 {
     _mRecorder.Stop();
     _mRecorder.Release();
     _mRecorder.Dispose();
     _mRecorder = null;
 }
        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);
            }
        }
示例#11
0
 public string StopRecord()
 {
     _recorder.Stop();
     _recorder.Reset();
     _recorder.Release();
     return(sFileName);
 }
示例#12
0
        protected override void OnStop()
        {
            _player.Release();
            _recorder.Release();

            base.OnStop();
        }
示例#13
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) { }
                }
            }
        }
示例#14
0
 public string Stop()
 {
     recorder.Stop();
     recorder.Release();
     isRecording = false;
     return(Path.Combine(mainPath, "audio.wav"));;
 }
示例#15
0
 private void ReleaseMediaRecorder()
 {
     if (mediaRecorder != null)
     {
         mediaRecorder.Release();
         mediaRecorder = null;
     }
 }
示例#16
0
        public void Dispose()
        {
            recorder.Release();
            recorder = null;

            player.Release();
            player = null;
        }
示例#17
0
 public void StopRecorder()
 {
     if (recoder != null)
     {
         recoder.Stop();
         recoder.Release();
     }
 }
 public void StopRecording()
 {
     if (recorder != null)
     {
         recorder.Stop();
         recorder.Release();
         recorder = null;
     }
 }
示例#19
0
 public static void StopRecording()
 {
     if (_recorder != null)
     {
         _recorder.Stop();
         _recorder.Release();
         _recorder.Dispose();
     }
 }
示例#20
0
 public void StopRecorder()
 {
     if (_recorder != null)
     {
         _recorder.Stop();
         _recorder.Release();
         _recorder = null;
     }
 }
示例#21
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);
        }
示例#22
0
 private void releaseMediaRecorder()
 {
     if (mediaRecorder != null)
     {
         mediaRecorder.Reset();
         mediaRecorder.Release();
         mediaRecorder = null;
         camera.Lock();
     }
 }
 public void StopRecording()
 {
     if (_recorder == null)
     {
         return;
     }
     _recorder.Stop();
     _recorder.Release();
     _recorder = null;
 }
示例#24
0
 protected override void OnDestroy()
 {
     base.OnDestroy();
     if (recorder != null)
     {
         recorder.Release();
         //recorder.Dispose();
         recorder = null;
     }
 }
示例#25
0
 protected override void OnPause()
 {
     base.OnPause();
     _player.Release();
     _recorder.Release();
     _player.Dispose();
     _recorder.Dispose();
     _player   = null;
     _recorder = null;
 }
示例#26
0
        public override void OnPause()
        {
            base.OnPause();

            player.Release();
            recorder.Release();
            player.Dispose();
            recorder.Dispose();
            player   = null;
            recorder = null;
        }
示例#27
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.VideoRecord);

            var record = FindViewById <Button>(Resource.Id.Record);
            var stop   = FindViewById <Button>(Resource.Id.Stop);
            var play   = FindViewById <Button>(Resource.Id.Play);
            var video  = FindViewById <VideoView>(Resource.Id.SampleVideoView);

            //displaying from camera

            /*Intent intent = new Intent(MediaStore.ActionVideoCapture);
             * StartActivityForResult(intent, 0);*/
            //displaying from camera ENDED

            String timeStamp = GetTimestamp(DateTime.Now);

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

            record.Click += delegate
            {
                video.StopPlayback();

                recorder = new MediaRecorder();
                recorder.SetVideoSource(VideoSource.Camera);
                recorder.SetAudioSource(AudioSource.Mic);
                recorder.SetOutputFormat(OutputFormat.Default);
                recorder.SetVideoEncoder(VideoEncoder.Default);
                recorder.SetAudioEncoder(AudioEncoder.Default);
                recorder.SetOutputFile(path);
                recorder.SetPreviewDisplay(video.Holder.Surface);
                recorder.Prepare();

                recorder.Start();
            };

            stop.Click += delegate
            {
                if (recorder != null)
                {
                    recorder.Stop();
                    recorder.Release();
                }
            };

            play.Click += delegate
            {
                var uri = Android.Net.Uri.Parse(path);
                video.SetVideoURI(uri);
                video.Start();
            };
        }
示例#28
0
 public void StopRecording()
 {
     if (_recorder != null)
     {
         _recorder.Stop();
         _recorder.Release();
         _recorder.Dispose();
         _recorder    = null;
         _isRecording = false;
     }
 }
        public void Release()
        {
            if (_recorder == null)
            {
                return;
            }

            _recorder.Release();
            _recorder.Dispose();
            _recorder = null;
        }
示例#30
0
 protected override void OnDestroy()
 {
     base.OnDestroy();
     mMediaRecorder.Release();
     mMediaRecorder.Dispose();
     mMediaRecorder = null;
     mediaProjection.Stop();
     mediaProjection = null;
     virtualDisplay.Release();
     virtualDisplay = null;
 }