MediaRecorder stop - 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 stop method.

This code example shows how to use the following methods:release, stop
	protected void stopRecording(){ 
		try{ 
			if((recorder != null)&&(isRecording))
			{ 
				isRecording = false;
				recorder.stop();
		        recorder.release(); 
			} 
			moveFile(saveFile);
		} 
		catch (Exception e)
		{ 
			e.printStackTrace();
		} 
	}	 
	 
	protected void startPlaying(String file) {
		if (isPlaying==false) {
			try { 
				mPlayer = new MediaPlayer();
8
CodeRank
This code example shows how to use the following methods:release, reset, stop
		recorder.start();
		isRecording = true;
	} 
 
	public void stop() throws IOException { 
		recorder.stop();
		recorder.reset();
		recorder.release();
		isRecording = false;
	} 
 
	public Uri getPath() {
		return Uri.fromFile(new File(path));
	} 
 
	public boolean isRecording() { 
		return isRecording;
	} 
 
} 
8
CodeRank
This code example shows how to use the following methods:release, stop
	} 
	 
	@Kroll.method 
	public void stop() { 
		if (recorder != null) {
			recorder.stop();
			recorder.release();
			recorder = null;
		} 
	} 
	 
	// Properties 
	@Kroll.getProperty 
	public int getSoundAmplitude() { 
		if (recorder != null) {
			try { 
				// Convert from 16-bit sample value to dBFS 
				return (int)(20.0 * Math.log10((double)recorder.getMaxAmplitude() / 32767.0));
			} catch (RuntimeException e) {
			} 
8
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:release, stop
    } 
 
    MediaRecorder tempRecorder=recorder;
 
    recorder=null;
    tempRecorder.stop();
    tempRecorder.release();
    camera.reconnect();
  } 
 
  public void autoFocus() { 
    camera.autoFocus(getHost());
  } 
 
  public void cancelAutoFocus() { 
    camera.cancelAutoFocus();
  } 
 
  // based on CameraPreview.java from ApiDemos 
 
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:release, stop
	} 
 
	public void stopRecording(View view) {
		startButton.setEnabled(true);
		stopButton.setEnabled(false);
		recorder.stop();
		recorder.release();
		addRecordingToMediaLibrary(); 
	} 
 
	protected void addRecordingToMediaLibrary() { 
		ContentValues values = new ContentValues(4);
		long current = System.currentTimeMillis();
		values.put(MediaStore.Audio.Media.TITLE, "audio" + audiofile.getName());
		values.put(MediaStore.Audio.Media.DATE_ADDED, (int) (current / 1000));
		values.put(MediaStore.Audio.Media.MIME_TYPE, "audio/3gpp");
		values.put(MediaStore.Audio.Media.DATA, audiofile.getAbsolutePath());
		ContentResolver contentResolver = getContentResolver();
 
		Uri base = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;
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:prepare, setAudioSource, setMaxDuration, setMaxFileSize, setOutputFile
		cameraView.setClickable(true);
		cameraView.setOnClickListener(this);
	} 
 
	private void initRecorder() { 
		recorder.setAudioSource(MediaRecorder.AudioSource.DEFAULT);
		recorder.setVideoSource(MediaRecorder.VideoSource.DEFAULT);
 
		CamcorderProfile cpHigh = CamcorderProfile
				.get(CamcorderProfile.QUALITY_HIGH);
		recorder.setProfile(cpHigh);
		recorder.setOutputFile("/sdcard/videocapture_example.mp4");
		recorder.setMaxDuration(50000); // 50 seconds
		recorder.setMaxFileSize(5000000); // Approximately 5 megabytes
	} 
 
	private void prepareRecorder() { 
		recorder.setPreviewDisplay(holder.getSurface());
 
		try { 

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 stop Questions & Answers:

Other MediaRecorder stop Examples

56:	    startButton.setEnabled(true);
57:	    stopButton.setEnabled(false);
58:	    recorder.stop();
59:	    recorder.release();
60:	    addRecordingToMediaLibrary();

Read More

stop Method Overview
Stops recording.
See Code Examples for other Android MediaRecorder Methods: