MediaRecorder setOutputFile - 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 setOutputFile 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, 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
This code example shows how to use the following methods:setAudioSource, setMaxDuration, setMaxFileSize, setOutputFile, setProfile
		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 { 
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:setAudioEncoder, setAudioSource, setOutputFile, setOutputFormat
		if(this.tempRecordingFile != null) {
			this.tempRecordingFile.delete();
		} 
		this.tempRecordingFile = File.createTempFile("enoughMMAPI", ".sound");
		FileDescriptor fileDescriptor = new FileOutputStream(this.tempRecordingFile).getFD();
		this.androidMediaRecorder.setOutputFile(fileDescriptor);
		this.androidMediaRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
		this.androidMediaRecorder.setOutputFormat(outputFormat);
		this.androidMediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.DEFAULT);
	} 
 
	public int setRecordSizeLimit(int size) throws MediaException {
		// TODO Auto-generated method stub 
		return 0; 
	} 
 
	public void setRecordStream(OutputStream stream) {
		if(stream == null) {
			throw new RuntimeException("The parameter 'stream' must not be null.");
		} 
6
CodeRank

Related MediaRecorder setOutputFile Questions & Answers:

Other MediaRecorder setOutputFile Examples

48:	    recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
49:	    recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
50:	    recorder.setOutputFile(audiofile.getAbsolutePath());
51:	    recorder.prepare();
52:	    recorder.start();

Read More

setOutputFile Method Overview
Pass in the file descriptor of the file to be written.
See Code Examples for other Android MediaRecorder Methods: