我已经录制了 3gp 格式的音频并将其保存在 sd 卡中。这是我的代码,它运行成功。我需要将图像添加到该音频文件中,以便添加的图像将成为专辑封面&当我尝试在 android 的默认媒体播放器中播放从 sd 卡位置获取的录制音频 ..like this ..
图片中显示的图像是我必须将其提供给我录制的音频文件的专辑封面
/**
* Starts a new recording.
*/
public void start() throws IOException {
String state = android.os.Environment.getExternalStorageState();
if (!state.equals(android.os.Environment.MEDIA_MOUNTED)) {
throw new IOException("SD Card is not mounted. It is " + state
+ ".");
}
// make sure the directory we plan to store the recording in exists
File directory = new File(path).getParentFile();
if (!directory.exists() && !directory.mkdirs()) {
throw new IOException("Path to file could not be created.");
}
recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
System.out.println("audio_file_path : = " + path);
recorder.setOutputFile(path);
recorder.prepare();
recorder.start(); // Recording is now started
}