Read First

Common bugs/problems with the Android SDK the Emulator and the ADT-Plugin.

Read First

Postby plusminus » Tue Nov 20, 2007 6:55 pm

[b]General Help for Beginners

It's worth using the search-function to check out if you bug has already been solved somewhere else. If you encounter any problems and found no solution here, feel free to post :)


Best Regards,
Your anddev.org - Team.
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

Top

Playing Audio From Emulator

Postby akhilkumars » Thu Jul 01, 2010 5:56 am

Could you pass me some important information regarding the above.
akhilkumars
Freshman
Freshman
 
Posts: 4
Joined: Fri Jun 25, 2010 1:09 pm

Re: Read First

Postby Lakshumaiah » Thu Jan 27, 2011 12:27 pm

package com.AudioRecording;

import java.io.IOException;

import android.app.Activity;
import android.media.MediaPlayer;
import android.media.MediaRecorder;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

public class AudioRecording extends Activity
{

public static String path=null;
public static MediaRecorder recoder=null;
public static MediaPlayer player=null;
Button start=null;
Button stop=null;
Button Play=null;

public void setPath(String modPath)
{
AudioRecording.path=modPath;
}

public void onCreate(Bundle b)
{
super.onCreate(b);
setContentView(R.layout.main);
this.setPath(“/sdcard/myoutputfile.3gp”);
start=(Button)findViewById(R.id.btnRecord);
Play=(Button)findViewById(R.id.startPlayerBtn);

Play.setOnClickListener(new View.OnClickListener() {

@Override
public void onClick(View v) {

player=new MediaPlayer();
try {
player.setDataSource(“/sdcard/myoutputfile.3gp”);
player.prepare();
player.start();
} catch (IllegalArgumentException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalStateException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

}
});
start.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
System.out.println(“Testing File\n”);
recoder=new MediaRecorder();
recoder.setAudioSource(MediaRecorder.AudioSource.MIC);
recoder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
recoder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
recoder.setOutputFile(AudioRecording.path);

try
{
recoder.prepare();
recoder.start();
}catch(IOException e)
{}
}
});
stop=(Button)findViewById(R.id.stopPlayerBtn);
stop.setOnClickListener(new View.OnClickListener() {

public void onClick(View v) {
try {
stopPlayingRecording();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
});
}

private void stopPlayingRecording() throws Exception {
if(recoder!=null)
{
recoder.stop();
}
}
}

This is the code i have written for recording audio through micro phone. I am able to record voice but i am unable to play back it, please help me to play

steps i have taken to execute this code is:

i created sdcard img and i stored the output_file int. But it is not playing
Lakshumaiah
Once Poster
Once Poster
 
Posts: 1
Joined: Thu Jan 27, 2011 12:18 pm

Re: Read First

Postby wakawaka » Mon May 20, 2013 9:16 am

plusminus,
It will be good if you prepare list/index of very useful Android app development tutorials. AndDev tons of very good tutorials, but now challenge is how to dig it.
Please prepare handy list and post it as a sticky topic.
Thanks.
Android Development Tutorials and Code Snippets: http://forum.gssdaily.com/
wakawaka
Experienced Developer
Experienced Developer
 
Posts: 79
Joined: Tue Jan 11, 2011 1:51 pm

Top

Return to SDK/ADT/Emulator Problems

Who is online

Users browsing this forum: Exabot [Bot], Google [Bot] and 4 guests