Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

添加临时文件路径的配置 #80

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,13 @@ public void changeRecordDir(String recordDir) {
RecordService.changeRecordDir(recordDir);
}

/**
* 修改录音临时文件的存放路径
*/
public void changeTempRecordDir(String tempRecordDir) {
RecordService.changeTempRecordDir(tempRecordDir);
}

/**
* 获取当前的录音状态
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
import android.media.AudioFormat;
import android.os.Environment;

import com.zlw.main.recorderlib.utils.FileUtils;

import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.util.Locale;

/**
Expand Down Expand Up @@ -53,6 +56,15 @@ public class RecordConfig implements Serializable {
"%s/Record/",
Environment.getExternalStorageDirectory().getAbsolutePath());

/**
* 临时录音存放文件, 默认sdcard/Record
*/
private String tempRecordDir = String.format(
Locale.getDefault(),
"%s/Record/",
Environment.getExternalStorageDirectory().getAbsolutePath()
);

public RecordConfig() {
}

Expand Down Expand Up @@ -86,6 +98,14 @@ public void setRecordDir(String recordDir) {
this.recordDir = recordDir;
}

public String getTempRecordDir() {
return tempRecordDir;
}

public void setTempRecordDir(String tempRecordDir) {
this.tempRecordDir = tempRecordDir;
}

/**
* 获取当前录音的采样位宽 单位bit
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,8 @@ private boolean mergePcmFiles(File recordFile, List<File> files) {
* 实例 record_20160101_13_15_12
*/
private String getTempFilePath() {
String fileDir = String.format(Locale.getDefault(), "%s/Record/", Environment.getExternalStorageDirectory().getAbsolutePath());
String fileDir =
currentConfig.getTempRecordDir();
if (!FileUtils.createOrExistsDir(fileDir)) {
Logger.e(TAG, "文件夹创建失败:%s", fileDir);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,10 @@ public static void changeRecordDir(String recordDir) {
currentConfig.setRecordDir(recordDir);
}

public static void changeTempRecordDir(String tempRecordDir) {
currentConfig.setTempRecordDir(tempRecordDir);
}

/**
* 获取当前的录音状态
*/
Expand Down