mirror of
https://github.com/FossifyOrg/Camera.git
synced 2026-06-13 10:42:09 -04:00
implement video recording
This commit is contained in:
@@ -1,10 +1,17 @@
|
||||
package com.simplemobiletools.camera;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.hardware.Camera;
|
||||
import android.media.MediaScannerConnection;
|
||||
import android.os.Environment;
|
||||
import android.widget.Toast;
|
||||
|
||||
import java.io.File;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
public class Utils {
|
||||
public static Camera.CameraInfo getCameraInfo(int cameraId) {
|
||||
@@ -36,4 +43,38 @@ public class Utils {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static String getOutputMediaFile(Context context, boolean isPhoto) {
|
||||
final File mediaStorageDir = getFolderName(context, isPhoto);
|
||||
|
||||
if (!mediaStorageDir.exists()) {
|
||||
if (!mediaStorageDir.mkdirs()) {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
final String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss", Locale.getDefault()).format(new Date());
|
||||
if (isPhoto) {
|
||||
return mediaStorageDir.getPath() + File.separator + "IMG_" + timeStamp + ".jpg";
|
||||
} else {
|
||||
return mediaStorageDir.getPath() + File.separator + "VID_" + timeStamp + ".mp4";
|
||||
}
|
||||
}
|
||||
|
||||
private static File getFolderName(Context context, boolean isPhoto) {
|
||||
final Resources res = context.getResources();
|
||||
final String appName = res.getString(R.string.app_name);
|
||||
final String sharedPath = new File(Environment.getExternalStorageDirectory(), appName).getAbsolutePath();
|
||||
String typeDirectory = res.getString(R.string.photo_directory);
|
||||
if (!isPhoto) {
|
||||
typeDirectory = res.getString(R.string.video_directory);
|
||||
}
|
||||
|
||||
return new File(sharedPath, typeDirectory);
|
||||
}
|
||||
|
||||
public static void scanFile(String path, Context context) {
|
||||
final String[] paths = {path};
|
||||
MediaScannerConnection.scanFile(context, paths, null, null);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user