Example usage for android.provider MediaStore ACTION_VIDEO_CAPTURE

List of usage examples for android.provider MediaStore ACTION_VIDEO_CAPTURE

Introduction

In this page you can find the example usage for android.provider MediaStore ACTION_VIDEO_CAPTURE.

Prototype

String ACTION_VIDEO_CAPTURE

To view the source code for android.provider MediaStore ACTION_VIDEO_CAPTURE.

Click Source Link

Document

Standard Intent action that can be sent to have the camera application capture a video and return it.

Usage

From source file:Main.java

public static void takeVideo(Activity ac) {

    Intent intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
    intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 1);

    ac.startActivityForResult(intent, TAKE_VIDEO);
}

From source file:Main.java

public static Intent buildVideoIntent(Context context, Uri uri) {

    String title = "Choose photo";

    //Build galleryIntent
    Intent galleryIntent = new Intent(Intent.ACTION_PICK);

    galleryIntent.setType("video/*");
    //Create chooser
    Intent chooser = Intent.createChooser(galleryIntent, title);

    Intent cameraIntent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);

    cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, uri);
    Intent[] extraIntents = { cameraIntent };
    chooser.putExtra(Intent.EXTRA_INITIAL_INTENTS, extraIntents);
    return chooser;

}

From source file:Main.java

public static Intent captureVideo(Uri output) {
    final Intent intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
    if (output != null) {
        intent.putExtra(MediaStore.EXTRA_OUTPUT, output);
    }/*from   www .  j av  a  2  s .c  om*/
    return intent;
}

From source file:Main.java

public static boolean supportsExtraOutput(String intentAction) {
    if (Build.MANUFACTURER.equalsIgnoreCase("samsung")
            && (Build.MODEL.startsWith("GT-") || Build.MODEL.startsWith("SM-"))) {
        // Samsung *Galaxy Models* contain a Camera app that does not implement EXTRA_OUTPUT properly.
        // Either doesn't support it or have a different behavior than the specified (e.g. Copies the
        // media file to both the destination path in the uri and the default gallery path).
        return false;
    }/*from   ww w  . j ava  2 s  .co  m*/

    if (MediaStore.ACTION_IMAGE_CAPTURE.equals(intentAction)) {
        // Nexus One and other devices must use EXTRA_OUTPUT due to a bug with the default mechanism.
        // http://thanksmister.com/2012/03/16/android_null_data_camera_intent/
        return true;
    } else if (MediaStore.ACTION_VIDEO_CAPTURE.equals(intentAction)) {
        // Some older devices like the Nexus One for ACTION_VIDEO_CAPTURE, don't support it. Use only on >= ICS.
        // Also, make sure to use EXTRA_OUTPUT due to a bug in Android 4.3 and later if not using it.
        // https://code.google.com/p/android/issues/detail?id=57996
        return (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH);
    } else { // MediaStore.Audio.Media.RECORD_SOUND_ACTION
        return true;
    }
}

From source file:Main.java

/**
 * Returns an intent calling the android chooser. The chooser will provide apps, which listen to one of the following actions
 * {@link Intent#ACTION_GET_CONTENT} , {@link MediaStore#ACTION_IMAGE_CAPTURE}, {@link MediaStore#ACTION_VIDEO_CAPTURE},
 * {@link MediaStore.Audio.Media#RECORD_SOUND_ACTION}
 * //w w w  . j  a v  a 2 s .c om
 * @return Intent that opens the app chooser.
 */
public static Intent getChooserIntent() {
    // GET_CONTENT Apps
    Intent getContentIntent = new Intent();
    getContentIntent.setAction(Intent.ACTION_GET_CONTENT);
    getContentIntent.setType("*/*");
    getContentIntent.addCategory(Intent.CATEGORY_OPENABLE);
    // ACTION_IMAGE_CAPTURE Apps
    Intent captureImageIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    // ACTION_VIDEO_CAPTURE Apps
    Intent captureVideoIntent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
    // RECORD_SOUND_ACTION Apps
    Intent recordSoungIntent = new Intent(MediaStore.Audio.Media.RECORD_SOUND_ACTION);
    Intent finalIntent = Intent.createChooser(getContentIntent, "test");
    finalIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS,
            new Intent[] { captureImageIntent, captureVideoIntent, recordSoungIntent });
    return finalIntent;
}

From source file:disono.webmons.com.utilities.sensor.Camera.Launcher.java

public void takeVideo(String duration, String quality) {
    Intent intent = new Intent(android.provider.MediaStore.ACTION_VIDEO_CAPTURE);

    // Specify the maximum allowed recording duration in seconds.
    if (duration != null) {
        intent.putExtra("android.intent.extra.durationLimit", duration);
    }/*from   www .ja  v  a2s. c  o m*/

    // The name of the Intent-extra used to control the quality of a recorded video. This is an integer property.
    // Currently value 0 means low quality, suitable for MMS messages, and value 1 means high quality. In the future other quality levels may be added.
    if (quality != null) {
        intent.putExtra("android.intent.extra.videoQuality", quality);
    }

    mActivity.startActivityForResult(intent, REQUEST_VIDEO_CAPTURE);
}

From source file:org.alfresco.mobile.android.application.capture.VideoCapture.java

