score:1
Accepted answer
i'm still not sure what was the problem, but i think there was something wrong with the way i stopped recording (the whole try, catch thing). i just rewrote the whole code and put the mediarecorder in two different methods. startrecording() and stoprecording() method. and now it works perfectly!
startrecording()
public void startrecording (){
recorder = new mediarecorder();
recorder.reset();
recorder.setaudiosource(mediarecorder.audiosource.camcorder);
recorder.setoutputformat(mediarecorder.outputformat.three_gpp);
recorder.setaudioencoder(mediarecorder.audioencoder.amr_nb);
if (environment.getexternalstoragestate().equals(environment.media_mounted))
{
externalstoragepath = environment.getexternalstoragedirectory().getabsolutepath();
externaloutputpath = externalstoragepath + file.separator + "/android/data/com.whizzappseasyvoicenotepad/test.mp3";
recorder.setoutputfile(externaloutputpath);
}
else
{
storagepath = environment.getdatadirectory().getabsolutepath();
recorder.setoutputfile(storagepath + "/android/data/com.whizzappseasyvoicenotepad/test.mp3");
}
recorder.setonerrorlistener(errorlistener);
recorder.setoninfolistener(infolistener);
try {
recorder.prepare();
recorder.start();
} catch (illegalstateexception e) {
// todo auto-generated catch block
e.printstacktrace();
} catch (ioexception e) {
// todo auto-generated catch block
e.printstacktrace();
}
}
stoprecording()
public void stoprecording() {
if (null != recorder) {
recorder.stop();
recorder.reset();
recorder.release();
recorder = null;
}
}
Source: stackoverflow.com
Related Query
- File that I recorded with MediaRecorder can't be played
- Cant see changes in .java file when running Junit with Eclipse before mvn install
- Opening a file in Eclipse that is associated with another program
- Gradle does not copy xml file that store with java file to war file when it assemble
- Trying to rename recorded file with a method
- Eclipse project with file resources that I'd like to write out on application start
- Remove association for a file that begins with a '.' (no extension)
- I am having trouble with Java in Eclipse with finding a file that is clearly there
- Scanner cant find my file to read [Java with eclipse]
- How to open a java file with java editor that eclipse owns?
- Can't find the file directory after I stopped recording with MediaRecorder
- eclipse create jar file with txt file that can be referred to
- I have an external executable jar file that I wish to edit the java files in it with Eclipse
- Android xml error: "No resource found that matches the given name" with RelativeLayout (@id/LinearLayout_acc, @id/ProgressBar_statusScreen)
- Class file name must end with .class exception in Java Search
- ctrl-click goes to the declaration of the method I clicked. For interfaces with one implementation, how can I just directly go to that implementation?
- Eclipse source out of sync with file system
- Opening JSF Facelets page shows "This XML file does not appear to have any style information associated with it."
- Error : No resource found that matches the given name (at 'icon' with value '@drawable/icon')
- Best ways to deal with properties values in XML file in Spring, Maven and Eclipses
- Debugging jar file with source code attached in eclipse
- Unable to create a file with foreign language characters
- No JREs installed in the work space that are strictly compatible with this environment
- What is the best, free, subversion control repository that can be used with the Eclipse subversion plugin?
- How to undelete a file with Subversive?
- Where do I put the txt file that I want to read in Java?
- Automatically Creating Manifest File with Eclipse for JAR Files
- A project with that name already exists in the workspace eclipse
- Problem with relative file path
- Error: No resource found that matches the given name (at 'theme' with value '@style/AppTheme')
More Query from same tag
- Eclipse doesn't generates R.java even without errors
- Eclipse Scala Worksheet error value is not a member of object
- Where should I place external xslt file in java web app?
- Accessing my Protege OWL Ontology using Java in Eclipse
- Error coming on creating new JPA project::: after selecting jpa version 2.1,basic jpa configuration showing error jpa 2.1 requires java 1.5 or newer
- Eclipse won't jump to declaration of namespaced classes
- Error launching Eclipse
- can't run app on eclipse using google play service
- connecting to Oracle XE with myBatis using JDBC in Eclipse
- Eclipse Jetty Integration, how to setup dependencies?
- seam-gen vs eclipse seam web project
- Plugins working in Eclipse Indigo, not in galileo
- MySQL connection error with java
- Options Menu cannot override?
- Search for an exact phrase with InstaSearch for Eclipse
- catalina.base path while run service from IDE
- Which Python Environment Does Pydev Use?
- Spring Tool Suite not "Spring" in create New
- unsigned APK can not be installed - google maps app
- WebLogic plugin within Eclipse
- How to disable/enable an action set in Eclipse e4?
- Eclipse: Debugging & inspection of variables causes com.sun.jdi.ObjectCollectedException
- How to bulk cleanup imports in Java with Eclipse?
- How are commands and their functions defined in Java?
- Starting wso2 enterprise integrator server from EI Tool
- EclipseRT/Virgo not appearing in Eclipse Server Adapter list
- Can't add Liferay portlet from SVN to the App Server
- Running and Importing files folder along with runnable jar in eclipse
- How to implement IWindowCloseHandler in Eclipse (e4) RCP?
- Spring "hello world" example error: A JNI error has occured & NoClassDefFoundError: org/springframework/beans/factory/ListableBeanFactory