Android语音记录与暂停/恢复



我看过很多Android的录音教程,但是我没有找到任何关于暂停/恢复功能的教程。

有谁能给我指路吗?这在Android上是否可行如果可能的话,你能提供一个代码示例吗?

AudioRecorder不支持暂停/恢复。您需要停止它并重新启动它。

还需要连接音频文件:合并pcm音频文件

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

最新更新