Exemplo n.º 1
0
        public async Task <bool> StartRecording()
        {
            recorder.Reset();
            recorder.SetAudioSource(AudioSource.VoiceCall);
            recorder.SetOutputFormat(OutputFormat.ThreeGpp);
            recorder.SetAudioEncoder(AudioEncoder.Aac);
            recorder.SetOutputFile("/sdcard/Download/123.3gpp");
            recorder.Prepare();
            recorder.Start();

            return(true);
        }
Exemplo n.º 2
0
 private void SetRecorderProperties()
 {
     recorder = new MediaRecorder();
     recorder.SetCamera(camera);
     recorder.SetVideoSource(VideoSource.Camera);
     recorder.SetAudioSource(AudioSource.Mic);
     recorder.SetOutputFormat(OutputFormat.Mpeg4);
     recorder.SetVideoEncoder(VideoEncoder.H264);
     recorder.SetAudioEncoder(AudioEncoder.AmrNb);
     recorder.SetOutputFile(path);
     recorder.SetOrientationHint(90);
 }
        /// <summary>
        /// Records the audio input to a file (into the specefied folder(s))
        /// using a date time format as its name
        /// and in an mp3 file format.
        /// </summary>
        public void Record()
        {
            string fileName = Generic.GetDateTimeNow("DD-MM-YY_HH-mm-ss");

            _mediaRecorder = new MediaRecorder();
            _mediaRecorder.SetAudioSource(AudioSource.Mic);
            _mediaRecorder.SetOutputFormat(OutputFormat.Mpeg4);
            _mediaRecorder.SetOutputFile(musicDirAbsPath + DEFAULT_RECORDING_DIRECTORY + fileName + DEFAULT_RECORDING_FORMAT);
            _mediaRecorder.SetAudioEncoder(AudioEncoder.Aac);
            _mediaRecorder.Prepare();
            _mediaRecorder.Start();
        }
Exemplo n.º 4
0
 public void Record()
 {
     CheckForPermissions();
     _mediaRecorder = new MediaRecorder();
     _mediaRecorder.Reset();
     _mediaRecorder.SetAudioSource(AudioSource.Mic);
     _mediaRecorder.SetOutputFormat(OutputFormat.Mpeg2Ts);
     _mediaRecorder.SetOutputFile(GetFileName());
     _mediaRecorder.SetAudioEncoder(AudioEncoder.Aac);
     _mediaRecorder.Prepare();
     _mediaRecorder.Start();
 }
Exemplo n.º 5
0
 public void startRecording(string mFileName)
 {
     mRecorder = new MediaRecorder();
     mRecorder.SetAudioSource(AudioSource.Mic);
     mRecorder.SetOutputFormat(OutputFormat.ThreeGpp);
     mRecorder.SetAudioEncoder(AudioEncoder.AmrNb);
     // Initialized state.
     mRecorder.SetOutputFile(Path.Combine(FilePath, mFileName));
     // DataSourceConfigured state.
     mRecorder.Prepare();            // Prepared state
     mRecorder.Start();              // Recording state.
 }
Exemplo n.º 6
0
 public Task PlatformRecordAsync()
 {
     _recorder = new MediaRecorder();
     _recorder.SetAudioSource(AudioSource.Mic);
     _recorder.SetOutputFormat(OutputFormat.Mpeg4);
     _recorder.SetAudioEncoder(AudioEncoder.Aac);
     _audioFilePath = Path.Combine(Kit.CachePath, Kit.NewGuid + ".m4a");
     _recorder.SetOutputFile(_audioFilePath);
     _recorder.Prepare();
     _recorder.Start();
     return(Task.CompletedTask);
 }
Exemplo n.º 7
0
        public void StartRecord()
        {
            var video = Activity.FindViewById <VideoView>(Resource.Id.videoView1);

            video.StopPlayback();

            var documents = System.Environment.GetFolderPath(System.Environment.SpecialFolder.MyDocuments);
            var filename  = System.IO.Path.Combine(documents, write_sequence.ToString() + ".MP4");

            File.Delete(filename);

            var cameraParameters      = camera.GetParameters();
            var supportedSizes        = cameraParameters.SupportedVideoSizes;
            var supportedPreviewSizes = cameraParameters.SupportedPreviewSizes;

            //        cameraParameters.Zoom = 30;

            camera.Unlock();

            recorder?.Release();
            recorder = null;

            recorder = new MediaRecorder();
            recorder.SetCamera(camera);

            recorder.SetVideoSource(VideoSource.Camera);
            recorder.SetAudioSource(AudioSource.Camcorder);
            recorder.SetOutputFormat(OutputFormat.Mpeg4);

            recorder.SetVideoSize(supportedSizes[0].Width, supportedSizes[0].Height);

            recorder.SetVideoEncoder(VideoEncoder.Mpeg4Sp);
            recorder.SetAudioEncoder(AudioEncoder.AmrNb);


            // Change the stream to your stream of choice.



            //((AudioManager)activity.getApplicationContext().getSystemService(Context.AUDIO_SERVICE)).setStreamMute(AudioManager.STREAM_ALARM, true);
            //((AudioManager)activity.getApplicationContext().getSystemService(Context.AUDIO_SERVICE)).setStreamMute(AudioManager.STREAM_DTMF, true);
            //((AudioManager)activity.getApplicationContext().getSystemService(Context.AUDIO_SERVICE)).setStreamMute(AudioManager.STREAM_MUSIC, true);
            //((AudioManager)activity.getApplicationContext().getSystemService(Context.AUDIO_SERVICE)).setStreamMute(AudioManager.STREAM_RING, true);
            //((AudioManager)activity.getApplicationContext().getSystemService(Context.AUDIO_SERVICE)).setStreamMute(AudioManager.STREAM_SYSTEM, true);
            //((AudioManager)activity.getApplicationContext().getSystemService(Context.AUDIO_SERVICE)).setStreamMute(AudioManager.STREAM_VOICE_CALL, true);

            recorder.SetPreviewDisplay(video.Holder.Surface);

            recorder.SetOutputFile(filename);
            recorder.Prepare();
            recorder.Start();
        }
Exemplo n.º 8
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.criticaGUI);
            TextView nomeRestaurante = FindViewById <TextView>(Resource.Id.textView3);
            string   nome            = Intent.GetStringExtra("restaurante");

            nomeRestaurante.Text = nome;

            // Create intent to Open Image applications like Gallery, Google Photos
            Button imagem = FindViewById <Button>(Resource.Id.button1);

            _start = FindViewById <Button>(Resource.Id.button2);
            _stop  = FindViewById <Button>(Resource.Id.button3);
            string path = "/storage/emulated/0/SaboresPortugal/" + nome + ".3gpp";


            imagem.Click += (sender, e) =>
            {
                // Start the Intent
                var imageIntent = new Intent();
                imageIntent.SetType("image/*");
                imageIntent.SetAction(Intent.ActionGetContent);
                StartActivityForResult(
                    Intent.CreateChooser(imageIntent, "Select photo"), 0);
            };

            _start.Click += (sender, e) =>
            {
                _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 += (sender, e) =>
            {
                _stop.Enabled = !_stop.Enabled;

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

                _player.SetDataSource(path);
                _player.Prepare();
                _player.Start();
            };
        }
Exemplo n.º 9
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // Create your application here

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.frmVideo);
            btnGravar = (Button)FindViewById(Resource.Id.btnGravar);
            btnVoltar = (Button)FindViewById(Resource.Id.btnVoltar);
            btnParar  = (Button)FindViewById(Resource.Id.btnParar);
            btnTocar  = (Button)FindViewById(Resource.Id.btnTocar);
            video     = (VideoView)FindViewById(Resource.Id.video);
            string path = Android.OS.Environment.ExternalStorageDirectory.AbsolutePath + "/teste.mp4";

            btnGravar.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();
            };

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

            btnTocar.Click += delegate
            {
                var uri = Android.Net.Uri.Parse(path);
                video.SetVideoURI(uri);
                video.Start();
            };
            btnVoltar.Click += (sender, e) =>
            {
                Intent intent = new Intent(this, typeof(MainActivity));
                StartActivity(intent);
            };
        }
Exemplo n.º 10
0
        void StartRecording()
        {
            _recorder    = new MediaRecorder();
            _isrecording = true;
            // Set how we want the audio formatting to be.
            _recorder.SetAudioSource(AudioSource.Mic);
            _recorder.SetOutputFormat(OutputFormat.AmrNb);
            _recorder.SetAudioEncoder(AudioEncoder.AmrNb);

            _recorder.SetOutputFile(_path);
            _recorder.Prepare();
            _recorder.Start();
            LOG_EVENT("START_RECORDING");
        }
        public void StartRecord()
        {
            //if (ContextCompat.CheckSelfPermission(, Manifest.Permission.RecordAudio) != Permission.Granted)
            //{
            //    ActivityCompat.RequestPermissions(this, new String[] { Manifest.Permission.RecordAudio }, 1);
            //}

            Recorder.SetAudioSource(AudioSource.Mic);
            Recorder.SetOutputFormat(OutputFormat.ThreeGpp);
            Recorder.SetAudioEncoder(AudioEncoder.AmrNb);
            Recorder.SetOutputFile(AudioFilePath + "/" + AudioFileName + ".wav");
            Recorder.Prepare();
            Recorder.Start();
        }
        private void startRecordingVideo()
        {
            if (null == Activity)
            {
                return;
            }


            media_recorder = new MediaRecorder();
            File file = getVideoFile(Activity);

            try {
                //UI
                button_video.SetText(Resource.String.stop);
                is_recording_video = true;

                //Configure the MediaRecorder
                media_recorder.SetAudioSource(AudioSource.Mic);
                media_recorder.SetVideoSource(VideoSource.Surface);
                media_recorder.SetOutputFormat(OutputFormat.Mpeg4);
                media_recorder.SetOutputFile(System.IO.Path.GetFullPath(file.ToString()));
                media_recorder.SetVideoEncodingBitRate(10000000);
                media_recorder.SetVideoFrameRate(30);
                media_recorder.SetVideoSize(1440, 1080);
                media_recorder.SetVideoEncoder(VideoEncoder.H264);
                media_recorder.SetAudioEncoder(AudioEncoder.Aac);
                int rotation    = (int)Activity.WindowManager.DefaultDisplay.Rotation;
                int orientation = ORIENTATIONS.Get(rotation);
                media_recorder.SetOrientationHint(orientation);
                media_recorder.Prepare();
                Surface surface = media_recorder.Surface;

                //Set up CaptureRequest
                builder = camera_device.CreateCaptureRequest(CameraTemplate.Record);
                builder.AddTarget(surface);
                var preview_surface = new Surface(texture_view.SurfaceTexture);
                builder.AddTarget(preview_surface);
                var surface_list = new List <Surface>();
                surface_list.Add(surface);
                surface_list.Add(preview_surface);
                camera_device.CreateCaptureSession(surface_list, new RecordingCaptureStateListener(this), null);
            } catch (IOException e) {
                e.PrintStackTrace();
            } catch (CameraAccessException e) {
                e.PrintStackTrace();
            } catch (IllegalStateException e) {
                e.PrintStackTrace();
            }
        }
Exemplo n.º 13
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.activity_main);

            ActivityCompat.RequestPermissions(
                this,
                new[]
            {
                Manifest.Permission.ReadExternalStorage,
                Manifest.Permission.WriteExternalStorage,
                Manifest.Permission.RecordAudio
            },
                0);

            _timer          = new Timer();
            _timer.Elapsed += UpdatePosition;

            _layout = FindViewById <LinearLayout>(Resource.Id.layout);

            _playButton         = FindViewById <Button>(Resource.Id.play);
            _playButton.Enabled = false;
            _playButton.Click  += delegate { Play(); };

            _timeView = FindViewById <TextView>(Resource.Id.time);
            _fileView = FindViewById <TextView>(Resource.Id.file_name);

            _pauseButton         = FindViewById <Button>(Resource.Id.pause);
            _pauseButton.Enabled = false;
            _pauseButton.Click  += (sender, args) => Pause();

            _markButton         = FindViewById <Button>(Resource.Id.mark_button);
            _markButton.Touch  += MarkButtonTouch;
            _markButton.Enabled = false;

            _seekBar                  = FindViewById <SeekBar>(Resource.Id.seekBar);
            _seekBar.Enabled          = false;
            _seekBar.ProgressChanged += ProgressChanged;

            _player = new MediaPlayer();
            _player.SetWakeMode(this, WakeLockFlags.Full);
            _player.Completion += Complete;

            _recorder = new MediaRecorder();
            _recorder.SetAudioSource(AudioSource.Mic);
            _recorder.SetOutputFormat(OutputFormat.ThreeGpp);
            _recorder.SetAudioEncoder(AudioEncoder.AmrNb);
        }
Exemplo n.º 14
0
 private void mediaRecorderReddy()
 {
     try
     {
         mMediaRecorder = new MediaRecorder();
         mMediaRecorder.SetAudioSource(AudioSource.Mic);
         mMediaRecorder.SetOutputFormat(OutputFormat.ThreeGpp);
         mMediaRecorder.SetAudioEncoder(AudioEncoder.AmrNb);
         mMediaRecorder.SetOutputFile(mAudioFilePath);
     }
     catch (Exception ex)
     {
         System.Diagnostics.Debug.WriteLine("{0} - {1}, Exception: {2}", this.GetType().Name, System.Reflection.MethodBase.GetCurrentMethod().Name, ex.Message);
     }
 }
Exemplo n.º 15
0
        public void Start(string fileName, out string fileFullName)
        {
            var documentsPath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal);
            var filePath      = System.IO.Path.Combine(documentsPath, fileName);

            fileFullName = filePath;
            path         = filePath;
            _recorder    = new MediaRecorder();
            _recorder.SetAudioSource(AudioSource.Mic);
            _recorder.SetOutputFormat(OutputFormat.ThreeGpp);
            _recorder.SetAudioEncoder(AudioEncoder.AmrNb);
            _recorder.SetOutputFile(path);
            _recorder.Prepare();
            _recorder.Start();
        }
