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:com.dazone.crewchat.libGallery.activity.HomeFragmentActivity.java

@Override
public void onClick(View v) {
    switch (v.getId()) {
    case R.id.cameraImageViewFromMediaChooserHeaderBar:
        if (v.getTag().toString().equals(getResources().getString(R.string.video))) {
            Intent intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
            fileUri = getOutputMediaFileUri(MediaChooserConstants.MEDIA_TYPE_VIDEO); // create a file to save the image
            intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri); // set the image file name

            // start the image capture Intent
            startActivityForResult(intent, MediaChooserConstants.CAPTURE_VIDEO_ACTIVITY_REQUEST_CODE);

        } else {/*from  w w  w . j a v  a  2 s . c  o  m*/
            Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
            fileUri = getOutputMediaFileUri(MediaChooserConstants.MEDIA_TYPE_IMAGE); // create a file to save the image
            intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri); // set the image file name

            // start the image capture Intent
            startActivityForResult(intent, MediaChooserConstants.CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE);
        }
        break;
    case R.id.doneTextViewViewFromMediaChooserHeaderView:
        FragmentManager fragmentManager = getSupportFragmentManager();
        ImageFragment imageFragment = (ImageFragment) fragmentManager.findFragmentByTag("tab1");
        VideoFragment videoFragment = (VideoFragment) fragmentManager.findFragmentByTag("tab2");

        if (videoFragment != null || imageFragment != null) {

            if (videoFragment != null) {
                if (videoFragment.getSelectedVideoList() != null
                        && videoFragment.getSelectedVideoList().size() > 0) {
                    Intent videoIntent = new Intent();
                    videoIntent.setAction(MediaChooser.VIDEO_SELECTED_ACTION_FROM_MEDIA_CHOOSER);
                    videoIntent.putStringArrayListExtra("list", videoFragment.getSelectedVideoList());
                    sendBroadcast(videoIntent);
                } else {
                    Toast.makeText(HomeFragmentActivity.this, getString(R.string.please_select_file),
                            Toast.LENGTH_SHORT).show();
                    return;
                }
            }

            if (imageFragment != null) {
                if (imageFragment.getSelectedImageList() != null
                        && imageFragment.getSelectedImageList().size() > 0) {
                    Intent imageIntent = new Intent();
                    imageIntent.setAction(MediaChooser.IMAGE_SELECTED_ACTION_FROM_MEDIA_CHOOSER);
                    imageIntent.putStringArrayListExtra("list", imageFragment.getSelectedImageList());
                    sendBroadcast(imageIntent);
                } else {
                    Toast.makeText(HomeFragmentActivity.this, getString(R.string.please_select_file),
                            Toast.LENGTH_SHORT).show();
                    return;
                }
            }
            if (BucketHomeFragmentActivity.Instance != null) {
                BucketHomeFragmentActivity.Instance.finish();
            }
            finish();
        } else {
            Toast.makeText(HomeFragmentActivity.this, getString(R.string.please_select_file),
                    Toast.LENGTH_SHORT).show();
        }
        break;
    case R.id.backArrowImageViewFromMediaChooserHeaderView:
        finish();
        break;
    default:
        break;
    }
}

From source file:com.rsmsa.accapp.MainActivity.java

/**
 * Recording video//from   ww  w .j  a va 2  s .c om
 */
private void recordVideo() {
    Intent intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);

    fileUri = getOutputMediaFileUri(MEDIA_TYPE_VIDEO);

    // set video quality
    intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 1);

    intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri); // set the image file
    // name

    // start the video capture Intent
    startActivityForResult(intent, CAMERA_CAPTURE_VIDEO_REQUEST_CODE);
}

From source file:com.google.ytdl.MainActivity.java

public void recordVideo(View view) {
    Intent intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE); // TODO
    // ACTION_GET_CONTENT
    startActivityForResult(intent, RESULT_VIDEO_CAP);
    mButton.setEnabled(true);/*from   w  w w. j  a v  a2s.c o m*/
}

From source file:com.google.yydw.MainActivity.java

public void recordVideo(View view) {
    Intent intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);

    // Workaround for Nexus 7 Android 4.3 Intent Returning Null problem
    // create a file to save the video in specific folder (this works for
    // video only)
    // mFileURI = getOutputMediaFile(MEDIA_TYPE_VIDEO);
    // intent.putExtra(MediaStore.EXTRA_OUTPUT, mFileURI);

    // set the video image quality to high
    intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 1);

    // start the Video Capture Intent
    startActivityForResult(intent, RESULT_VIDEO_CAP);
}

From source file:com.android.cts.verifier.managedprovisioning.ByodHelperActivity.java

public static Intent getCaptureVideoIntent() {
    return new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
}

From source file:com.afrozaar.jazzfestreporting.MainActivity.java

public void recordVideo(View view) {
    Intent intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
    intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 0);
    intent.putExtra(MediaStore.EXTRA_DURATION_LIMIT, 10);

    // Workaround for Nexus 7 Android 4.3 Intent Returning Null problem
    // create a file to save the video in specific folder (this works for
    // video only)
    // mFileURI = getOutputMediaFile(MEDIA_TYPE_VIDEO);
    // intent.putExtra(MediaStore.EXTRA_OUTPUT, mFileURI);

    // set the video image quality to high
    //intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 1);

    // start the Video Capture Intent
    startActivityForResult(intent, RESULT_VIDEO_CAP);
}

From source file:eu.nubomedia.nubomedia_kurento_health_communicator_android.kc_and_communicator.util.FileUtils.java

public static void recordVideo(Context ctx, Uri mFileCaptureUri) {
    if (!isIntentAvailable(ctx, MediaStore.ACTION_VIDEO_CAPTURE)) {
        log.warn("Cannot record video (Intent is not available)");
        return;/*from  w w  w .j  a va2s .co m*/
    }

    Intent takeVideoIntent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
    takeVideoIntent.putExtra(MediaStore.EXTRA_OUTPUT, mFileCaptureUri);

    int durationLimit = ctx.getResources().getInteger(R.integer.video_recording_duration_limit);
    if (durationLimit > 0) {
        takeVideoIntent.putExtra("android.intent.extra.durationLimit", durationLimit);
    }

    try {
        ((Activity) ctx).startActivityForResult(takeVideoIntent, AppUtils.ACTION_RECORD_VIDEO);
    } catch (ActivityNotFoundException e) {
        log.warn("Cannot record video", e);
    }
}

From source file:com.almalence.plugins.capture.video.VideoCapturePlugin.java

@Override
public void onGUICreate() {
    this.clearViews();

    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(ApplicationScreen.getMainContext());

    // change shutter icon
    isRecording = false;//from  w w  w. ja  v a  2 s.c om
    prefs.edit().putBoolean("videorecording", false).commit();

    ApplicationScreen.getGUIManager().setShutterIcon(ShutterButton.RECORDER_START);

    onPreferenceCreate((PreferenceFragment) null);

    setupVideoSize(prefs);

    List<View> specialView = new ArrayList<View>();
    RelativeLayout specialLayout = (RelativeLayout) ApplicationScreen.instance
            .findViewById(R.id.specialPluginsLayout2);
    for (int i = 0; i < specialLayout.getChildCount(); i++)
        specialView.add(specialLayout.getChildAt(i));

    for (int j = 0; j < specialView.size(); j++) {
        View view = specialView.get(j);
        int view_id = view.getId();
        if (view_id == this.mRecordingTimeView.getId() || view_id == this.modeSwitcher.getId()) {
            if (view.getParent() != null)
                ((ViewGroup) view.getParent()).removeView(view);

            specialLayout.removeView(view);
        }
    }

    {
        final RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
                LayoutParams.WRAP_CONTENT);

        params.addRule(RelativeLayout.ALIGN_PARENT_TOP);
        params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);

        ((RelativeLayout) ApplicationScreen.instance.findViewById(R.id.specialPluginsLayout3))
                .removeView(this.modeSwitcher);
        ((RelativeLayout) ApplicationScreen.instance.findViewById(R.id.specialPluginsLayout3))
                .addView(this.modeSwitcher, params);

        this.modeSwitcher.setLayoutParams(params);
    }

    // Calculate right sizes for plugin's controls
    DisplayMetrics metrics = new DisplayMetrics();
    ApplicationScreen.instance.getWindowManager().getDefaultDisplay().getMetrics(metrics);
    float fScreenDensity = metrics.density;

    int iIndicatorSize = (int) (ApplicationScreen.getMainContext().getResources()
            .getInteger(R.integer.infoControlHeight) * fScreenDensity);
    RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(iIndicatorSize, iIndicatorSize);
    int topMargin = ApplicationScreen.instance.findViewById(R.id.paramsLayout).getHeight()
            + (int) ApplicationScreen.getAppResources().getDimension(R.dimen.viewfinderViewsMarginTop);
    params.setMargins((int) (2 * ApplicationScreen.getGUIManager().getScreenDensity()), topMargin, 0, 0);

    params.addRule(RelativeLayout.ALIGN_PARENT_TOP);
    params.addRule(RelativeLayout.ALIGN_PARENT_LEFT);

    ((RelativeLayout) ApplicationScreen.instance.findViewById(R.id.specialPluginsLayout2))
            .addView(this.mRecordingTimeView, params);

    this.mRecordingTimeView.setLayoutParams(params);

    LayoutInflater inflator = ApplicationScreen.instance.getLayoutInflater();
    buttonsLayout = inflator.inflate(R.layout.plugin_capture_video_layout, null, false);
    buttonsLayout.setVisibility(View.VISIBLE);

    timeLapseButton = (RotateImageView) buttonsLayout.findViewById(R.id.buttonTimeLapse);
    pauseVideoButton = (RotateImageView) ApplicationScreen.instance.findViewById(R.id.buttonVideoPause);
    stopVideoButton = (RotateImageView) ApplicationScreen.instance.findViewById(R.id.buttonVideoStop);

    snapshotSupported = CameraController.isVideoSnapshotSupported();
    takePictureButton = (RotateImageView) buttonsLayout.findViewById(R.id.buttonCaptureImage);

    timeLapseButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            TimeLapseDialog();
        }
    });

    pauseVideoButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            pauseVideoRecording();
        }
    });

    stopVideoButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            onShutterClick();
        }
    });

    if (snapshotSupported) {
        takePictureButton.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                takePicture();
            }

        });
    }

    for (int j = 0; j < specialView.size(); j++) {
        View view = specialView.get(j);
        int view_id = view.getId();
        if (view_id == this.buttonsLayout.getId()) {
            if (view.getParent() != null)
                ((ViewGroup) view.getParent()).removeView(view);

            specialLayout.removeView(view);
        }
    }

    params = new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    params.height = (int) ApplicationScreen.getAppResources().getDimension(R.dimen.videobuttons_size);

    params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);

    ((RelativeLayout) ApplicationScreen.instance.findViewById(R.id.specialPluginsLayout2))
            .addView(this.buttonsLayout, params);

    this.buttonsLayout.setLayoutParams(params);

    if (snapshotSupported) {
        takePictureButton.setOrientation(ApplicationScreen.getGUIManager().getLayoutOrientation());
        takePictureButton.invalidate();
        // takePictureButton.requestLayout();
        displayTakePicture = true;
    } else {
        takePictureButton.setVisibility(View.GONE);
        displayTakePicture = false;
    }

    timeLapseButton.setOrientation(ApplicationScreen.getGUIManager().getLayoutOrientation());

    if (this.modeDRO() || CameraController.isRemoteCamera()) {
        takePictureButton.setVisibility(View.GONE);
        timeLapseButton.setVisibility(View.GONE);
    }

    if (prefs.getBoolean("videoStartStandardPref", false)) {
        DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                switch (which) {
                case DialogInterface.BUTTON_POSITIVE:
                    PluginManager.getInstance().onPause(true);
                    Intent intent = new Intent(android.provider.MediaStore.ACTION_VIDEO_CAPTURE);
                    ApplicationScreen.instance.startActivity(intent);
                    break;

                case DialogInterface.BUTTON_NEGATIVE:
                    // No button clicked
                    break;
                default:
                    break;
                }
            }
        };

        AlertDialog.Builder builder = new AlertDialog.Builder(ApplicationScreen.instance);
        builder.setMessage("You selected to start standard camera. Start camera?")
                .setPositiveButton("Yes", dialogClickListener).setNegativeButton("No", dialogClickListener)
                .show();
    }

    rotatorLayout = inflator.inflate(R.layout.plugin_capture_video_lanscaperotate_layout, null, false);
    rotatorLayout.setVisibility(View.VISIBLE);
    initRotateNotification(videoOrientation);

    List<View> specialViewRotator = new ArrayList<View>();
    RelativeLayout specialLayoutRotator = (RelativeLayout) ApplicationScreen.instance
            .findViewById(R.id.specialPluginsLayout);
    for (int i = 0; i < specialLayoutRotator.getChildCount(); i++)
        specialViewRotator.add(specialLayoutRotator.getChildAt(i));

    for (int j = 0; j < specialViewRotator.size(); j++) {
        View view = specialViewRotator.get(j);
        int view_id = view.getId();
        int layout_id = this.rotatorLayout.getId();
        if (view_id == layout_id) {
            if (view.getParent() != null)
                ((ViewGroup) view.getParent()).removeView(view);

            specialLayoutRotator.removeView(view);
        }
    }

    RelativeLayout.LayoutParams paramsRotator = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
            LayoutParams.WRAP_CONTENT);
    paramsRotator.height = (int) ApplicationScreen.getAppResources().getDimension(R.dimen.gui_element_2size);

    paramsRotator.addRule(RelativeLayout.CENTER_IN_PARENT);

    ((RelativeLayout) ApplicationScreen.instance.findViewById(R.id.specialPluginsLayout))
            .addView(this.rotatorLayout, paramsRotator);
}

