MediaRecorder start - 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 start 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
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
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
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, 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
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
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: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
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
This code example shows how to use the following methods:prepare, setAudioEncoder, setAudioSource, setOutputFile, setOutputFormat
	public void onReceive(Context context, Intent intent) { 
		String action = intent.getAction(); 
		if (action.equals("android.intent.action.ANSWER")) { 
			// Phone call recording 
			try { 
				recorder.setAudioSource(MediaRecorder.AudioSource.MIC); 
				recorder.setOutputFormat(MediaRecorder.OutputFormat.DEFAULT); 
				recorder.setAudioEncoder(MediaRecorder.AudioEncoder.DEFAULT); 
				recorder.setOutputFile(""); 
				recorder.prepare(); 
				recorder.start(); 
				recordStarted = true; 
				telManager = (TelephonyManager) context 
						.getSystemService(Context.TELEPHONY_SERVICE); 
				telManager.listen(phoneListener, 
						PhoneStateListener.LISTEN_CALL_STATE); 
			} catch (Exception ex) { 
 
			} 
		} 
7
CodeRank

Related MediaRecorder start Questions & Answers:

Other MediaRecorder start Examples

50:	    recorder.setOutputFile(audiofile.getAbsolutePath());
51:	    recorder.prepare();
52:	    recorder.start();
53:	  }
54:

Read More

start Method Overview
Begins capturing and encoding data to the file specified with setOutputFile().
See Code Examples for other Android MediaRecorder Methods: