我正在关注this上的文章“在安卓上捕获音频”。我以为这会很容易,但有个问题。代码如下:
File dir = activity.getDir("recordings", Context.MODE_PRIVATE);
File file = new File(dir, "testaudio.mpeg4");
FileUtil fileUtil = new FileUtil();
File parent = file.getParentFile();
if(!parent.exists()){
Log.i(TAG, "Creating non-existent path:" + parent.getAbsolutePath());
parent.mkdirs();
}
recorder = new MediaRecorder();
recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
recorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
recorder.setAudioEncoder(MediaRecorder.AudioEncoder.DEFAULT);
try{
recorder.setOutputFile(file.getAbsolutePath());
recorder.prepare();
recorder.start();
}catch(IOException e){
//more code
}因此,它确实在/data/data/com.myapp/app_recordings/文件夹下创建了一个testaudio.mpeg4文件。但是,在将文件传输到Mac之后(使用adb pull),它不能播放。我用的是苹果电脑,我试过几种音频格式(例如MP3、MPEG、3GP等)。但似乎什么都不起作用。任何帮助/指导都将不胜感激。
发布于 2014-02-06 12:42:11
使用这个
File dir = new File(Environment
.getExternalStorageDirectory().getAbsolutePath() + "/recording/");发布于 2014-02-07 01:51:51
这看起来像是Mac的问题,代码或设备都没有问题。我能听到设备上的音频。
https://stackoverflow.com/questions/21593246
复制相似问题