java - Android Audio Recorder with pause and Resume functionality -


is there can me out developing flexible audio recorder play , pause functionality?

noted: have used pauseresumeaudiorecorder. not flexible when stop recording file corrupting. have used mp4parser library taking lot of time merging 2 large files.

here mp4wrapper class using merging 2 files.

public final class mp4parserwrapper {  public static final string tag = "mp4parserwrapper";  public static final int file_buffer_size = 1024;  private mp4parserwrapper() { }  /**  * appends mp4 audios/videos: {@code anotherfilename} {@code mainfilename}.  *  * @param mainfilename first file path.  * @param anotherfilename second file path.  *  * @return true if operation made successfully.  */ public static boolean append(string mainfilename, string anotherfilename){     try {         file targetfile = new file(mainfilename);         file anotherfile = new file(anotherfilename);         if (targetfile.exists() && targetfile.length() > 0) {             string tmpfilename = mainfilename + ".tmp";             append(mainfilename, anotherfilename, tmpfilename);             copyfile(tmpfilename, mainfilename);             return anotherfile.delete() && new file(tmpfilename).delete();         } else {             if (!targetfile.exists()) {                 if (!targetfile.getparentfile().exists()) {                     if (!targetfile.getparentfile().mkdirs()) {                         return false;                     }                 }                 if (!targetfile.createnewfile()) {                     return false;                 }             }             copyfile(anotherfilename, mainfilename);             return anotherfile.delete();         }     } catch (ioexception e) {         e.printstacktrace();         log.e(tag, "appending 2 mp4 files failed exception", e);         return false;     } catch (exception e) {         e.printstacktrace();         return false;      } }   private static void copyfile(final string from, final string destination)         throws ioexception {     fileinputstream in = new fileinputstream(from);     fileoutputstream out = new fileoutputstream(destination);     copy(in, out);     in.close();     out.close(); }  private static void copy(fileinputstream in, fileoutputstream out) throws ioexception {     byte[] buf = new byte[file_buffer_size];     int len;     while ((len = in.read(buf)) > 0) {         out.write(buf, 0, len);     } }  public static void append(         final string firstfile,         final string secondfile,         final string newfile) throws exception {     final movie moviea = moviecreator.build(new filedatasourceimpl(new file(secondfile)));     final movie movieb = moviecreator.build(new filedatasourceimpl(firstfile));      final movie finalmovie = new movie();      final list<track> movieonetracks = moviea.gettracks();     final list<track> movietwotracks = movieb.gettracks();      (int = 0; < movieonetracks.size() || < movietwotracks.size(); ++i) {         finalmovie.addtrack(new appendtrack(movietwotracks.get(i), movieonetracks.get(i)));     }      final container container = new defaultmp4builder().build(finalmovie);      final fileoutputstream fos = new fileoutputstream(new file(string.format(newfile)));     final writablebytechannel bb = channels.newchannel(fos);     container.writecontainer(bb);     fos.close(); } 

}

i suggest use mp4parser in file can see check track size , respective code add perfectly.


Comments

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -