I am working on a task where i need to record the audio which is taken from MIC.
and save in either local drive or sdcard. I implemented the following code.
But i m unable load the sdcard.
I used the basic commands given in developer.android.com to create sdcard image and load.
but i couldn succeed.
Plz help me out in doing this.
Using java Syntax Highlighting
- package com.sample.recorder;
- import android.app.Activity;
- import android.media.MediaPlayer;
- import android.media.MediaRecorder;
- import android.os.Bundle;
- import android.view.View;
- import android.view.View.OnClickListener;
- import android.widget.Button;
- import android.widget.Toast;
- public class Test extends Activity implements OnClickListener
- {
- @Override
- public void onCreate(Bundle icici)
- {
- super.onCreate(icici);
- setContentView(R.layout.record);
- Button stop = (Button) findViewById(R.id.stop);
- stop.setOnClickListener(this);
- Button rec = (Button) findViewById(R.id.rec);
- rec.setOnClickListener(this);
- Button play = (Button) findViewById(R.id.play);
- play.setOnClickListener(this);
- }
- @Override
- public void onClick(View v)
- {
- int id = v.getId();
- String PATH_NAME = "/sdcard/Music/Records";
- MediaRecorder mRecorder = new MediaRecorder();
- MediaPlayer mp;
- mp = MediaPlayer.create(getBaseContext(), R.raw.test_cbr);
- if(id == R.id.rec)
- {
- mRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
- mRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
- mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
- mRecorder.setOutputFile(PATH_NAME);
- try
- {
- mRecorder.prepare();
- }
- catch(Exception e)
- {
- }
- mRecorder.start();
- }
- else if(id == R.id.play)
- {
- mp.start();
- }
- else if(id == R.id.stop)
- {
- mp.stop();
- mp.release();
- mRecorder.stop();
- Toast.makeText(getBaseContext(),"cello...",Toast.LENGTH_SHORT);
- mRecorder.release();
- }
- }
- }
Parsed in 0.038 seconds, using GeSHi 1.0.8.4


