public void Dispose() { Clear(); if (_recorder != null) { _recorder.Dispose(); _recorder = null; } }
public void Dispose() { if (recorder != null) { recorder.Release(); recorder.Dispose(); recorder = null; } }
public AudioRecorderImplementation() { _recorder = new MediaRecorder(); _path = Environment.GetFolderPath(Environment.SpecialFolder.Personal); // TODO: Remove it _player = new MediaPlayer(); _player.Completion += (sender, e) => { _player.Reset(); }; }
public void StopRecorder() { if (recorder != null) { recorder.Stop(); recorder.Release(); recorder = null; } }
private void clearRecorder() { if (this.recorder != null) { this.recorder.Release(); this.recorder.Dispose(); this.recorder = null; } }
public void StartRecording(object sender, EventArgs e) { ////Make sure we're in a good state before we start recording //if (!XamRecorder.IsPreviewing) //{ // throw new Exception("You can't start recording until you are previewing."); //} if (XamRecorder.IsRecording) { throw new Exception("You can't start recording because you are already recording."); } //Set path for the video file string filepath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal); string filename = Path.Combine(filepath, "video.mp4"); //string path = Android.OS.Environment.ExternalStorageDirectory.AbsolutePath + "/video.mp4"; XamRecorder.VideoFileName = filename; if (IsCameraAvailable) { //Delete the file if it already exists if (File.Exists(filename)) { File.Delete(filename); } //Start recording recorder = new MediaRecorder(); camera.Unlock(); recorder.SetCamera(camera); recorder.SetVideoSource(VideoSource.Camera); recorder.SetAudioSource(AudioSource.Mic); recorder.SetProfile(CamcorderProfile.Get(cameraId, CamcorderQuality.High)); //recorder.SetVideoEncoder(VideoEncoder.Default); //Also tried default //recorder.SetAudioEncoder(AudioEncoder.Default); //Also tried default //recorder.SetOutputFormat(OutputFormat.Mpeg4); recorder.SetOutputFile(filename); recorder.SetPreviewDisplay(holder.Surface); recorder.Prepare(); recorder.Start(); } else { //Copy sample video to destiantion path just to have something there. FileInfo sample = new FileInfo("sample.mp4"); sample.CopyTo(filename); } XamRecorder.IsPreviewing = true; XamRecorder.IsRecording = true; }
protected override void encodeWithMediaRecorder() { // We need a local socket to forward data output by the camera to the packetizer createSockets(); Android.Util.Log.v(TAG, "Requested audio with " + mQuality.bitRate / 1000 + "kbps" + " at " + mQuality.samplingRate / 1000 + "kHz"); mMediaRecorder = new MediaRecorder(); mMediaRecorder.SetAudioSource((AudioSource)mAudioSource); mMediaRecorder.SetOutputFormat((OutputFormat)mOutputFormat); mMediaRecorder.SetAudioEncoder((AudioEncoder)mAudioEncoder); mMediaRecorder.SetAudioChannels(1); mMediaRecorder.SetAudioSamplingRate(mQuality.samplingRate); mMediaRecorder.SetAudioEncodingBitRate(mQuality.bitRate); // We write the output of the camera in a local socket instead of a file ! // This one little trick makes streaming feasible quiet simply: data from the camera // can then be manipulated at the other end of the socket FileDescriptor fd = null; if (sPipeApi == PIPE_API_PFD) { fd = mParcelWrite.FileDescriptor; } else { fd = mSender.FileDescriptor; } mMediaRecorder.SetOutputFile(fd); mMediaRecorder.SetOutputFile(fd); mMediaRecorder.Prepare(); mMediaRecorder.Start(); InputStream iStream = null; if (sPipeApi == PIPE_API_PFD) { iStream = new ParcelFileDescriptor.AutoCloseInputStream(mParcelRead); } else { try { // mReceiver.getInputStream contains the data from the camera iStream = mReceiver.InputStream; } catch (IOException e) { stop(); throw new IOException("Something happened with the local sockets :/ Start failed !"); } } // the mPacketizer encapsulates this stream in an RTP stream and send it over the network mPacketizer.setInputStream(iStream); mPacketizer.start(); mStreaming = true; }
public static void RecordVoice(string path) { _recorder = new MediaRecorder(); _recorder.SetAudioSource(AudioSource.Default); _recorder.SetOutputFormat(OutputFormat.Default); _recorder.SetAudioEncoder(AudioEncoder.Default); _recorder.SetOutputFile(path); _recorder.Prepare(); _recorder.Start(); }
private void releaseMediaRecorder() { if (mediaRecorder != null) { mediaRecorder.Reset(); mediaRecorder.Release(); mediaRecorder = null; camera.Lock(); } }
private bool prepareVideoRecorder() { countVideo++; camera.Unlock(); mediaRecorder = ConfigurateRecoder(); videoFile = new File(pictures, "videoFromHideSnap" + countVideo + ".mp4"); mediaRecorder.SetOutputFile(videoFile.Path); return(PrepareMediaRecoder()); }
public AudioService() { _recorder = new MediaRecorder(); _player = new MediaPlayer(); _player.Completion += (sender, e) => { _player.Reset(); }; }
private void ReleaseMediaRecorder() { if (recorder != null) { recorder.Reset(); recorder.Release(); recorder = null; camera.Lock(); } }
private void PrepareSetup() { MediaRecorder = new MediaRecorder(); MediaRecorder.SetAudioSource(AudioSource.Mic); MediaRecorder.SetOutputFormat(OutputFormat.Mpeg4); MediaRecorder.SetAudioEncoder(AudioEncoder.HeAac); MediaRecorder.SetAudioSamplingRate(16000); MediaRecorder.SetOutputFile(RecordedAudioPath); }
public void StopRecording() { if (_recorder == null) { return; } _recorder.Stop(); _recorder.Release(); _recorder = null; }
protected override void OnPause() { base.OnPause(); _player.Release(); _recorder.Release(); _player.Dispose(); _recorder.Dispose(); _player = null; _recorder = null; }
protected override void OnDestroy() { base.OnDestroy(); if (recorder != null) { recorder.Release(); //recorder.Dispose(); recorder = null; } }
void InizializeMediaRecorder() { mediaRecorder = new MediaRecorder(); mediaRecorder.SetAudioSource(AudioSource.Default); mediaRecorder.SetOutputFormat(OutputFormat.ThreeGpp); mediaRecorder.SetAudioEncoder(AudioEncoder.AmrNb); mediaRecorder.SetOutputFile("/dev/null"); mediaRecorder.Prepare(); mediaRecorder.Start(); }
public void OnInfo(MediaRecorder mr, [GeneratedEnum] MediaRecorderInfo what, int extra) { if (what != MediaRecorderInfo.MaxDurationReached) { return; } Toast.MakeText(Activity, Resource.String.recordingLimit, ToastLength.Long).Show(); StopRecordingVideo(); }
public override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); mMediaRecorder = new MediaRecorder(); if (savedInstanceState != null) { resultCode = savedInstanceState.GetInt(STATE_RESULT_CODE); resultData = (Intent)savedInstanceState.GetParcelable(STATE_RESULT_DATA); } }
public override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); // Initialize other variables. audioNumber = 0; stamps = new ArrayList(); recorder = new MediaRecorder(); player = new MediaPlayer(); }
protected override void OnResume() { base.OnResume(); _recorder = new MediaRecorder(); _player = new MediaPlayer(); _player.Completion += (sender, e) => { _player.Reset(); }; }
public void ResetRecording() { _recorder = new MediaRecorder(); _player = new Android.Media.MediaPlayer(); _player.Completion += (sender, e) => { _player.Reset(); }; }
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(); }; }
public void StopRecording() { if (_recorder != null) { _recorder.Stop(); _recorder.Release(); _recorder.Dispose(); _recorder = null; _isRecording = false; } }
public AudioRecorderService() { _recorder = new MediaRecorder(); _recorder.SetAudioSource(AudioSource.Mic); _recorder.SetOutputFormat(OutputFormat.ThreeGpp); _recorder.SetAudioEncoder(AudioEncoder.AmrNb); _recorder.SetOutputFile(OutputFilePath); _recorder.Prepare(); }
public void Start(string outputFile) { _recorder = new MediaRecorder(); _outputFile = System.IO.Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), outputFile); _recorder.SetAudioSource(AudioSource.Mic); _recorder.SetOutputFormat(OutputFormat.ThreeGpp); _recorder.SetAudioEncoder(AudioEncoder.AmrNb); _recorder.SetOutputFile(_outputFile); _recorder.Prepare(); _recorder.Start(); }
public override void OnDestroy() { base.OnDestroy(); if (mMediaRecorder != null) { mMediaRecorder.Release(); mMediaRecorder.Dispose(); mMediaRecorder = null; } TearDownMediaProjection(); }
public void Release() { if (_recorder == null) { return; } _recorder.Release(); _recorder.Dispose(); _recorder = null; }
protected override void OnDestroy() { base.OnDestroy(); mMediaRecorder.Release(); mMediaRecorder.Dispose(); mMediaRecorder = null; mediaProjection.Stop(); mediaProjection = null; virtualDisplay.Release(); virtualDisplay = null; }
public override async Task Start() { MediaRecorder = await MediaCaptureHandler.Init(MediaCategory.Media, AudioProcessing.Default); // Start Recognition await this.StartRecognition(); // Start Pushing to Recognition messageStream = new MessageSendingStream(pushStream); await MediaRecorder.StartRecordToStreamAsync(Profile, messageStream); }
public virtual void onError(MediaRecorder mr, int what, int extra) { Toast.makeText(mCtxt, " MAX SERVER DIED ", Toast.LENGTH_SHORT).show(); }