开发者

Android voice recording with pause/resume?

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开发者_Go百科 possible in Android or not If it is possible, can you provide a code example?


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


    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();
    }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