java - Android Media Recorder Stop Exception -



java - Android Media Recorder Stop Exception -

i recording both video , sound android media recorder... checking clip length, if less 2 sec, delete it... problem if check duration of file file path, mediarecorder throws exception everytime after 1 time exception thrown, when record sound of 10 seconds? when comment code check duration of video created, worsk fine... next code

if (prmediarecorder != null) { seek { prmediarecorder.stop(); timer.cancel(); pathnamearray.add(prrecordedfile.getpath()); log.e("no exception", "file added , saved"); ////////////// check length , delete file if (prrecordedfile != null) { if (mediaplayer.create(getapplicationcontext(), uri.fromfile(new file( prrecordedfile.getpath()))).getduration() <= 2000) { file file = new file(prrecordedfile.getpath()); boolean deleted = file.delete(); toast.maketext(getapplicationcontext(), "video clip length short, clip not added", toast.length_short).show(); pathnamearray.remove(pathnamearray.size() - 1); } } } grab (runtimeexception e) { toast.maketext(getapplicationcontext(), "corrupt clip, clip not added", toast.length_short).show(); file file = new file(prrecordedfile.getpath()); boolean deleted = file.delete(); timer.cancel(); log.e("exception caught", "file not added"); } { seek { prcamera.reconnect(); } grab (ioexception e) { e.printstacktrace(); } } } prmediarecorder = new mediarecorder(); markername = null;

please help me out, wrong code or ?

i fixed issue, problem way getting duration, mediaplayer instead used code , fixed...

//////////////// check length , delete file mediametadataretriever retriever = new mediametadataretriever(); retriever.setdatasource(prrecordedfile.getpath()); string time = retriever.extractmetadata(mediametadataretriever.metadata_key_duration); long timeinmillisec = long.parselong(time);

java android file exception android-mediarecorder

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -