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.sandklef.coachapp.fragments.TrainingPhasesFragment.java

@Override
public boolean onContextItemSelected(MenuItem item) {
    AdapterView.AdapterContextMenuInfo acmi = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
    int position = acmi.position;

    String fileName = LocalStorage.getInstance().getNewMediaDir() + "/tp-" + currentTPId
            + JsonSettings.SERVER_VIDEO_SUFFIX;
    Media m = Media.newInstructionVideo(fileName, currentTPId);
    currentTPId = null;/*from  w  ww. ja  v  a  2 s  .c o m*/
    Uri uri = Uri.fromFile(new File(fileName));

    if (m != null) {
        Log.d(LOG_TAG, "   instruction video item: " + fileName);
        Intent intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);

        Log.d(LOG_TAG, "  file: " + fileName + " uri: " + uri);

        intent.putExtra(MediaStore.EXTRA_OUTPUT, uri);
        intent.putExtra("android.intent.extra.durationLimit", 5);
        intent.putExtra(MediaStore.EXTRA_FINISH_ON_COMPLETION, true);
        intent.putExtra(MediaStore.EXTRA_DURATION_LIMIT, 5);
        intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 1); // set the video image quality to high
        // start the image capture Intent
        //context.startActivity(intent);
        //            activity.startActivityForResult(intent, com.sandklef.coachapp.fragments.VideoCapture.VIDEO_CAPTURE);
        ((Activity) getContext()).startActivityForResult(intent, VIDEO_CAPTURE);
    }
    Log.d(LOG_TAG, "  new instruction video wanted creation: " + fileName);

    return true;
}

From source file:org.apache.cordova.Capture.java

/**
 * Sets up an intent to capture video.  Result handled by onActivityResult()
 *//*from   w w  w  .  j a  v a  2  s .  c o  m*/
private void captureVideo(int duration) {
    Intent intent = new Intent(android.provider.MediaStore.ACTION_VIDEO_CAPTURE);

    if (Build.VERSION.SDK_INT > 7) {
        intent.putExtra("android.intent.extra.durationLimit", duration);
    }
    this.cordova.startActivityForResult((CordovaPlugin) this, intent, CAPTURE_VIDEO);
}

From source file:com.psu.capstonew17.pdxaslapp.CreateCardActivity.java

private void dispatchTakeVideoIntent() {
    Intent takeVideoIntent = new Intent();
    takeVideoIntent.setAction(MediaStore.ACTION_VIDEO_CAPTURE);
    if (takeVideoIntent.resolveActivity(getPackageManager()) != null) {
        startActivityForResult(takeVideoIntent, GET_VIDEO);
    } else {//from   w  w  w  . j av  a 2 s.co m
        Toast.makeText(getApplicationContext(), R.string.card_record_video_error, Toast.LENGTH_SHORT).show();
    }
}

From source file:com.getchute.android.photopickerplus.ui.activity.ServicesActivity.java

@Override
public void recordVideo() {
    Intent intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
    mediaPath = AppUtil.getOutputMediaFileUri(MediaType.VIDEO);
    intent.putExtra(MediaStore.EXTRA_OUTPUT, mediaPath);
    intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 1);
    startTheCamera(intent, Constants.CAMERA_VIDEO_REQUEST);

}

From source file:com.android.camera.v2.uimanager.SettingManager.java

private void initializeSettings() {
    if (mSettingLayout == null) {
        mSettingLayout = (ViewGroup) mActivity.getLayoutInflater().inflate(R.layout.setting_container_v2,
                mSettingViewLayer, false);
        mTabHost = (TabHost) mSettingLayout.findViewById(R.id.tab_title);
        mTabHost.setup();//from   w  ww  . ja  v a2 s  .  c o  m
        String action = mIntent.getAction();
        LogHelper.i(TAG, "intent.action:" + action);
        List<Holder> list = new ArrayList<Holder>();
        // default setting
        int commonKeys[] = SettingKeys.SETTING_GROUP_COMMON_FOR_TAB;
        int cameraKeys[] = SettingKeys.SETTING_GROUP_CAMERA_FOR_TAB;
        int videoKeys[] = SettingKeys.SETTING_GROUP_VIDEO_FOR_TAB;

        if (FeatureSwitcher.isSubSettingEnabled()) {
            // For tablet
            commonKeys = SettingKeys.SETTING_GROUP_MAIN_COMMON_FOR_TAB;
        } else if (FeatureSwitcher.isLomoEffectEnabled()) {
            commonKeys = SettingKeys.SETTING_GROUP_COMMON_FOR_LOMOEFFECT;
        }
        // image capture setting, compared to default setting,
        // common settings and video setting may be different.
        if (MediaStore.ACTION_IMAGE_CAPTURE.equals(action)) {
            videoKeys = null;
        }
        // image capture setting, compared to default setting,
        // common settings and video setting
        // may be different.
        if (MediaStore.ACTION_VIDEO_CAPTURE.equals(action)) {
            cameraKeys = null;
        }

        if (commonKeys != null) {
            list.add(new Holder(TAB_INDICATOR_KEY_COMMON, R.drawable.ic_tab_common_setting, commonKeys));
        }
        if (cameraKeys != null) {
            list.add(new Holder(TAB_INDICATOR_KEY_CAMERA, R.drawable.ic_tab_camera_setting, cameraKeys));
        }
        if (videoKeys != null) {
            list.add(new Holder(TAB_INDICATOR_KEY_VIDEO, R.drawable.ic_tab_video_setting, videoKeys));
        }

        int size = list.size();
        List<SettingListLayout> pageViews = new ArrayList<SettingListLayout>();
        for (int i = 0; i < size; i++) {
            Holder holder = list.get(i);
            // new page view
            SettingListLayout pageView = (SettingListLayout) mActivity.getLayoutInflater()
                    .inflate(R.layout.setting_list_layout_v2, mSettingViewLayer, false);
            ArrayList<ListPreference> listItems = new ArrayList<ListPreference>();
            pageView.setRootView(mSettingViewLayer);
            pageView.initialize(getListPreferences(holder.mSettingKeys, i == 0));
            pageView.setSettingChangedListener(SettingManager.this);
            pageViews.add(pageView);
            // new indicator view
            ImageView indicatorView = new ImageView(mActivity);
            if (indicatorView != null) {
                indicatorView.setBackgroundResource(R.drawable.bg_tab_title);
                indicatorView.setImageResource(holder.mIndicatorIconRes);
                indicatorView.setScaleType(ScaleType.CENTER);
            }
            mTabHost.addTab(mTabHost.newTabSpec(holder.mIndicatorKey).setIndicator(indicatorView)
                    .setContent(android.R.id.tabcontent));
        }

        mAdapter = new MyPagerAdapter(pageViews);
        mPager = (ViewPager) mSettingLayout.findViewById(R.id.pager);
        mPager.setAdapter(mAdapter);
        mPager.setOnPageChangeListener(mAdapter);
        mTabHost.setOnTabChangedListener(this);
    }
    int orientation = (Integer) mSettingViewLayer.getTag();
    CameraUtil.setOrientation(mSettingLayout, orientation, false);
}

From source file:org.matrix.console.activity.RoomActivity.java

/**
 * Launch the camera/*from w w  w.java  2  s.com*/
 */
private void launchVideo() {
    final Intent captureIntent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
    // lowest quality
    captureIntent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 0);
    RoomActivity.this.runOnUiThread(new Runnable() {
        @Override
        public void run() {
            startActivityForResult(captureIntent, TAKE_VIDEO);
        }
    });
}

From source file:org.odk.collect.android.widgets.VideoWidget.java

private void captureVideo() {
    Intent i;//from w w  w  .  j  a v a  2 s  .  c om
    if (selfie) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            i = new Intent(getContext(), CaptureSelfieVideoActivityNewApi.class);
        } else {
            i = new Intent(getContext(), CaptureSelfieVideoActivity.class);
        }
    } else {
        i = new Intent(android.provider.MediaStore.ACTION_VIDEO_CAPTURE);
        // Need to have this ugly code to account for
        // a bug in the Nexus 7 on 4.3 not returning the mediaUri in the data
        // of the intent - using the MediaStore.EXTRA_OUTPUT to get the data
        // Have it saving to an intermediate location instead of final destination
        // to allow the current location to catch issues with the intermediate file
        Timber.i("The build of this device is %s", MODEL);
        if (NEXUS7.equals(MODEL) && Build.VERSION.SDK_INT == 18) {
            nexus7Uri = getOutputMediaFileUri(MEDIA_TYPE_VIDEO);
            i.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, nexus7Uri);
        } else {
            i.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, Video.Media.EXTERNAL_CONTENT_URI.toString());
        }
    }

    SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(Collect.getInstance());

    // request high resolution if configured for that...
    boolean highResolution = settings.getBoolean(GeneralKeys.KEY_HIGH_RESOLUTION,
            VideoWidget.DEFAULT_HIGH_RESOLUTION);
    if (highResolution) {
        i.putExtra(android.provider.MediaStore.EXTRA_VIDEO_QUALITY, 1);
    }
    try {
        waitForData();
        ((Activity) getContext()).startActivityForResult(i, RequestCodes.VIDEO_CAPTURE);
    } catch (ActivityNotFoundException e) {
        Toast.makeText(getContext(), getContext().getString(R.string.activity_not_found,
                getContext().getString(R.string.capture_video)), Toast.LENGTH_SHORT).show();
        cancelWaitingForData();
    }
}

From source file:com.dycode.jepretstory.mediachooser.activity.BucketHomeFragmentActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {

    int itemID = item.getItemId();
    if (itemID == android.R.id.home) {
        materialMenu.animateTouch();/*from  ww  w .j  av  a 2s.c  o  m*/
        finish();
    } else if (itemID == R.id.menuNext) {

        if (mSelectedImages.size() == 0 && mSelectedImages.size() == 0) {
            Toast.makeText(BucketHomeFragmentActivity.this, getString(R.string.plaese_select_file),
                    Toast.LENGTH_SHORT).show();

        } else {

            if (mSelectedVideos.size() > 0) {
                Intent videoIntent = new Intent();
                videoIntent.setAction(MediaChooser.VIDEO_SELECTED_ACTION_FROM_MEDIA_CHOOSER);
                //videoIntent.putStringArrayListExtra("list", mSelectedVideo);
                videoIntent.putParcelableArrayListExtra("selectedVideos", mSelectedVideos);
                setResult(RESULT_OK, videoIntent);
                sendBroadcast(videoIntent);
            }

            if (mSelectedImages.size() > 0) {
                Intent imageIntent = new Intent();
                imageIntent.setAction(MediaChooser.IMAGE_SELECTED_ACTION_FROM_MEDIA_CHOOSER);
                //imageIntent.putStringArrayListExtra("list", mSelectedImage);
                imageIntent.putParcelableArrayListExtra("selectedImages", mSelectedImages);
                setResult(RESULT_OK, imageIntent);
                sendBroadcast(imageIntent);
            }
            finish();
        }
    } else if (itemID == R.id.menuCamera) {

        if (currentMediaMode == MediaType.VIDEO) {

            Intent intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);

            // create a file to save the image
            fileUri = getOutputMediaFileUri(MediaChooserConstants.MEDIA_TYPE_VIDEO);

            //fileUri = getVideoInMediaStore(fileUri);

            // set the image file name
            intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri);
            intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 0);
            Long limit = Long.valueOf((MediaChooserConstants.SELECTED_VIDEO_SIZE_IN_MB * 1024 * 1024));
            intent.putExtra(MediaStore.EXTRA_SIZE_LIMIT, limit);
            intent.putExtra(MediaStore.EXTRA_DURATION_LIMIT,
                    MediaChooserConstants.VIDEO_DURATION_LIMIT_IN_SECOND);

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

        } else {

            Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);

            // create a file to save the image
            fileUri = getOutputMediaFileUri(MediaChooserConstants.MEDIA_TYPE_IMAGE);

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

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

    }

    return super.onOptionsItemSelected(item);
}

From source file:com.dycode.jepretstory.mediachooser.activity.HomeFragmentActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {

    int itemID = item.getItemId();
    if (itemID == android.R.id.home) {
        materialMenu.animateTouch();/*www  .j av a2 s .c o  m*/
        finish();
    } else if (itemID == R.id.menuNext) {

        //android.support.v4.app.FragmentManager fragmentManager = getSupportFragmentManager();

        if (mVideoFragment != null || mImageFragment != null) {

            if (mVideoFragment != null) {
                if (mVideoFragment.getSelectedVideos() != null
                        && mVideoFragment.getSelectedVideos().size() > 0) {
                    Intent videoIntent = new Intent();
                    videoIntent.setAction(MediaChooser.VIDEO_SELECTED_ACTION_FROM_MEDIA_CHOOSER);
                    //videoIntent.putStringArrayListExtra("list", mVideoFragment.getSelectedVideoList());
                    videoIntent.putParcelableArrayListExtra("selectedVideos",
                            mVideoFragment.getSelectedVideos());
                    setResult(RESULT_OK, videoIntent);
                    sendBroadcast(videoIntent);
                }
            }

            if (mImageFragment != null) {
                if (mImageFragment.getSelectedImages() != null
                        && mImageFragment.getSelectedImages().size() > 0) {
                    Intent imageIntent = new Intent();
                    imageIntent.setAction(MediaChooser.IMAGE_SELECTED_ACTION_FROM_MEDIA_CHOOSER);
                    //imageIntent.putStringArrayListExtra("list", mImageFragment.getSelectedImageList());
                    imageIntent.putParcelableArrayListExtra("selectedImages",
                            mImageFragment.getSelectedImages());
                    setResult(RESULT_OK, imageIntent);
                    sendBroadcast(imageIntent);
                }
            }

            finish();

        } else {
            Toast.makeText(HomeFragmentActivity.this, getString(R.string.plaese_select_file),
                    Toast.LENGTH_SHORT).show();
        }
    } else if (itemID == R.id.menuCamera) {

        if (currentMediaMode == MediaType.VIDEO) {

            Intent intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
            fileUri = getOutputMediaFileUri(MediaType.VIDEO); // create a file to save the image
            intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri); // set the image file name
            intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 0);
            Long limit = Long.valueOf((MediaChooserConstants.SELECTED_VIDEO_SIZE_IN_MB * 1024 * 1024));
            intent.putExtra(MediaStore.EXTRA_SIZE_LIMIT, limit);
            intent.putExtra(MediaStore.EXTRA_DURATION_LIMIT,
                    MediaChooserConstants.VIDEO_DURATION_LIMIT_IN_SECOND);

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

        } else {

            Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
            fileUri = getOutputMediaFileUri(MediaType.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);
        }

    }

    return super.onOptionsItemSelected(item);
}

From source file:net.jongrakko.zipsuri.activity.PostReviseActivity.java

private void takeVideo() {
    Intent intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
    takeFile = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES),
            "Zisuri_tmp_" + System.currentTimeMillis() + ".mp4");
    Uri saveUri = Uri.fromFile(takeFile);
    intent.putExtra(MediaStore.EXTRA_OUTPUT, saveUri); // set the image file name
    intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 1); // set the video image quality to high
    startActivityForResult(intent, TAKE_VIDEO_FOR_AVATAR);
}