1

I have seen so many voice recording tutorials for Android but I did not find any tutorials for a pause/resume feature.

Can any one guide me? Is this possible in Android or not If it is possible, can you provide a code example?

Bill the Lizard
  • 398,270
  • 210
  • 566
  • 880
UMAR-MOBITSOLUTIONS
  • 77,236
  • 95
  • 209
  • 278

2 Answers2

4

AudioRecorder does not support pause/resume. You will need to stop it and restart it.

Also you'll need to concatenate audio files: Merging pcm audio files

Community
  • 1
  • 1
Peter Knego
  • 79,991
  • 11
  • 123
  • 154
  • so according to your solution i will have to stop it and then save file start again and merge these both files on final save? – UMAR-MOBITSOLUTIONS Sep 08 '11 at 20:43
  • 1
    PCM is probably easiest because it only contains raw uncompressed digital audio data without any header or footer. So it's easiest to merge. – Peter Knego Sep 08 '11 at 21:03
  • 1
    After you have a merged PCM data you can create WAV file: http://stackoverflow.com/questions/4777181/creating-a-wav-file-from-raw-pcm-data-using-the-android-sdk – Peter Knego Sep 08 '11 at 21:05
1
    byte fileContent[]=null;
    FileInputStream ins;
    FileOutputStream fos = null;
    try{
        fos = new FileOutputStream(getFilename(),true);
        Log.i(TAG, "OutputFile created");
    }
    catch (FileNotFoundException e1){
        // TODO Auto-generated catch block
        Log.i(TAG, "OutputFile Not created");
        e1.printStackTrace();
    }
    for(int i=1;i<listOfFilesToCombine.size();i+=2){
        try{
            File f=new File(listOfFilesToCombine.get(i));
            Log.v("TAG", "File Length:"+f.length());
            fileContent = new byte[(int)f.length()];
            ins=new FileInputStream(listOfFilesToCombine.get(i));
            int r=ins.read(fileContent);
            Log.v("TAG", "Number Of Bytes Readed:"+r);
            if(i>1){
                byte[] headerlessFileContent = new byte[fileContent.length-6];
                for(int j=6; j<fileContent.length;j++){
                    headerlessFileContent[j-6] = fileContent[j];
                }
                fileContent = headerlessFileContent;
            }
            fos.write(fileContent);         
            Log.v("TAG", "File"+i+"is Appended");
        }
        catch (FileNotFoundException e){
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        catch (IOException e) 
        {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
    try{
        fos.close();
        Log.v("Record Message", "===== Combine File Closed =====");
    }
    catch (IOException e){
        // TODO Auto-generated catch block
        e.printStackTrace();
    }