package com.casic.dcms.utils;

import android.content.Context;
import android.os.Environment;

import java.io.File;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;

public class FileUtils {
    private static final String TAG = "FileUtils";
    private static String videoFilePath;

    public static void init(Context context) {
        File videoDir = new File(context.getExternalFilesDir(Environment.DIRECTORY_MOVIES), "");
        if (!videoDir.exists()) {
            videoDir.mkdir();
        }
        String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss", Locale.CHINA).format(new Date());
        File videoFile = new File(videoDir + File.separator + "VID_" + timeStamp + ".mp4");
        if (!videoFile.exists()) {
            try {
                videoFile.createNewFile();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        videoFilePath = videoFile.getPath();
    }

    public static String getOutputVideoFile() {
        return videoFilePath;
    }
}