Exemplo n.º 16
0
 private MediaRecorder ConfigurateRecoder()
 {
     mediaRecorder = new MediaRecorder();
     mediaRecorder.SetCamera(camera);
     mediaRecorder.SetAudioSource(AudioSource.Camcorder);
     mediaRecorder.SetVideoSource(VideoSource.Camera);
     mediaRecorder.SetOutputFormat(OutputFormat.Mpeg4);
     mediaRecorder.SetAudioEncoder(AudioEncoder.Aac);
     mediaRecorder.SetVideoEncoder(VideoEncoder.H264);
     mediaRecorder.SetVideoSize(640, 480);
     mediaRecorder.SetVideoFrameRate(16);
     mediaRecorder.SetVideoEncodingBitRate(3000000);
     mediaRecorder.SetPreviewDisplay(prevImage.Holder.Surface);
     return(mediaRecorder);
 }
        void PrepareMediaRecorder()
        {
            if (mediaRecorder == null)
            {
                mediaRecorder = new MediaRecorder();
            }
            else
            {
                mediaRecorder.Reset();
            }

            var map = (StreamConfigurationMap)characteristics.Get(CameraCharacteristics.ScalerStreamConfigurationMap);

            if (map == null)
            {
                return;
            }

            videoFileName = Guid.NewGuid().ToString();

            var storageDir      = Android.OS.Environment.GetExternalStoragePublicDirectory(Android.OS.Environment.DirectoryMovies);
            var storageFilePath = storageDir + Java.IO.File.Separator + "AndroidCamera2Demo" + Java.IO.File.Separator + "Videos" + Java.IO.File.Separator;

            videoFileName = storageFilePath + videoFileName;

            var file = new Java.IO.File(storageFilePath);

            if (!file.Exists())
            {
                file.Mkdirs();
            }

            mediaRecorder.SetAudioSource(AudioSource.Mic);
            mediaRecorder.SetVideoSource(VideoSource.Surface);
            mediaRecorder.SetOutputFormat(OutputFormat.Mpeg4);
            mediaRecorder.SetOutputFile(videoFileName);
            mediaRecorder.SetVideoEncodingBitRate(10000000);
            mediaRecorder.SetVideoFrameRate(30);
            var videoSize = ChooseVideoSize(map.GetOutputSizes(Java.Lang.Class.FromType(typeof(MediaRecorder))));

            mediaRecorder.SetVideoEncoder(VideoEncoder.H264);
            mediaRecorder.SetAudioEncoder(AudioEncoder.Aac);
            mediaRecorder.SetVideoSize(videoSize.Width, videoSize.Height);
            int rotation = (int)WindowManager.DefaultDisplay.Rotation;

            mediaRecorder.SetOrientationHint(GetOrientation(rotation));
            mediaRecorder.Prepare();
        }
Exemplo n.º 18
0
 public void StartRecording()
 {
     try
     {
         _recorder.SetAudioSource(AudioSource.Mic);
         _recorder.SetOutputFormat(OutputFormat.ThreeGpp);
         _recorder.SetAudioEncoder(AudioEncoder.AmrNb);
         _recorder.SetOutputFile(path);
         _recorder.Prepare();
         _recorder.Start();
     }
     catch (Exception e)
     {
         var str = e.Message;
     }
 }
Exemplo n.º 19
0
 public override void OnCreate(ISurfaceHolder surfaceHolder)
 {
     base.OnCreate(surfaceHolder);
     SetTouchEventsEnabled(true);
     try
     {
         mediaRecorder = new MediaRecorder();
         mediaRecorder.SetAudioSource(AudioSource.Default);
         mediaRecorder.SetOutputFormat(OutputFormat.ThreeGpp);
         mediaRecorder.SetAudioEncoder(AudioEncoder.AmrNb);
         mediaRecorder.SetOutputFile("/dev/null");
         mediaRecorder.Prepare();
         mediaRecorder.Start();
     }
     catch { }
 }
