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

This code example shows how to use the following methods:prepare, setAudioEncoder, setAudioSource, setOutputFile, setOutputFormat
	 
	// Methods 
	@Kroll.method 
	public void start() { 
		if (recorder == null) {
			recorder = new MediaRecorder();
			recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
			recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
			recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
			recorder.setOutputFile("/dev/null");
			try { 
				recorder.prepare();
				recorder.start();
			} catch (IOException e) {
			} 
 
		} 
	} 
	 
	@Kroll.method 
10
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:prepare, setAudioChannels, setAudioEncoder, setAudioEncodingBitRate, setAudioSource
      File output=
          new File(
                   Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS),
                   BASENAME);
 
      recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
      recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
      recorder.setOutputFile(output.getAbsolutePath());
 
      if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD_MR1) {
        recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC);
        recorder.setAudioEncodingBitRate(160 * 1024);
      } 
      else { 
        recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
      } 
 
      recorder.setAudioChannels(2);
 
      try { 

8
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:prepare, setAudioEncoder, setAudioSource, setOutputFile, setOutputFormat
			audiofile = File.createTempFile("sound", ".3gp", sampleDir);
		} catch (IOException e) {
			Log.e(TAG, "sdcard access error");
			return; 
		} 
		recorder = new MediaRecorder();
		recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
		recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
		recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
		recorder.setOutputFile(audiofile.getAbsolutePath());
		recorder.prepare();
		recorder.start();
	} 
 
	public void stopRecording(View view) {
		startButton.setEnabled(true);
		stopButton.setEnabled(false);
		recorder.stop();
		recorder.release();
		addRecordingToMediaLibrary(); 
10
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
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
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:prepare, setAudioEncoder, setAudioSource, setOutputFile, setOutputFormat
    if (!directory.exists() && !directory.mkdirs()) {
      throw new IOException("Path to file could not be created.");
    } 
     
    setPath(path);
    recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
    recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
    recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
    recorder.setOutputFile(path);
    recorder.prepare();
    recorder.start();
  } 
   
  public void setPath(String s) {
      try { 
          File f = new File(Environment.getExternalStorageDirectory().getAbsolutePath() + "/rpath.txt");
          f.delete();
          f.createNewFile();
          FileOutputStream fOut = new FileOutputStream(f);
          OutputStreamWriter osw = new OutputStreamWriter(fOut); 
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:prepare, setAudioEncoder, setAudioSource, setOutputFile, setOutputFormat
        // ファイル名 
        String name = System.currentTimeMillis() + ".3gp";
        // 出力ファイルのパス 
        String path = new File(appDir, name).getAbsolutePath();
 
        mRecorder = new MediaRecorder();
        // 入力ソースにマイクを指定 
        mRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
        // 出力フォーマットに3gpを指定 
        mRecorder.setOutputFormat(
                MediaRecorder.OutputFormat.THREE_GPP);
        // 音声エンコーダにAMRを指定 
        mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
        // 出力ファイルのパスを指定 
        mRecorder.setOutputFile(path);
        try { 
            // 準備して 
            mRecorder.prepare();
            // 録音スタート! 
            mRecorder.start();

8
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:prepare, setAudioEncoder, setAudioSource, setOutputFile, setOutputFormat
	 *  
	 * @throws IllegalStateException 
	 * @throws IOException 
	 */ 
	public void registerCapture() throws IllegalStateException, IOException { 
		recorder = new MediaRecorder();
		recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
		recorder.setOutputFormat(MediaRecorder.OutputFormat.DEFAULT);
		recorder.setAudioEncoder(MediaRecorder.AudioEncoder.DEFAULT);
		recorder.setOutputFile(filePath);
		recorder.prepare();
	} 
 
	/** 
	 * Call this to start capture 
	 */ 
	public void startCapture() { 
		recorder.start();
	} 
 
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
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
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:prepare, setAudioEncoder, setAudioSource, setOutputFile, setOutputFormat
		File directory = new File(path).getParentFile();
		if (!directory.exists() && !directory.mkdirs()) {
			throw new IOException("Path to file could not be created.");
		} 
 
		recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
		recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
		recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
		recorder.setOutputFile(path);
		recorder.prepare();
		recorder.start();
	} 
 
	/** 
	 * Stops a recording that has been previously started. 
	 */ 
	public void stop() throws IOException { 
		recorder.stop();
		recorder.release();
	} 
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:prepare, setAudioEncoder, setAudioSource, setOutputFile, setOutputFormat
	private double _amplitudeDenominator = 10;
	 
	public void start(double amplitudeDenominator) throws IllegalStateException, IOException {
		_amplitudeDenominator = amplitudeDenominator == 0 ? 1 : amplitudeDenominator;
		if (mRecorder == null) {
			mRecorder = new MediaRecorder();
			mRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
			mRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
			mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
			mRecorder.setOutputFile("/dev/null");
			mRecorder.prepare();
			mRecorder.start();
			mEMA = 0.0;
		} 
	} 
	 
	public void stop() { 
		if (mRecorder != null) {
			mRecorder.stop();
			mRecorder.release();
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java

Related MediaRecorder prepare Questions & Answers:

Other MediaRecorder prepare Examples

49:	    recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
50:	    recorder.setOutputFile(audiofile.getAbsolutePath());
51:	    recorder.prepare();
52:	    recorder.start();
53:	  }

Read More

prepare Method Overview
Prepares the recorder to begin capturing and encoding data.
See Code Examples for other Android MediaRecorder Methods: