录音后找不到音频文件
can't find audio file after recording
我在 android 工作室创建了一个录音机,但我在 phone 上找不到录制的文件。通常我打算将它附加到将要发送的电子邮件中,但我无法在我的 phone 上找到它,以便我将其添加为 attachment.This 是我在下面写的代码
private String outputFile = null;
private MediaRecorder mRecorder;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_home);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
outputFile = Environment.getExternalStorageDirectory().getAbsolutePath() + "/recording.3gpp";
}
public void startRecording() throws Exception {
if(mRecorder!=null){
mRecorder.release();
}
File fileOut = new File(outputFile);
if(fileOut!=null){
fileOut.delete();
}
mRecorder = new MediaRecorder();
mRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
mRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
mRecorder.setOutputFile(outputFile);
mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
mRecorder.prepare();
mRecorder.start();
}
public void stopRecording() {
if(mRecorder != null) {
mRecorder.stop();
mRecorder.release();
}
}
public void record(){
new CountDownTimer(10000, 10000) { // 5000 = 5 sec
public void onTick(long millisUntilFinished) {
try {
startRecording();
} catch (Exception e) {
e.printStackTrace();
}
Toast.makeText(HomeActivity.this, R.string.record_audio, Toast.LENGTH_LONG).show();
}
public void onFinish() {
stopRecording();
mProgressDialog.dismiss();
Toast.makeText(HomeActivity.this, R.string.record_saved, Toast.LENGTH_LONG).show();
}
}.start();
}
可能您的存储没有挂载。我尤其在 CyanogenMod 系统上遇到默认情况下未安装 sotrages 的问题。只要确保通过简单地调用就可以安装存储:
boolean isMountend = Environment.getExternalStorageState().
equals(android.os.Environment.MEDIA_MOUNTED);
当您通过电缆连接复制它们时,它们不会出现。您需要通过 WiFi 连接,然后打开 phone 上的录音,然后点击右上角的选项。将有一个选项可以将其上传到 Google 驱动器。上传到您的帐户后,将其下载到您的桌面驱动器。
我在 android 工作室创建了一个录音机,但我在 phone 上找不到录制的文件。通常我打算将它附加到将要发送的电子邮件中,但我无法在我的 phone 上找到它,以便我将其添加为 attachment.This 是我在下面写的代码
private String outputFile = null;
private MediaRecorder mRecorder;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_home);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
outputFile = Environment.getExternalStorageDirectory().getAbsolutePath() + "/recording.3gpp";
}
public void startRecording() throws Exception {
if(mRecorder!=null){
mRecorder.release();
}
File fileOut = new File(outputFile);
if(fileOut!=null){
fileOut.delete();
}
mRecorder = new MediaRecorder();
mRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
mRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
mRecorder.setOutputFile(outputFile);
mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
mRecorder.prepare();
mRecorder.start();
}
public void stopRecording() {
if(mRecorder != null) {
mRecorder.stop();
mRecorder.release();
}
}
public void record(){
new CountDownTimer(10000, 10000) { // 5000 = 5 sec
public void onTick(long millisUntilFinished) {
try {
startRecording();
} catch (Exception e) {
e.printStackTrace();
}
Toast.makeText(HomeActivity.this, R.string.record_audio, Toast.LENGTH_LONG).show();
}
public void onFinish() {
stopRecording();
mProgressDialog.dismiss();
Toast.makeText(HomeActivity.this, R.string.record_saved, Toast.LENGTH_LONG).show();
}
}.start();
}
可能您的存储没有挂载。我尤其在 CyanogenMod 系统上遇到默认情况下未安装 sotrages 的问题。只要确保通过简单地调用就可以安装存储:
boolean isMountend = Environment.getExternalStorageState().
equals(android.os.Environment.MEDIA_MOUNTED);
当您通过电缆连接复制它们时,它们不会出现。您需要通过 WiFi 连接,然后打开 phone 上的录音,然后点击右上角的选项。将有一个选项可以将其上传到 Google 驱动器。上传到您的帐户后,将其下载到您的桌面驱动器。