Example usage for android.provider MediaStore EXTRA_DURATION_LIMIT

List of usage examples for android.provider MediaStore EXTRA_DURATION_LIMIT

Introduction

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

Prototype

String EXTRA_DURATION_LIMIT

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

Click Source Link

Document

Specify the maximum allowed recording duration in seconds.

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 w  w .  java 2 s .  c  om*/
    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: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();//  w ww  . j a v a 2 s .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();/*from   www .  j  ava2 s  .  co  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: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:com.almalence.plugins.capture.video.VideoCapturePlugin.java

private void readVideoPreferences(SharedPreferences prefs) {
    Intent intent = ApplicationScreen.instance.getIntent();
    // Set video duration limit. The limit is read from the preference,
    // unless it is specified in the intent.
    if (intent.hasExtra(MediaStore.EXTRA_DURATION_LIMIT)) {
        int seconds = intent.getIntExtra(MediaStore.EXTRA_DURATION_LIMIT, 0);
        mMaxVideoDurationInMs = 1000 * seconds;
    } else/*  w w w.  j a  v  a 2 s.c o  m*/
        mMaxVideoDurationInMs = 0;
}