@Override
public boolean captureData() {
    if (hasDevice()) {
        try {//from  w w w  . j ava  2  s .c o m

            File folder = parentFolder;
            if (folder != null) {
                Intent intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
                if (intent.resolveActivity(context.getPackageManager()) == null) {
                    AlfrescoNotificationManager.getInstance(context).showAlertCrouton(parentActivity,
                            context.getString(R.string.feature_disable));
                    return false;
                }

                payload = new File(folder.getPath(), createFilename("VID", "mp4"));

                intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(payload));
                intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 0);
                // Represents a limit of 300Mb
                intent.putExtra(MediaStore.EXTRA_SIZE_LIMIT, 314572800L);

                parentActivity.startActivityForResult(intent, getRequestCode());
            } else {
                AlfrescoNotificationManager.getInstance(parentActivity)
                        .showLongToast(parentActivity.getString(R.string.sdinaccessible));
            }
        } catch (Exception e) {
            Log.d(TAG, Log.getStackTraceString(e));
            return false;
        }

        return true;
    } else {
        return false;
    }
}

From source file:com.commonsware.android.videorecord.MainActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    if (savedInstanceState == null) {
        output = new File(new File(getFilesDir(), VIDEOS), FILENAME);

        if (output.exists()) {
            output.delete();//from  ww  w  . j av  a  2  s. com
        } else {
            output.getParentFile().mkdirs();
        }
    } else {
        output = (File) savedInstanceState.getSerializable(EXTRA_FILENAME);
    }

    outputUri = FileProvider.getUriForFile(this, AUTHORITY, output);

    if (savedInstanceState == null) {
        Intent i = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);

        i.putExtra(MediaStore.EXTRA_OUTPUT, outputUri);
        i.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 1);

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            i.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION | Intent.FLAG_GRANT_READ_URI_PERMISSION);
        } else {
            List<ResolveInfo> resInfoList = getPackageManager().queryIntentActivities(i,
                    PackageManager.MATCH_DEFAULT_ONLY);

            for (ResolveInfo resolveInfo : resInfoList) {
                String packageName = resolveInfo.activityInfo.packageName;

                grantUriPermission(packageName, outputUri,
                        Intent.FLAG_GRANT_WRITE_URI_PERMISSION | Intent.FLAG_GRANT_READ_URI_PERMISSION);
            }
        }

        startActivityForResult(i, REQUEST_ID);
    }
}

From source file:Main.java

public static Intent getIntentForAction(int action) {
    Log.d(TAG, "[AirImagePickerUtils] Entering getIntentForAction");
    Intent intent;//from   w  w  w.  j  av a2s. c o m
    switch (action) {
    case GALLERY_IMAGES_ONLY_ACTION:
        intent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
        Log.d(TAG, "[AirImagePickerUtils] Exiting getIntentForAction");
        return intent;

    case GALLERY_VIDEOS_ONLY_ACTION:
        intent = new Intent(Intent.ACTION_GET_CONTENT);
        intent.setType("video/*");
        Log.d(TAG, "[AirImagePickerUtils] Exiting getIntentForAction");
        return intent;

    case CAMERA_IMAGE_ACTION:
        Log.d(TAG, "[AirImagePickerUtils] Exiting getIntentForAction");
        return new Intent(MediaStore.ACTION_IMAGE_CAPTURE);

    case CAMERA_VIDEO_ACTION:
        Log.d(TAG, "[AirImagePickerUtils] Exiting getIntentForAction");
        return new Intent(MediaStore.ACTION_VIDEO_CAPTURE);

    case CROP_ACTION:
        Log.d(TAG, "[AirImagePickerUtils] Exiting getIntentForAction");
        return new Intent("com.android.camera.action.CROP");

    default:
        Log.d(TAG, "[AirImagePickerUtils] Exiting getIntentForAction");
        return null;
    }
}

From source file:com.diona.videoplugin.CameraUtil.java

/**
 * Method to get a video clip.//from  www.  j a  v a 2s  . c  o m
 * 
 * @param fragment
 *          fragment instance that holds the callback method for the camera utility.
 */
public static void getVideoFromCamera(final Fragment fragment) {
    callingActivity = fragment;
    /*final SocialWorkerSharedPreferences preferences = SocialWorkerSharedPreferences.getInstance();
    final Intent videoIntent = new Intent(android.provider.MediaStore.ACTION_VIDEO_CAPTURE);
    videoIntent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, preferences.getVideoQuality());
            
    final long videoSize = preferences.getVideoSize();
    if (videoSize > 0) {
      videoIntent.putExtra(MediaStore.EXTRA_SIZE_LIMIT, videoSize);
    }
            
    final int videoDuration = preferences.getVideoDuration();
    if (videoDuration > 0) {
      videoIntent.putExtra(MediaStore.EXTRA_DURATION_LIMIT, videoDuration);
    }
            
    videoIntent.putExtra(MediaStore.EXTRA_OUTPUT, FileCacheUtil.getOutputMediaFileUriForVideos());
            
    callingActivity.startActivityForResult(videoIntent, VIDEO_REQUEST);*/

    final Intent videoIntent = new Intent(android.provider.MediaStore.ACTION_VIDEO_CAPTURE);
    videoIntent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 1);

    //final long videoSize = preferences.getVideoSize();
    /* if (videoSize > 0) {
       videoIntent.putExtra(MediaStore.EXTRA_SIZE_LIMIT, 100);
     }*/

    //final int videoDuration = preferences.getVideoDuration();
    /*if (videoDuration > 0) {
      videoIntent.putExtra(MediaStore.EXTRA_DURATION_LIMIT, 60);
    }*/

    videoIntent.putExtra(MediaStore.EXTRA_OUTPUT, FileCacheUtil.getOutputMediaFileUriForVideos());

    callingActivity.startActivityForResult(videoIntent, VIDEO_REQUEST);
}