Android Open Source - androidify-yourself Android Sound Recorder






From Project

Back to project page androidify-yourself.

License

The source code is released under:

MIT License

If you think the Android project androidify-yourself listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.github.androidify;
//from   w w  w  . j av a  2s  .  c  o  m

import android.media.MediaRecorder;
import android.os.Environment;
import android.util.Log;

import java.io.IOException;

public class AndroidSoundRecorder {

    private MediaRecorder mediaRecorder = null;
    private String mFileName;

    public AndroidSoundRecorder(String mFileName) {
        this.mFileName = Environment.getExternalStorageDirectory().
                getAbsolutePath() + "/" + mFileName;
    }

    public void startRecording() {
        if (mediaRecorder != null) stopRecording();

        mediaRecorder = new MediaRecorder();
        mediaRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
        mediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
        mediaRecorder.setOutputFile(mFileName);
        mediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC);
        mediaRecorder.setAudioSamplingRate(44100);
        mediaRecorder.setAudioEncodingBitRate(16);

        try {
            mediaRecorder.prepare();
        } catch (IOException e) {
            Log.e("HELLO", "prepare() failed");
        }

        mediaRecorder.start();

    }

    public void stopRecording() {
        if (mediaRecorder == null) return;

        mediaRecorder.stop();
        mediaRecorder.release();
        mediaRecorder = null;
    }

    public boolean isRecording() {
        return mediaRecorder != null;
    }

}




Java Source Code List

com.github.androidify.AndroidDrawables.java
com.github.androidify.AndroidSoundPlayer.java
com.github.androidify.AndroidSoundRecorder.java
com.github.androidify.AndroidifyViewPagerAdapter.java
com.github.androidify.AndroidifyViewPagerItemFragment.java
com.github.androidify.BitmapUtils.java
com.github.androidify.MainActivity.java
com.github.androidify.PlaceholderFragment.java