fix: 修改摄像模块功能
This commit is contained in:
parent
a136dc0683
commit
1cae1f0252
@ -14,6 +14,7 @@ import android.location.Location;
|
|||||||
import android.media.MediaMetadataRetriever;
|
import android.media.MediaMetadataRetriever;
|
||||||
import android.os.Looper;
|
import android.os.Looper;
|
||||||
import android.os.Message;
|
import android.os.Message;
|
||||||
|
import android.os.SystemClock;
|
||||||
import android.util.DisplayMetrics;
|
import android.util.DisplayMetrics;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@ -21,9 +22,11 @@ import android.view.View;
|
|||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.CheckBox;
|
import android.widget.CheckBox;
|
||||||
|
import android.widget.Chronometer;
|
||||||
import android.widget.CompoundButton;
|
import android.widget.CompoundButton;
|
||||||
import android.widget.FrameLayout;
|
import android.widget.FrameLayout;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import com.github.lazylibrary.util.DensityUtil;
|
import com.github.lazylibrary.util.DensityUtil;
|
||||||
@ -105,6 +108,9 @@ public class PictureActivity extends BaseActivity implements View.OnClickListene
|
|||||||
private final long period = 1; // 记录csv文件的间隔时间,单位为秒
|
private final long period = 1; // 记录csv文件的间隔时间,单位为秒
|
||||||
private ViewGroup layerChange; // 切换地图和相机的父控件
|
private ViewGroup layerChange; // 切换地图和相机的父控件
|
||||||
private boolean isFinishActivity = false; // 是否需要关闭当前activity
|
private boolean isFinishActivity = false; // 是否需要关闭当前activity
|
||||||
|
private TextView videoChronometer;
|
||||||
|
private long recordingTime = 0;// 记录下来的总时间
|
||||||
|
private int oratation = -1; // 是否强制横屏拍摄,默认不强制,0-强制横屏 其他-任意
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int getLayout() {
|
protected int getLayout() {
|
||||||
@ -120,7 +126,9 @@ public class PictureActivity extends BaseActivity implements View.OnClickListene
|
|||||||
|
|
||||||
if (getIntent()!=null) {
|
if (getIntent()!=null) {
|
||||||
finalVideoPath = getIntent().getStringExtra(Constant.INTENT_VIDEO_PATH);
|
finalVideoPath = getIntent().getStringExtra(Constant.INTENT_VIDEO_PATH);
|
||||||
|
oratation = getIntent().getIntExtra(Constant.INTENT_VIDEO_ORATATION, -1);
|
||||||
}
|
}
|
||||||
|
videoChronometer = findViewById(R.id.video_chronometer);
|
||||||
// if (finalVideoPath == null) {
|
// if (finalVideoPath == null) {
|
||||||
// finalVideoPath = Constant.PICTURE_FOLDER+"/final.mp4";
|
// finalVideoPath = Constant.PICTURE_FOLDER+"/final.mp4";
|
||||||
// }
|
// }
|
||||||
@ -145,11 +153,13 @@ public class PictureActivity extends BaseActivity implements View.OnClickListene
|
|||||||
@Override
|
@Override
|
||||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||||
if (isChecked) { // 开始采集,设置按钮文字内容为“结束采集”
|
if (isChecked) { // 开始采集,设置按钮文字内容为“结束采集”
|
||||||
|
if (oratation == 0) { // oratation为0时,拍摄视频必须为横屏
|
||||||
// 如果当前手机是竖向,则不允许拍摄
|
// 如果当前手机是竖向,则不允许拍摄
|
||||||
if (camera.getVideoSize().getWidth()<camera.getVideoSize().getHeight()) {
|
if (camera.getVideoSize().getWidth()<camera.getVideoSize().getHeight()) {
|
||||||
Toast.makeText(PictureActivity.this, "不允许竖向拍摄...", Toast.LENGTH_SHORT).show();
|
Toast.makeText(PictureActivity.this, "不允许竖向拍摄...", Toast.LENGTH_SHORT).show();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
captureVideo.setText("暂停采集");
|
captureVideo.setText("暂停采集");
|
||||||
// stopVideo.setEnabled(false);// 开始采集视频后,禁用停止采集的按钮,必须暂停采集后才可点击停止采集
|
// stopVideo.setEnabled(false);// 开始采集视频后,禁用停止采集的按钮,必须暂停采集后才可点击停止采集
|
||||||
@ -299,7 +309,6 @@ public class PictureActivity extends BaseActivity implements View.OnClickListene
|
|||||||
// long currentTime = AWMp4ParserHelper.getInstance().getVedioTotalTime(new File(finalVideoPath));
|
// long currentTime = AWMp4ParserHelper.getInstance().getVedioTotalTime(new File(finalVideoPath));
|
||||||
timerTask = new CsvTimerTask(new File(finalVideoPath+".txt"));
|
timerTask = new CsvTimerTask(new File(finalVideoPath+".txt"));
|
||||||
timer.schedule(timerTask, 0, period*1000);
|
timer.schedule(timerTask, 0, period*1000);
|
||||||
|
|
||||||
// // 开始采集,每隔2秒实时记录位置信息、视频时间以及设备时间
|
// // 开始采集,每隔2秒实时记录位置信息、视频时间以及设备时间
|
||||||
// if (currentTime == 0) {
|
// if (currentTime == 0) {
|
||||||
// timer.schedule(timerTask, 0, period*1000);
|
// timer.schedule(timerTask, 0, period*1000);
|
||||||
@ -319,10 +328,11 @@ public class PictureActivity extends BaseActivity implements View.OnClickListene
|
|||||||
// Toast.makeText(PictureActivity.this, "请先拍照", Toast.LENGTH_SHORT).show();
|
// Toast.makeText(PictureActivity.this, "请先拍照", Toast.LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
// 一段视频拍摄完成自动将当前拍摄路径加1
|
// 一段视频拍摄完成自动将当前拍摄路径加1
|
||||||
int lastSubIndex = finalVideoPath.lastIndexOf("-");
|
File finalVideoFile = new File(finalVideoPath);
|
||||||
int lastPointIndex= finalVideoPath.lastIndexOf(".mp4");
|
if (finalVideoFile.exists()) {
|
||||||
String videoIndex = finalVideoPath.substring(lastSubIndex+1, lastPointIndex);
|
int videoIndex = Integer.parseInt(finalVideoFile.getName().replace(".mp4", ""));
|
||||||
finalVideoPath = finalVideoPath.substring(0, lastSubIndex) +"-"+(Integer.parseInt(videoIndex)+1)+".mp4";
|
finalVideoPath = finalVideoFile.getParentFile().getAbsolutePath()+"/"+(videoIndex+1)+".mp4";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -336,6 +346,14 @@ public class PictureActivity extends BaseActivity implements View.OnClickListene
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 将秒转化成小时分钟秒
|
||||||
|
private String formatMiss(long miss){
|
||||||
|
String hh=miss/3600>9?miss/3600+"":"0"+miss/3600;
|
||||||
|
String mm=(miss % 3600)/60>9?(miss % 3600)/60+"":"0"+(miss % 3600)/60;
|
||||||
|
String ss=(miss % 3600) % 60>9?(miss % 3600) % 60+"":"0"+(miss % 3600) % 60;
|
||||||
|
return hh+":"+mm+":"+ss;
|
||||||
|
}
|
||||||
|
|
||||||
private void message(String content, Boolean important) {
|
private void message(String content, Boolean important) {
|
||||||
if (important) {
|
if (important) {
|
||||||
LOG.w(content);
|
LOG.w(content);
|
||||||
@ -380,7 +398,6 @@ public class PictureActivity extends BaseActivity implements View.OnClickListene
|
|||||||
|
|
||||||
|
|
||||||
public void stopVideoAndFinish() {
|
public void stopVideoAndFinish() {
|
||||||
showLoadingDialog();
|
|
||||||
if (timerTask!=null){
|
if (timerTask!=null){
|
||||||
timerTask.cancel();
|
timerTask.cancel();
|
||||||
Intent intent = new Intent();
|
Intent intent = new Intent();
|
||||||
@ -390,6 +407,7 @@ public class PictureActivity extends BaseActivity implements View.OnClickListene
|
|||||||
Toast.makeText(this, "本段视频没有计时!", Toast.LENGTH_SHORT).show();
|
Toast.makeText(this, "本段视频没有计时!", Toast.LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
if (camera.isTakingVideo()) {
|
if (camera.isTakingVideo()) {
|
||||||
|
showLoadingDialog();
|
||||||
isFinishActivity = true;
|
isFinishActivity = true;
|
||||||
camera.stopVideo();
|
camera.stopVideo();
|
||||||
} else {
|
} else {
|
||||||
@ -581,8 +599,16 @@ public class PictureActivity extends BaseActivity implements View.OnClickListene
|
|||||||
sb.append("\r\n");
|
sb.append("\r\n");
|
||||||
FileUtils.writeFile(csvFile.getAbsolutePath(), sb.toString(), true);
|
FileUtils.writeFile(csvFile.getAbsolutePath(), sb.toString(), true);
|
||||||
currentVideoTime = currentVideoTime+period; //
|
currentVideoTime = currentVideoTime+period; //
|
||||||
|
recordingTime += period;
|
||||||
|
runOnUiThread(updateTimeRunnable);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Runnable updateTimeRunnable = new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
videoChronometer.setText(formatMiss(recordingTime));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
}
|
}
|
@ -109,6 +109,7 @@ public class Constant {
|
|||||||
public static MapView treasureMap;
|
public static MapView treasureMap;
|
||||||
|
|
||||||
public static final String INTENT_VIDEO_PATH = "INTENT_VIDEO_PATH"; // 拍照界面指定的视频文件保存位置
|
public static final String INTENT_VIDEO_PATH = "INTENT_VIDEO_PATH"; // 拍照界面指定的视频文件保存位置
|
||||||
|
public static final String INTENT_VIDEO_ORATATION = "INTENT_VIDEO_ORATATION"; // 视频拍摄时屏幕方向 0-强制横屏 其他-任意
|
||||||
|
|
||||||
public static boolean IS_FILTER_LIST_ITEM =true;//poi页面的查重
|
public static boolean IS_FILTER_LIST_ITEM =true;//poi页面的查重
|
||||||
}
|
}
|
||||||
|
@ -166,7 +166,7 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
File finalFile = AWMp4ParserHelper.getInstance().obtainMp4FilePath(showPoiEntity.getId(), fmPoiVideoPic.getTag());
|
File finalFile = AWMp4ParserHelper.getInstance().obtainMp4FilePath(new File(Constant.PICTURE_FOLDER, showPoiEntity.getId()).getAbsolutePath());
|
||||||
Intent intent = new Intent(getContext(), PictureActivity.class);
|
Intent intent = new Intent(getContext(), PictureActivity.class);
|
||||||
intent.putExtra(Constant.INTENT_VIDEO_PATH, finalFile.getAbsolutePath());
|
intent.putExtra(Constant.INTENT_VIDEO_PATH, finalFile.getAbsolutePath());
|
||||||
startActivityForResult(intent, 0x101);
|
startActivityForResult(intent, 0x101);
|
||||||
@ -298,7 +298,7 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
|
|||||||
// String videoFormatName = formatter.format(new Date());
|
// String videoFormatName = formatter.format(new Date());
|
||||||
|
|
||||||
Intent intent = new Intent(getContext(), PictureActivity.class);
|
Intent intent = new Intent(getContext(), PictureActivity.class);
|
||||||
File finalFile = AWMp4ParserHelper.getInstance().obtainMp4FilePath(showPoiEntity.getId(), fmPoiVideoPic.getTag());
|
File finalFile = AWMp4ParserHelper.getInstance().obtainMp4FilePath(new File(Constant.PICTURE_FOLDER, showPoiEntity.getId()).getAbsolutePath());
|
||||||
intent.putExtra(Constant.INTENT_VIDEO_PATH, finalFile.getAbsolutePath());
|
intent.putExtra(Constant.INTENT_VIDEO_PATH, finalFile.getAbsolutePath());
|
||||||
startActivityForResult(intent, 0x101);
|
startActivityForResult(intent, 0x101);
|
||||||
break;
|
break;
|
||||||
@ -636,6 +636,7 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
|
|||||||
//根据要保存的数据的类型,调用对应的put方法,
|
//根据要保存的数据的类型,调用对应的put方法,
|
||||||
|
|
||||||
PoiEntity poiEntity = new PoiEntity();
|
PoiEntity poiEntity = new PoiEntity();
|
||||||
|
poiEntity.setId(showPoiEntity.getId());
|
||||||
String roadName = etRoadName.getText().toString().trim();
|
String roadName = etRoadName.getText().toString().trim();
|
||||||
if (roadName != null && !roadName.equals("")) {
|
if (roadName != null && !roadName.equals("")) {
|
||||||
poiEntity.setName(roadName);
|
poiEntity.setName(roadName);
|
||||||
@ -656,7 +657,11 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
|
|||||||
poiEntity.setType(3);
|
poiEntity.setType(3);
|
||||||
poiEntity.setTaskStatus(2);
|
poiEntity.setTaskStatus(2);
|
||||||
poiEntity.setIsLocalData(1);
|
poiEntity.setIsLocalData(1);
|
||||||
poiEntity.setPhoto(getPhotoStrFromTag());
|
poiEntity.setX(showPoiEntity.getX());
|
||||||
|
poiEntity.setY(showPoiEntity.getY());
|
||||||
|
List<File> videoFileListByUUID = AWMp4ParserHelper.getInstance().getVideoFileListByUUID(showPoiEntity.getId());
|
||||||
|
String photoStr = AWMp4ParserHelper.getInstance().getVideoFileListStr(videoFileListByUUID);
|
||||||
|
poiEntity.setPhoto(photoStr);
|
||||||
String newPoiEntity = new Gson().toJson(poiEntity);
|
String newPoiEntity = new Gson().toJson(poiEntity);
|
||||||
//以键值对的形式添加新值。
|
//以键值对的形式添加新值。
|
||||||
edit.putString("poiEntity", newPoiEntity);
|
edit.putString("poiEntity", newPoiEntity);
|
||||||
|
@ -168,9 +168,10 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
File finalFile = AWMp4ParserHelper.getInstance().obtainMp4FilePath(showPoiEntity.getId(), fmRoadPic.getTag());
|
File finalFile = AWMp4ParserHelper.getInstance().obtainMp4FilePath(new File(Constant.PICTURE_FOLDER, showPoiEntity.getId()).getAbsolutePath());
|
||||||
Intent intent = new Intent(getContext(), PictureActivity.class);
|
Intent intent = new Intent(getContext(), PictureActivity.class);
|
||||||
intent.putExtra(Constant.INTENT_VIDEO_PATH, finalFile.getAbsolutePath());
|
intent.putExtra(Constant.INTENT_VIDEO_PATH, finalFile.getAbsolutePath());
|
||||||
|
intent.putExtra(Constant.INTENT_VIDEO_ORATATION, 0);
|
||||||
startActivityForResult(intent, 0x101);
|
startActivityForResult(intent, 0x101);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -310,8 +311,9 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList
|
|||||||
// DateFormat formatter = new SimpleDateFormat("yyyyMMddHHmmss");
|
// DateFormat formatter = new SimpleDateFormat("yyyyMMddHHmmss");
|
||||||
// String videoFormatName = formatter.format(new Date());
|
// String videoFormatName = formatter.format(new Date());
|
||||||
Intent intent = new Intent(getContext(), PictureActivity.class);
|
Intent intent = new Intent(getContext(), PictureActivity.class);
|
||||||
File finalFile = AWMp4ParserHelper.getInstance().obtainMp4FilePath(showPoiEntity.getId(), fmRoadPic.getTag());
|
File finalFile = AWMp4ParserHelper.getInstance().obtainMp4FilePath(new File(Constant.PICTURE_FOLDER, showPoiEntity.getId()).getAbsolutePath());
|
||||||
intent.putExtra(Constant.INTENT_VIDEO_PATH, finalFile.getAbsolutePath());
|
intent.putExtra(Constant.INTENT_VIDEO_PATH, finalFile.getAbsolutePath());
|
||||||
|
intent.putExtra(Constant.INTENT_VIDEO_ORATATION, 0);
|
||||||
startActivityForResult(intent, 0x101);
|
startActivityForResult(intent, 0x101);
|
||||||
break;
|
break;
|
||||||
case R.id.road_upload:
|
case R.id.road_upload:
|
||||||
@ -407,7 +409,7 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList
|
|||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
String lineString = GeometryTools.getLineString(getLineString());
|
String lineString = GeometryTools.getLineString(AWMp4ParserHelper.getInstance().getLineStringByVideoFileList((List<File>) fmRoadPic.getTag()));
|
||||||
String filePathString = getPhotoStrFromTag();
|
String filePathString = getPhotoStrFromTag();
|
||||||
Log.d("TAG", "onGranted: " + lineString);
|
Log.d("TAG", "onGranted: " + lineString);
|
||||||
poiEntity.setPhoto(filePathString);
|
poiEntity.setPhoto(filePathString);
|
||||||
@ -474,30 +476,7 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList
|
|||||||
return filePathStringBuilder.toString();
|
return filePathStringBuilder.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<LatLng> getLineString() {
|
|
||||||
List<File> videoFileList = (List<File>) fmRoadPic.getTag();
|
|
||||||
|
|
||||||
List<LatLng> latLngs = new ArrayList<>();
|
|
||||||
StringBuilder filePathStringBuilder = new StringBuilder("");
|
|
||||||
for (int m = 0; m < videoFileList.size(); m++) {
|
|
||||||
File videoFile = videoFileList.get(m);
|
|
||||||
|
|
||||||
String path = videoFile.getPath() + ".txt";
|
|
||||||
List<String> strings = FileUtils.readFileToList(path, "utf-8");
|
|
||||||
for (int i = 0; i < strings.size(); i++) {
|
|
||||||
String[] split = strings.get(i).split(",");
|
|
||||||
LatLng latLng = new LatLng();
|
|
||||||
latLng.setLatitude(Double.valueOf(split[2]));
|
|
||||||
latLng.setLongitude(Double.valueOf(split[3]));
|
|
||||||
latLngs.add(latLng);
|
|
||||||
}
|
|
||||||
if (strings.size() == 1) {
|
|
||||||
LatLng latLng = latLngs.get(0);
|
|
||||||
latLngs.add(latLng);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return latLngs;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void poiVideoUpload(int body, File fileZip) {
|
private void poiVideoUpload(int body, File fileZip) {
|
||||||
if (body == 0) {
|
if (body == 0) {
|
||||||
@ -631,6 +610,9 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList
|
|||||||
@Override
|
@Override
|
||||||
public boolean onClick(BaseDialog baseDialog, View v) {
|
public boolean onClick(BaseDialog baseDialog, View v) {
|
||||||
Intent intentPanorama = new Intent(getActivity(),PictureActivity.class);
|
Intent intentPanorama = new Intent(getActivity(),PictureActivity.class);
|
||||||
|
File finalFile = AWMp4ParserHelper.getInstance().obtainMp4FilePath(new File(Constant.PICTURE_FOLDER, showPoiEntity.getId()).getAbsolutePath());
|
||||||
|
intentPanorama.putExtra(Constant.INTENT_VIDEO_PATH, finalFile.getAbsolutePath());
|
||||||
|
intentPanorama.putExtra(Constant.INTENT_VIDEO_ORATATION, 0);
|
||||||
startActivityForResult(intentPanorama, 0x101);
|
startActivityForResult(intentPanorama, 0x101);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -685,6 +667,7 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList
|
|||||||
//根据要保存的数据的类型,调用对应的put方法,
|
//根据要保存的数据的类型,调用对应的put方法,
|
||||||
|
|
||||||
PoiEntity poiEntity = new PoiEntity();
|
PoiEntity poiEntity = new PoiEntity();
|
||||||
|
poiEntity.setId(showPoiEntity.getId());
|
||||||
String roadName = etRoadName.getText().toString().trim();
|
String roadName = etRoadName.getText().toString().trim();
|
||||||
if (roadName != null && !roadName.equals("")) {
|
if (roadName != null && !roadName.equals("")) {
|
||||||
poiEntity.setName(roadName);
|
poiEntity.setName(roadName);
|
||||||
@ -710,6 +693,11 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList
|
|||||||
poiEntity.setType(4);
|
poiEntity.setType(4);
|
||||||
poiEntity.setTaskStatus(2);
|
poiEntity.setTaskStatus(2);
|
||||||
poiEntity.setIsLocalData(1);
|
poiEntity.setIsLocalData(1);
|
||||||
|
poiEntity.setX(showPoiEntity.getX());
|
||||||
|
poiEntity.setY(showPoiEntity.getY());
|
||||||
|
List<File> videoFileListByUUID = AWMp4ParserHelper.getInstance().getVideoFileListByUUID(showPoiEntity.getId());
|
||||||
|
String photoStr = AWMp4ParserHelper.getInstance().getVideoFileListStr(videoFileListByUUID);
|
||||||
|
poiEntity.setPhoto(photoStr);
|
||||||
String newPoiEntity = new Gson().toJson(poiEntity);
|
String newPoiEntity = new Gson().toJson(poiEntity);
|
||||||
//以键值对的形式添加新值。
|
//以键值对的形式添加新值。
|
||||||
edit.putString("poiEntity", newPoiEntity);
|
edit.putString("poiEntity", newPoiEntity);
|
||||||
|
@ -14,6 +14,7 @@ import com.bumptech.glide.load.resource.bitmap.BitmapTransformation;
|
|||||||
import com.bumptech.glide.load.resource.bitmap.VideoDecoder;
|
import com.bumptech.glide.load.resource.bitmap.VideoDecoder;
|
||||||
import com.bumptech.glide.request.RequestOptions;
|
import com.bumptech.glide.request.RequestOptions;
|
||||||
import com.coremedia.iso.boxes.Container;
|
import com.coremedia.iso.boxes.Container;
|
||||||
|
import com.github.lazylibrary.util.FileUtils;
|
||||||
import com.github.lazylibrary.util.StringUtils;
|
import com.github.lazylibrary.util.StringUtils;
|
||||||
import com.googlecode.mp4parser.authoring.Movie;
|
import com.googlecode.mp4parser.authoring.Movie;
|
||||||
import com.googlecode.mp4parser.authoring.Track;
|
import com.googlecode.mp4parser.authoring.Track;
|
||||||
@ -21,6 +22,7 @@ import com.googlecode.mp4parser.authoring.builder.DefaultMp4Builder;
|
|||||||
import com.googlecode.mp4parser.authoring.container.mp4.MovieCreator;
|
import com.googlecode.mp4parser.authoring.container.mp4.MovieCreator;
|
||||||
import com.googlecode.mp4parser.authoring.tracks.AppendTrack;
|
import com.googlecode.mp4parser.authoring.tracks.AppendTrack;
|
||||||
import com.navinfo.outdoor.api.Constant;
|
import com.navinfo.outdoor.api.Constant;
|
||||||
|
import com.tencent.tencentmap.mapsdk.maps.model.LatLng;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileFilter;
|
import java.io.FileFilter;
|
||||||
@ -237,7 +239,7 @@ public class AWMp4ParserHelper {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (fileList == null || fileList.length==0) {
|
if (fileList == null || fileList.length==0) {
|
||||||
return new File(Constant.PICTURE_FOLDER+"/0.mp4");
|
return new File(folderPath+"/0.mp4");
|
||||||
}
|
}
|
||||||
int maxIndex = 0;
|
int maxIndex = 0;
|
||||||
for (int i = 0; i < fileList.length; i++) {
|
for (int i = 0; i < fileList.length; i++) {
|
||||||
@ -249,6 +251,73 @@ public class AWMp4ParserHelper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return new File(Constant.PICTURE_FOLDER+"/"+(maxIndex+1)+".mp4");
|
return new File(folderPath+"/"+(maxIndex+1)+".mp4");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据提供的uuid,获取指定目录下所有的视频文件
|
||||||
|
* */
|
||||||
|
public List<File> getVideoFileListByUUID(String uuid) {
|
||||||
|
List<File> videoFileList = new ArrayList<>();
|
||||||
|
if (StringUtils.isEmpty(uuid)) {
|
||||||
|
return videoFileList;
|
||||||
|
}
|
||||||
|
File folderFile = new File(Constant.PICTURE_FOLDER+"/"+uuid+"/");
|
||||||
|
if (!folderFile.exists()) {
|
||||||
|
folderFile.mkdirs();
|
||||||
|
return videoFileList;
|
||||||
|
}
|
||||||
|
for (File videoFile: folderFile.listFiles()) {
|
||||||
|
videoFileList.add(videoFile);
|
||||||
|
}
|
||||||
|
return videoFileList;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getVideoFileListStr(List<File> videoFileList) {
|
||||||
|
StringBuilder resultStrBuilder = new StringBuilder("");
|
||||||
|
if (videoFileList == null || videoFileList.size()<=0){
|
||||||
|
return resultStrBuilder.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < videoFileList.size(); i++) {
|
||||||
|
File f = videoFileList.get(i);
|
||||||
|
resultStrBuilder.append(f.getAbsolutePath());
|
||||||
|
if (i < videoFileList.size() -1) {
|
||||||
|
resultStrBuilder.append(",");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return resultStrBuilder.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据视频文件列表,获取到对应的轨迹数据
|
||||||
|
* */
|
||||||
|
public List<LatLng> getLineStringByVideoFileList(List<File> videoFileList) {
|
||||||
|
List<LatLng> latLngs = new ArrayList<>();
|
||||||
|
if (videoFileList == null || videoFileList.isEmpty()) {
|
||||||
|
return latLngs;
|
||||||
|
}
|
||||||
|
|
||||||
|
StringBuilder filePathStringBuilder = new StringBuilder("");
|
||||||
|
for (int m = 0; m < videoFileList.size(); m++) {
|
||||||
|
File videoFile = videoFileList.get(m);
|
||||||
|
|
||||||
|
String path = videoFile.getPath() + ".txt";
|
||||||
|
List<String> strings = FileUtils.readFileToList(path, "utf-8");
|
||||||
|
if (strings!=null) {
|
||||||
|
for (int i = 0; i < strings.size(); i++) {
|
||||||
|
String[] split = strings.get(i).split(",");
|
||||||
|
LatLng latLng = new LatLng();
|
||||||
|
latLng.setLatitude(Double.valueOf(split[2]));
|
||||||
|
latLng.setLongitude(Double.valueOf(split[3]));
|
||||||
|
latLngs.add(latLng);
|
||||||
|
}
|
||||||
|
if (strings.size() == 1) {
|
||||||
|
LatLng latLng = latLngs.get(0);
|
||||||
|
latLngs.add(latLng);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return latLngs;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -76,5 +76,17 @@
|
|||||||
app:layout_constraintBottom_toBottomOf="@id/capuretVideo"
|
app:layout_constraintBottom_toBottomOf="@id/capuretVideo"
|
||||||
app:layout_constraintLeft_toRightOf="@id/capuretVideo"
|
app:layout_constraintLeft_toRightOf="@id/capuretVideo"
|
||||||
app:layout_constraintRight_toRightOf="parent" />
|
app:layout_constraintRight_toRightOf="parent" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/video_chronometer"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
app:layout_constraintLeft_toLeftOf="parent"
|
||||||
|
app:layout_constraintRight_toRightOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
android:background="@color/whiteAlpha50"
|
||||||
|
android:padding="@dimen/default_widget_padding"
|
||||||
|
android:format="00:00:00"
|
||||||
|
android:layout_marginTop="@dimen/default_widget_padding"></TextView>
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user