fix: 修改摄像功能

This commit is contained in:
XiaoYan 2021-08-05 19:41:09 +08:00
parent 0493be4e4d
commit ccefbc65a0
5 changed files with 68 additions and 5 deletions

View File

@ -3,7 +3,7 @@ apply plugin: 'com.android.application'
android {
compileSdkVersion 29
buildToolsVersion '29.0.2'
ndkVersion '23.0.7123448'
ndkVersion '21.0.6113669'
defaultConfig {
applicationId "com.navinfo.outdoor"

View File

@ -145,13 +145,19 @@ public class PictureActivity extends BaseActivity implements View.OnClickListene
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked) { // 开始采集设置按钮文字内容为结束采集
captureVideo.setText("结束采集");
// 如果当前手机是竖向则不允许拍摄
if (camera.getVideoSize().getWidth()<camera.getVideoSize().getHeight()) {
Toast.makeText(PictureActivity.this, "不允许竖向拍摄...", Toast.LENGTH_SHORT).show();
return;
}
captureVideo.setText("暂停采集");
// stopVideo.setEnabled(false);// 开始采集视频后禁用停止采集的按钮必须暂停采集后才可点击停止采集
startTakenVideo(); // 开始采集视频
} else {
// stopTakenVideo();
stopTakenVideo();
captureVideo.setText("开始采集");
stopVideoAndFinish();
// stopVideoAndFinish();
}
}
});
@ -312,6 +318,11 @@ public class PictureActivity extends BaseActivity implements View.OnClickListene
}else {
// Toast.makeText(PictureActivity.this, "请先拍照", Toast.LENGTH_SHORT).show();
}
// 一段视频拍摄完成自动将当前拍摄路径加1
int lastSubIndex = finalVideoPath.lastIndexOf("-");
int lastPointIndex= finalVideoPath.lastIndexOf(".mp4");
String videoIndex = finalVideoPath.substring(lastSubIndex+1, lastPointIndex);
finalVideoPath = finalVideoPath.substring(0, lastSubIndex) +"-"+(Integer.parseInt(videoIndex)+1)+".mp4";
}
});

View File

@ -578,6 +578,8 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList
if (requestCode == 0x101) {
if (resultCode == 0x101) {
if (data != null && data.hasExtra(Constant.INTENT_VIDEO_PATH)) {
// 扫描照片目录中当前视频的所有视频文件
String videoPath = data.getStringExtra(Constant.INTENT_VIDEO_PATH);
File videoFile = new File(videoPath);
if (videoFile.exists()) {
@ -593,6 +595,20 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList
}
}
private List<File> getAllCurrentPoiVideoFile(String uuid) {
List<File> fileList = new ArrayList<>();
if (StringUtils.isEmpty(uuid)) {
return fileList;
}
File folder = new File(Constant.PICTURE_FOLDER);
if (folder.exists()) {
for (File videoFile: folder.listFiles()) {
}
}
return fileList;
}
@Override
public void onSaveInstanceState(@NonNull Bundle outState) {
super.onSaveInstanceState(outState);

View File

@ -23,6 +23,7 @@ import com.googlecode.mp4parser.authoring.tracks.AppendTrack;
import com.navinfo.outdoor.api.Constant;
import java.io.File;
import java.io.FileFilter;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.nio.channels.FileChannel;
@ -214,4 +215,40 @@ public class AWMp4ParserHelper {
}
return new File(Constant.PICTURE_FOLDER+"/"+uuid+"-"+(maxIndex+1)+".mp4");
}
/**
* 根据文件夹路径生成最新的视频文件路径
* */
public File obtainMp4FilePath(String folderPath) {
if (folderPath == null) {
return null;
}
File folderFile = new File(folderPath);
if (!folderFile.exists()) {
folderFile.mkdirs();
}
File[] fileList = folderFile.listFiles(new FileFilter() {
@Override
public boolean accept(File pathname) {
if (pathname.getName().endsWith(".mp4")){
return true;
}
return false;
}
});
if (fileList == null || fileList.length==0) {
return new File(Constant.PICTURE_FOLDER+"/0.mp4");
}
int maxIndex = 0;
for (int i = 0; i < fileList.length; i++) {
File file = fileList[i];
if (file!=null) {
int index = Integer.parseInt(file.getName().replace(".mp4", ""));
if (index>=maxIndex) {
maxIndex = index;
}
}
}
return new File(Constant.PICTURE_FOLDER+"/"+(maxIndex+1)+".mp4");
}
}

View File

@ -72,7 +72,6 @@
android:layout_height="wrap_content"
android:background="@drawable/uploding_shape"
android:text="结束采集"
android:visibility="gone"
android:textColor="@color/colorBlue"
app:layout_constraintBottom_toBottomOf="@id/capuretVideo"
app:layout_constraintLeft_toRightOf="@id/capuretVideo"