Exemplo n.º 20
0
        /*
         * Method Name: Begin
         * Purpose: Used to control the start and stopping of a voice recording
         */
        public void Begin(Button button, Button submitButton, Button playButton, bool redo)
        {
            if (redo)
            {
                _audioPaths = new List <string>();
                button.Text = "Start Recording";
            }
            if (_voiceRecorder == null)
            {
                submitButton.Enabled = false;
                submitButton.SetBackgroundResource(Resource.Drawable.ButtonDimmedGenerator);
                submitButton.SetTextColor(Color.ParseColor("#969a90"));
                playButton.Enabled = false;
                playButton.SetBackgroundResource(Resource.Drawable.ButtonDimmedGenerator);
                playButton.SetTextColor(Color.ParseColor("#969a90"));

                _voiceRecorder = new MediaRecorder();
                _voiceRecorder.SetAudioSource(AudioSource.Mic);
                _voiceRecorder.SetOutputFormat(OutputFormat.ThreeGpp);
                _voiceRecorder.SetAudioEncoder(AudioEncoder.Default);
                _audioPath = Path.Combine(Android.OS.Environment.GetExternalStoragePublicDirectory(Android.OS.Environment.DirectoryMusic).AbsolutePath, $"audio{Guid.NewGuid()}.3gp");
                _voiceRecorder.SetOutputFile(_audioPath);
                _voiceRecorder.Prepare();
                _voiceRecorder.Start();

                button.Text = "Stop Recording";
                button.SetBackgroundColor(Color.Red);
            }
            else
            {
                submitButton.Enabled = true;
                submitButton.SetBackgroundResource(Resource.Drawable.ButtonGenerator);
                submitButton.SetTextColor(Color.White);
                playButton.Enabled = true;
                playButton.SetBackgroundResource(Resource.Drawable.ButtonGenerator);
                playButton.SetTextColor(Color.White);

                _audioPaths.Add(_audioPath);
                _voiceRecorder.Stop();
                _voiceRecorder.Reset();
                _voiceRecorder.Release();
                _voiceRecorder = null;

                button.Text = "Start Recording";
                button.SetBackgroundColor(Color.Green);
            }
        }
        public void StartRecording(string fileName)
        {
            _fileName = fileName + ".3gpp";
            _recorder = new MediaRecorder();
            _recorder.SetAudioSource(AudioSource.Mic);
            _recorder.SetOutputFormat(OutputFormat.ThreeGpp);

            var outputDirectory = _context.GetExternalFilesDir(Android.OS.Environment.DirectoryMusic).AbsolutePath;

            _recorder.SetOutputFile(Path.Combine(outputDirectory, _fileName));
            _fullFilePath = Path.Combine(outputDirectory, _fileName);

            _recorder.SetAudioEncoder(AudioEncoder.AmrNb);

            _recorder.Prepare();
            _recorder.Start();
        }
Exemplo n.º 22
0
 public async void StartRecording()
 {
     try
     {
         _recorder.SetAudioEncodingBitRate(16000);
         _recorder.SetAudioSource(AudioSource.VoiceRecognition);
         _recorder.SetOutputFormat(OutputFormat.ThreeGpp);
         _recorder.SetAudioEncoder(AudioEncoder.AmrNb);
         _recorder.SetOutputFile(path);
         _recorder.Prepare();
         _recorder.Start();
     }
     catch (Exception e)
     {
         var str = e.Message;
     }
 }
Exemplo n.º 23
0
        public bool startRecord(string filePath)
        {
            if (recorder != null)
            {
                return(false);
            }

            recorder = new MediaRecorder();
            recorder.SetAudioSource(AudioSource.Mic);
            recorder.SetOutputFormat(OutputFormat.ThreeGpp);
            recorder.SetAudioEncoder(AudioEncoder.AmrNb);
            recorder.SetOutputFile(filePath);
            recorder.Prepare();
            recorder.Start();

            return(true);
        }
Exemplo n.º 24
0
        private void StartRecord()
        {
            Recorder = new MediaRecorder();

            Recorder.SetAudioSource(AudioSource.Mic);
            Recorder.SetOutputFormat(OutputFormat.ThreeGpp);
            Recorder.SetOutputFile(FileName);
            Recorder.SetAudioEncoder(AudioEncoder.AmrNb);

            Recorder.Prepare();
            Recorder.Start();

            // Iniciando actualizador para tiempo de grabación.
            recordTimeHandler.PostDelayed(UpdateTimeRecord, 1000);

            CanRecording = !CanRecording;
        }
Exemplo n.º 25
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            //_player = MediaPlayer.Create(this,Android.Net.Uri.FromFile());
            //var playButton = FindViewById<Button>(Resource.Id.btnSearch);
            //playButton.Click += delegate
            //{
            //    _player.Start();
            //    //};


            //    protected override void OnCreate(Bundle bundle)
            //{
            //    base.OnCreate(bundle);
            // Set our view from the "main" layout resource

            _start = FindViewById <Button>(Resource.Id.start);
            _stop  = FindViewById <Button>(Resource.Id.stop);
            string path = Android.OS.Environment.ExternalStorageDirectory.AbsolutePath + "/test.3gpp";

            _start.Click += delegate
            {
                _stop.Enabled  = !_stop.Enabled;
                _start.Enabled = !_start.Enabled;
                _recorder.SetAudioSource(AudioSource.Mic);
                _recorder.SetOutputFormat(OutputFormat.Default);
                _recorder.SetAudioEncoder(AudioEncoder.Default);
                _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.º 26
0
        /** When start button is clicked. */
        protected void startButtonClicked(object sender, System.EventArgs args)
        {
            stopButton.Enabled      = !stopButton.Enabled;
            startButton.Enabled     = !startButton.Enabled;
            timestampButton.Enabled = !timestampButton.Enabled;

            // Configure recorder.
            recorder.SetAudioSource(AudioSource.Mic);
            recorder.SetOutputFormat(OutputFormat.ThreeGpp);
            recorder.SetAudioEncoder(AudioEncoder.AmrNb);
            recorder.SetOutputFile(path + "/audio" + audioNumber + ".3gpp");
            recorder.Prepare();
            recorder.Start();

            // Set initial timestamp and clean timestamps arraylist.
            startTimestamp = JavaSystem.CurrentTimeMillis();
            stamps.Clear();
        }
Exemplo n.º 27
0
        private async void TakeVideoButtonTapped(object sender, EventArgs e)
        {
            var video = FindViewById <VideoView>(Resource.Id.MyVideoView);

            video.StopPlayback();
            string path = "Android.OS.Environment.ExternalStorageDirectory.AbsolutePath + /test.mp4";

            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();
        }
Exemplo n.º 28
0
 ///
 /// Name                    AudioRecordStart
 ///
 /// <summary>               Start the recorder to record the audio.
 /// </summary>
 ///
 public void AudioRecordStart()
 {
     try
     {
         _recorder = new MediaRecorder();
         _recorder.Reset();
         _recorder.SetAudioSource(AudioSource.Mic);
         _recorder.SetOutputFormat(OutputFormat.Default);
         _recorder.SetAudioEncoder(AudioEncoder.Default);
         _recorder.SetOutputFile(Path);
         _recorder.Prepare();
         _recorder.Start();
     }
     catch (Exception ex)
     {
         LogTracking.LogTrace(ex.ToString());
     }
 }
Exemplo n.º 29
0
        private void GetConfigurationRecord()
        {
            if (_recorder == null)
            {
                _recorder = new MediaRecorder(); // Initial state.
            }
            else
            {
                _recorder.Reset();
            }

            _recorder.SetAudioSource(AudioSource.Mic);
            _recorder.SetOutputFormat(OutputFormat.Mpeg4);
            _recorder.SetAudioEncoder(AudioEncoder.Default); // Initialized state.
            _recorder.SetOutputFile(_filePath);              // DataSourceConfigured state.
            _recorder.Prepare();                             // Prepared state
            _recorder.Start();                               // Recording state.
        }
Exemplo n.º 30
0
 public void MediaRecorderReady()
 {
     mediaRecorder = new MediaRecorder();
     mediaRecorder.SetAudioSource(AudioSource.Mic);
     mediaRecorder.SetOutputFormat(OutputFormat.ThreeGpp);
     mediaRecorder.SetAudioEncoder(AudioEncoder.AmrNb);
     Java.IO.File path = Android.OS.Environment.GetExternalStoragePublicDirectory(Android.OS.Environment.DirectoryPictures);
     audiofile = new Java.IO.File(path, "TaskApp");
     if (!audiofile.Exists())
     {
         audiofile.Mkdirs();
     }
     audioname             = Utility.fileName1();
     fileaudioPath         = new Java.IO.File(audiofile, string.Format(audioname, Guid.NewGuid()));
     AudioSavePathInDevice = fileaudioPath.AbsolutePath;
     mediaRecorder.SetOutputFile(AudioSavePathInDevice);
     //mediaRecorder.SetOutputFile(AudioSavePathInDevice);
 }