android - MediaRecorder, getMaxAmplitude always returns 0 -


i have developed small mediarecorder application. have 3 buttons- play (for start recording), pause (for stop recording), max (for finding max amplitude). googled correct, nothing worked fine me.

the problem give me 0 getmaxamplitude.

below code using. can 1 please help

public class mainactivity extends activity {      button play,pause, max;      string outputfile = environment.getexternalstoragedirectory().           getabsolutepath() + "/myexampl.3gp";     mediarecorder mrecorder=new mediarecorder();      @override     protected void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);         setcontentview(r.layout.activity_main);          play = (button)findviewbyid(r.id.button1);         pause= (button)findviewbyid(r.id.button2);         max = (button)findviewbyid(r.id.button3);          mrecorder = new mediarecorder();          mrecorder.setaudiosource(mediarecorder.audiosource.mic);         mrecorder.setoutputformat(mediarecorder.outputformat.three_gpp);         mrecorder.setaudioencoder(mediarecorder.outputformat.amr_nb);         mrecorder.setoutputfile(outputfile);          play.setonclicklistener(new onclicklistener() {              @override             public void onclick(view v) {                  try {                     mrecorder.prepare();                 } catch (illegalstateexception e) {                     e.printstacktrace();                 } catch (ioexception e) {                     e.printstacktrace();                 }                  mrecorder.start();                 toast.maketext(getapplicationcontext(), "starts recording!",                      toast.length_short).show();             }         });          pause.setonclicklistener(new onclicklistener() {              @override             public void onclick(view v) {                  try {                     mrecorder.stop();                 } catch (illegalstateexception e) {                     e.printstacktrace();                 }                  mrecorder.release();                 toast.maketext(getapplicationcontext(), "stops recording!",                          toast.length_short).show();             }         });          max.setonclicklistener(new onclicklistener() {             int ampl=0;              @override             public void onclick(view v) {              try {                 ampl=mrecorder.getmaxamplitude();             } catch (illegalstateexception e) {                 e.printstacktrace();             }              toast.maketext(getapplicationcontext(), string.valueof(ampl),                      toast.length_short).show();         }     }); }  @override public boolean oncreateoptionsmenu(menu menu) {     // inflate menu; adds items action bar if present.     getmenuinflater().inflate(r.menu.activity_main, menu);     return true; } 

}


Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -