Dana
6 天以前 3c2194940ca57b45b66a6344ad67e9c9f0b861bd
app/src/main/java/com/safeluck/floatwindow/util/VideoFileUtils.java
@@ -67,9 +67,16 @@
     * 生成视频文件名(时分秒.mp4)
     * @return 文件名,例如:143025.mp4
     */
    public static String generateVideoFileName() {
    public static String generateVideoFileName(int usbCamId) {
        SimpleDateFormat timeFormat = new SimpleDateFormat("HHmmss", Locale.getDefault());
        return timeFormat.format(new Date()) + ".mp4";
        if (usbCamId==2){
            return timeFormat.format(new Date()) + "_P2.mp4";
        }else if (usbCamId==1){
            return timeFormat.format(new Date()) + "_P1.mp4";
        }else{
            return timeFormat.format(new Date()) + ".mp4";
        }
    }
    
    /**
@@ -78,24 +85,24 @@
     * @param tfCardFlag 0-内部存储,1-外部存储
     * @return 完整的文件路径
     */
    public static File getVideoFile(Context context, int tfCardFlag) {
    public static File getVideoFile(Context context, int tfCardFlag,int usbCameraId) {
        File dateDir = getVideoDirectory(context, tfCardFlag);
        if (dateDir == null) {
            return null;
        }
        
        String fileName = generateVideoFileName();
        String fileName = generateVideoFileName(usbCameraId);
        return new File(dateDir, fileName);
    }
    
    /**
     * 获取视频文件路径字符串
     * 获取视频文件路径字符串 只能获取到内部相机文件的路径
     * @param context 上下文
     * @param tfCardFlag 0-内部存储,1-外部存储
     * @return 文件路径字符串
     */
    public static String getVideoFilePath(Context context, int tfCardFlag) {
        File file = getVideoFile(context, tfCardFlag);
        File file = getVideoFile(context, tfCardFlag,0);
        return file != null ? file.getAbsolutePath() : null;
    }
}