android – 组合音频文件和播放不同API版本的奇怪问题

android – 组合音频文件和播放不同API版本的奇怪问题,第1张

概述所有,我正在使用录音机录音. 情况1:如果我使用安装Android 2.2版本的设备,我录制的音频组合起来很好. 情况2:如果我在Android 1.6安装的设备中使用它,我无法播放组合的音频文件. 它只播放第一个录制的音频和下一个录制的音频文件保持空没有声音. 我也没有在Logcat中收到任何错误. 我使用以下代码录制音频: mRecorder = new MediaRecorder(); 所有,我正在使用录音机录音.

情况1:如果我使用安装Android 2.2版本的设备,我录制的音频组合起来很好.

情况2:如果我在AndroID 1.6安装的设备中使用它,我无法播放组合的@R_419_6756@.

它只播放第一个录制的音频和下一个录制的@R_419_6756@保持空没有声音.

我也没有在Logcat中收到任何错误.

我使用以下代码录制音频:

mRecorder = new MediaRecorder();    mRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);    mRecorder.setoutputFormat(MediaRecorder.OutputFormat.RAW_AMR);    mRecorder.setoutputfile(main_record_file);    mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);    mRecorder.prepare();    mRecorder.start();

我也试过mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.DEFAulT);

代码组合@R_419_6756@:

public voID createCombineRecfile(){    combined_file_stored_path=getfilename_combined_raw(); // file path in String to store recorded audio    byte fileContent[]=null;    fileinputStream ins;    fileOutputStream fos = null;    try{        fos = new fileOutputStream(combined_file_stored_path,true);    }    catch (fileNotFoundException e1){        // Todo auto-generated catch block        e1.printstacktrace();    }    for(int i=0;i<audnames.size();i++){        try{            file f=new file(audnames.get(i));            Log.v("Record Message","file Length=========>>>"+f.length());            fileContent = new byte[(int)f.length()];            ins=new fileinputStream(audnames.get(i));            int r=ins.read(fileContent);// Reads the file content as byte from the List.            Log.v("Record Message","Number Of Bytes Readed=====>>>"+r);            fos.write(fileContent);//Write the byte into the combine file.            Log.v("Record Message","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();    }}

让我知道任何细节需要.谢谢.

解决方法 每个@R_419_6756@都有自己的标题(包括有关长度/样本等的信息) – 通过组合文件,生成文件的方式有多个标题,每个源文件一个(取决于具有文件偏移的确切格式等).
因此,文件格式规范的结果文件不正确.

较新的AndroID版本更容易,工作/播放与“多头”存在…旧版本不…

要创建正确组合的@R_419_6756@,您必须符合规范,其中包括创建一个新的标题,描述所有包含的音频…

用于组合@R_419_6756@的一种不同的方法 – 例如通过ffmpeg(请参阅this如何使ffmpeg为androID).

总结

以上是内存溢出为你收集整理的android – 组合音频文件和播放不同API版本的奇怪问题全部内容,希望文章能够帮你解决android – 组合音频文件和播放不同API版本的奇怪问题所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1131919.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-30
下一篇 2022-05-30

发表评论

登录后才能评论

评论列表(0条)

保存