MediaRecorder reset - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for MediaRecorder reset method.

This code example shows how to use the following methods:prepare, reset, setAudioEncoder, setAudioSource, setOutputFile
		File directory = soundFile.getParentFile();
		if (!directory.exists() && !directory.mkdirs()) {
			throw new IOException("Path to file could not be created.");
		} 
 
		recorder.reset();
		recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
		recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
		recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
		recorder.setOutputFile(path);
		recorder.prepare();
		recorder.start();
		isRecording = true;
	} 
 
	public void stop() throws IOException { 
		recorder.stop();
		recorder.reset();
		recorder.release();
		isRecording = false;
8
CodeRank
This code example shows how to use the following methods:prepare, release, reset, setAudioEncoder, setAudioSource
                setError(SDCARD_ACCESS_ERROR);
                return; 
            } 
        } 
         
        mRecorder = new MediaRecorder();
        mRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
        mRecorder.setOutputFormat(outputfileformat);
        mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
        mRecorder.setOutputFile(mSampleFile.getAbsolutePath());
 
        // Handle IOException 
        try { 
            mRecorder.prepare();
        } catch(IOException exception) {
            setError(INTERNAL_ERROR);
            mRecorder.reset();
            mRecorder.release();
            mRecorder = null;
            return; 

7
CodeRank
This code example shows how to use the following methods:reset, stop
 
	/** 
	 * Call this to stop capture 
	 */ 
	public void stopCapture() { 
		recorder.stop();
		recorder.reset();
	} 
 
	/** 
	 * Call this to release capture device 
	 */ 
	public void unregisterCapture() { 
		recorder.release();
	} 
 
} 
7
CodeRank
This code example shows how to use the following methods:prepare, reset, setAudioEncoder, setAudioSource, setOutputFile
		if (!directory.exists() && !directory.mkdirs()) {
			throw new IOException("Path to file could not be created.");
		} 
 
		// call reset() to start a new record for sure 
		recorder.reset();
		recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
		recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
		recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
		recorder.setOutputFile(path);
		recorder.prepare();
		recorder.start();
		isRecording = true;
	} 
 
	/** 
	 * Stops a recording that has been previously started. 
	 */ 
	public void stop() throws IOException { 
		recorder.stop();
7
CodeRank
This code example shows how to use the following methods:release, reset, stop
            releaseCamera(); 
        } 
    } 
     
    public void stop() { 
        mMediaRecorder.stop();
        releaseMediaRecorder(); 
        camera.lock();
        isRecording = false;
        releaseMediaRecorder();       // if you are using MediaRecorder, release it first 
        releaseCamera();              // release the camera immediately on pause event 
    } 
 
	 
    private boolean prepareVideoRecorder(){ 
        mMediaRecorder = new MediaRecorder();
 
        // Step 1: Unlock and set camera to MediaRecorder 
        camera.unlock();
        mMediaRecorder.setCamera(camera);

7
CodeRank
This code example shows how to use the following methods:prepare, release, reset, setPreviewDisplay, start
        myMediaRecorder.setProfile(targetProfile);
    } 
    
    private boolean realyStart() { 
         
        myMediaRecorder.setPreviewDisplay(myCamSHolder.getSurface());
        try { 
        	myMediaRecorder.prepare();
	    } catch (IllegalStateException e) {
	        releaseMediaRecorder();	 
	        Log.d("TEAONLY", "JAVA:  camera prepare illegal error");
            return false; 
	    } catch (IOException e) {
	        releaseMediaRecorder();	     
	        Log.d("TEAONLY", "JAVA:  camera prepare io error");
            return false; 
	    } 
	     
        try { 
            myMediaRecorder.start();

6
CodeRank
This code example shows how to use the following methods:release, reset, setOnErrorListener, setOnInfoListener
      Log.i(TAG, "starting");
      recorder.start();
    } 
 
    void stop() { 
      recorder.setOnErrorListener(null);
      recorder.setOnInfoListener(null);
      recorder.stop();
      recorder.reset();
      recorder.release();
    } 
  } 
 
  /* 
   * This is null when not recording, and contains the active RecordingState 
   * when recording. 
   */ 
  private RecordingController controller;
 
  public SoundRecorder(final ComponentContainer container) {
6
CodeRank
This code example shows how to use the following methods:prepare, reset, setAudioEncoder, setAudioSource, setOutputFile
		if (!directory.exists() && !directory.mkdirs()) {
			throw new IOException("Path to file could not be created.");
		} 
 
		// call reset() to start a new record for sure 
		recorder.reset();
		recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
		recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
		recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
		recorder.setOutputFile(path);
		recorder.prepare();
		recorder.start();
		isRecording = true;
	} 
 
	/** 
	 * Stops a recording that has been previously started. 
	 */ 
	public void stop() throws IOException { 
		recorder.stop();
7
CodeRank
This code example shows how to use the following methods:release, reset, setOnErrorListener, setOnInfoListener, stop
	private void releaseMediaRecorder() { 
		Log.v(TAG, "Releasing media recorder.");
		if (mMediaRecorder != null) {
			if (mMediaRecorderRecording) {
				try { 
					mMediaRecorder.setOnErrorListener(null);
					mMediaRecorder.setOnInfoListener(null);
					mMediaRecorder.stop();
				} catch (RuntimeException e) {
					Log.e(TAG, "stop fail: " + e.getMessage());
				} 
				mMediaRecorderRecording = false;
			} 
			mMediaRecorder.reset();
			mMediaRecorder.release();
			mMediaRecorder = null;
		} 
	} 
 
	@Override 
6
CodeRank
This code example shows how to use the following methods:reset, stop
 
	public void reset() throws IOException { 
		if(this.recordingState == RECORDING_STARTED) {
			stopRecord(); 
		} 
		this.androidMediaRecorder.reset();
		this.androidMediaRecorder = new MediaRecorder();
		if(this.recordOutputStream != null) {
			this.tempRecordingFile.delete();
			this.tempRecordingFile = File.createTempFile("enoughMMAPI", ".amr");
		} 
	} 
 
	/** 
	 * Only audio capture is supported. Supported encodings: amr,3gpp,mpeg4 
	 */ 
	public void setRecordLocation(String locator) throws IOException, MediaException {
		if(this.recordingState != RECORDING_STOPPED) {
			throw new IllegalStateException("The method 'setRecordLocation' must only be called in the RECORDING_STOPPED state");
		} 

6
CodeRank

Related MediaRecorder reset Questions & Answers:

reset Method Overview
Restarts the MediaRecorder to its idle state.
See Code Examples for other Android MediaRecorder Methods: