android - automatically stop recording in AudioRecord class -
i found code storing audio in .wav format link.the code has 2 buttons start , stop recording.i want stop audio recording after sometime.it uses audiorecord class of android store audio.is possible so?
04-19 08:20:00.688: e/androidruntime(2405): fatal exception: main 04-19 08:20:00.688: e/androidruntime(2405): java.lang.runtimeexception: unable start activity componentinfo{com.example.androidwaverecorder/com.example.androidwaverecorder.mainactivity}: java.lang.nullpointerexception 04-19 08:20:00.688: e/androidruntime(2405): @ android.app.activitythread.performlaunchactivity(activitythread.java:2180) 04-19 08:20:00.688: e/androidruntime(2405): @ android.app.activitythread.handlelaunchactivity(activitythread.java:2230) 04-19 08:20:00.688: e/androidruntime(2405): @ android.app.activitythread.access$600(activitythread.java:141) 04-19 08:20:00.688: e/androidruntime(2405): @ android.app.activitythread$h.handlemessage(activitythread.java:1234) 04-19 08:20:00.688: e/androidruntime(2405): @ android.os.handler.dispatchmessage(handler.java:99) 04-19 08:20:00.688: e/androidruntime(2405): @ android.os.looper.loop(looper.java:137) 04-19 08:20:00.688: e/androidruntime(2405): @ android.app.activitythread.main(activitythread.java:5039) 04-19 08:20:00.688: e/androidruntime(2405): @ java.lang.reflect.method.invokenative(native method) 04-19 08:20:00.688: e/androidruntime(2405): @ java.lang.reflect.method.invoke(method.java:511) 04-19 08:20:00.688: e/androidruntime(2405): @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:793) 04-19 08:20:00.688: e/androidruntime(2405): @ com.android.internal.os.zygoteinit.main(zygoteinit.java:560) 04-19 08:20:00.688: e/androidruntime(2405): @ dalvik.system.nativestart.main(native method) 04-19 08:20:00.688: e/androidruntime(2405): caused by: java.lang.nullpointerexception 04-19 08:20:00.688: e/androidruntime(2405): @ com.example.androidwaverecorder.mainactivity.oncreate(mainactivity.java:47) 04-19 08:20:00.688: e/androidruntime(2405): @ android.app.activity.performcreate(activity.java:5104) 04-19 08:20:00.688: e/androidruntime(2405): @ android.app.instrumentation.callactivityoncreate(instrumentation.java:1080) 04-19 08:20:00.688: e/androidruntime(2405): @ android.app.activitythread.performlaunchactivity(activitythread.java:2144) 04-19 08:20:00.688: e/androidruntime(2405): ... 11 more 04-19 08:31:55.766: e/trace(2899): error opening trace file: no such file or directory (2) 04-19 08:31:55.766: w/trace(2899): unexpected value nativegetenabledtags: 0 04-19 08:31:55.766: w/trace(2899): unexpected value nativegetenabledtags: 0 04-19 08:31:55.766: w/trace(2899): unexpected value nativegetenabledtags: 0 04-19 08:31:56.386: w/trace(2899): unexpected value nativegetenabledtags: 0 04-19 08:31:56.386: w/trace(2899): unexpected value nativegetenabledtags: 0 04-19 08:31:56.416: w/trace(2899): unexpected value nativegetenabledtags: 0 04-19 08:31:56.416: w/trace(2899): unexpected value nativegetenabledtags: 0
use code in oncreate of mainactivity
final runnable r = new runnable() { public void run() { if (wavaudiorecorder.state.error == mrecorder.getstate()) { mrecorder.release(); mrecorder = wavaudiorecorder.getinstanse(); mrecorder.setoutputfile(mrcordfilepath); btncontrol.settext("start"); } else { mrecorder.stop(); mrecorder.reset(); btncontrol.settext("start"); } } } }; handler.postdelayed(r, time in millisec);
edit
private static final string mrcordfilepath = environment.getexternalstoragedirectory() + "/testwave.wav";
to
string mrcordfilepath = environment.getexternalstoragedirectory() + "/testwave.wav";
Comments
Post a Comment