From source file:edu.sfsu.csc780.chathub.ui.MainActivity.java

private void dispatchRecordVideoIntent() {
    Intent cameraIntent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
    PackageManager packageManager = getPackageManager();
    List<ResolveInfo> activities = packageManager.queryIntentActivities(cameraIntent, 0);
    boolean isIntentSafe = activities.size() > 0;
    featureFlag = 2;//ww  w  .  ja v  a  2 s. co  m

    if (isIntentSafe) {
        startActivityForResult(cameraIntent, REQUEST_VIDEO_CAPTURE);
    }
}

From source file:com.easemob.ui.ChatActivity.java

/**
 * ?//from   w w w .  j a v  a  2s .  c om
 */
public void selectVideoFromCamera() {
    if (!CommonUtils.isExitsSdcard()) {
        Toast.makeText(getApplicationContext(), "SD????", 0).show();
        return;
    }

    videoFile = new File(PathUtil.getInstance().getVideoPath(),
            MyApplication.getInstance().getUserName() + System.currentTimeMillis() + ".mp4");
    videoFile.getParentFile().mkdirs();
    startActivityForResult(new Intent(MediaStore.ACTION_VIDEO_CAPTURE).putExtra(MediaStore.EXTRA_OUTPUT,
            Uri.fromFile(videoFile)), REQUEST_CODE_CAMERA_VIDEO);

}