mercredi 6 mai 2015

Android - Review video captured by custom camera before saving it

I can't find any information for this anywhere: I have created an Android custom camera in order to capture short videos. Instead of saving it directly on my mobile phone gallery, I would like first to review the video that I just capured, by watching it right after the recording, and with 2 buttons "Delete" and "OK".

Anyone knows how to do it? Do I have to create a new activity and using an intent?

Here is the current code which save the captured video on my mobile:

/** Saving Media Files */
/* Create a File for saving an image or video */
private static File getOutputMediaFile(int type){

    File mediaStorageDir = new File(Environment.getExternalStoragePublicDirectory(
            Environment.DIRECTORY_PICTURES), "MyCameraApp");
    // This location works best if you want the created images to be shared
    // between applications and persist after your app has been uninstalled.

    // Create the storage directory if it does not exist
    if (! mediaStorageDir.exists()){
        if (! mediaStorageDir.mkdirs()){
            Log.d("The app", "failed to create directory");
            return null;
        }
    }

    // Create a media file name
    String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
    File mediaFile;
    if (type == MEDIA_TYPE_IMAGE){
        mediaFile = new File(mediaStorageDir.getPath() + File.separator +
                "IMG_"+ timeStamp + ".jpg");
    } else if(type == MEDIA_TYPE_VIDEO) {
        mediaFile = new File(mediaStorageDir.getPath() + File.separator +
                "VID_"+ timeStamp + ".mp4");
    } else {
        return null;
    }

    return mediaFile;
}

Thank you so much for your help.

Aucun commentaire:

Enregistrer un commentaire