當前位置: 首頁>>代碼示例>>Java>>正文


Java MediaStore.ACTION_VIDEO_CAPTURE屬性代碼示例

本文整理匯總了Java中android.provider.MediaStore.ACTION_VIDEO_CAPTURE屬性的典型用法代碼示例。如果您正苦於以下問題:Java MediaStore.ACTION_VIDEO_CAPTURE屬性的具體用法?Java MediaStore.ACTION_VIDEO_CAPTURE怎麽用?Java MediaStore.ACTION_VIDEO_CAPTURE使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在android.provider.MediaStore的用法示例。


在下文中一共展示了MediaStore.ACTION_VIDEO_CAPTURE屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: gravarVideo

private void gravarVideo(){
    Intent takeVideoIntent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
    takeVideoIntent.putExtra(MediaStore.EXTRA_DURATION_LIMIT, 10);
    if (takeVideoIntent.resolveActivity(getPackageManager()) != null) {
        startActivityForResult(takeVideoIntent, REQUEST_VIDEO_CAPTURE);
    }
}
 
開發者ID:chacaldev,項目名稱:provadevida,代碼行數:7,代碼來源:EnviarVideoActivity.java

示例2: takeVideo

private void takeVideo() {
    File dirVideo = new File(Environment.getExternalStorageDirectory(), "ktools/videos/");
    if (!dirVideo.exists()) {
        dirVideo.mkdirs();
    }
    outputVideoFile = new File(dirVideo.getAbsolutePath() + System.currentTimeMillis() + ".mp4");
    if (!outputVideoFile.exists()) {
        try {
            outputVideoFile.createNewFile();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    //兼容7.0
    Uri videoUri = FileProvider.getUriForFile(
            this,
            BuildConfig.APPLICATION_ID,
            outputVideoFile
    );
    Intent intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
    //指定輸出
    intent.putExtra(MediaStore.EXTRA_OUTPUT, videoUri);
    intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 1);
    intent.putExtra(MediaStore.EXTRA_DURATION_LIMIT, 3000);
    startActivityForResult(intent, REQUEST_CODE_TAKE_VIDEO);
}
 
開發者ID:jiangkang,項目名稱:KTools,代碼行數:26,代碼來源:ImageActivity.java

示例3: do_add_video

@OnClick(R.id.fab_add_video)
public void do_add_video()
{
    Intent capture = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
    if (capture.resolveActivity(getPackageManager()) != null) {
        try {
            File videoFile = createFileName("traxyvid", ".mp4");
            mediaUri = FileProvider.getUriForFile(this,
                    getPackageName() + ".provider", videoFile);
            capture.putExtra(MediaStore.EXTRA_OUTPUT, mediaUri);
            startActivityForResult(capture, CAPTURE_VIDEO_REQUEST);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
 
開發者ID:gvsucis,項目名稱:mobile-app-dev-book,代碼行數:16,代碼來源:JournalViewActivity.java

示例4: startRecordingVideo

public void startRecordingVideo() {
    if (getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA)) {
        Intent intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);

        String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
        File storageDir = new File(Environment.getExternalStoragePublicDirectory(
                Environment.DIRECTORY_DCIM), "Camera");
        videoFile = new File(storageDir, "Commons_" + timeStamp + ".mp4");

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
            videoUri = FileProvider.getUriForFile(MainActivity.this,
                    BuildConfig.APPLICATION_ID + ".provider",
                    videoFile);
        } else {
            videoUri = Uri.fromFile(videoFile);
        }

        intent.putExtra(MediaStore.EXTRA_OUTPUT, videoUri);
        intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 1);
        startActivityForResult(intent, VIDEO_CAPTURE);
    } else {
        Toast.makeText(this, R.string.no_camera_on_device, Toast.LENGTH_LONG).show();
    }
}
 
開發者ID:CommonsLab,項目名稱:CommonsLab,代碼行數:24,代碼來源:MainActivity.java

示例5: onClick

@Override
public void onClick(View v) {
	int id = v.getId();
	switch (id) {
	case R.id.video_choose_cancel:
		finish();
		return;
	case R.id.video_choose_next:
		if (chooseVideo.size() == 0) {
			Toast.makeText(this, "至少選一個", 1).show();
		} else {
			ArrayList<String> videoPaths = new ArrayList<String>();
			for (Map.Entry entry : chooseVideo.entrySet()) {
				videoPaths.add(entry.getValue().toString());
			}
			Intent i = new Intent(this, HoDragVideo.class);
			i.putStringArrayListExtra("videos", videoPaths);
			startActivity(i);
		}
		return;
	default:
		break;
	}
	// TODO Auto-generated method stub
	if (v.getTag() != null && (int) v.getTag() == 1000) {
		Intent intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);

		Uri fileUri = getOutputMediaFileUri();
		intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri);
		intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 1);
		startActivityForResult(intent, 1);
	} else {
		int chkId = 300000 + (int) v.getTag();
		CheckBox chk = (CheckBox) CameraMain2.this.findViewById(chkId);

		chk.setChecked(!chk.isChecked());
		// String videoPath = getPath((int) v.getTag());
		// Intent i = new Intent(CameraMain2.this, VideoPlayer.class);
		// i.putExtra("videoPath", videoPath);
		// i.putExtra("videoButton", (int) v.getTag() + 1000);
		// CameraMain2.this.startActivityForResult(i, 2);
	}
}
 
開發者ID:smartbeng,項目名稱:PaoMovie,代碼行數:43,代碼來源:CameraMain2.java

示例6: createCamcorderIntent

private Intent createCamcorderIntent() {
	Intent cameraIntent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
	File externalDataDir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MOVIES);
	File cameraDataDir = new File(externalDataDir.getAbsolutePath() + File.separator + "browser-movies");
	cameraDataDir.mkdirs();
	mCameraFilePath = cameraDataDir.getAbsolutePath() + File.separator + System.currentTimeMillis() + ".mp4";
	cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(new File(mCameraFilePath)));
	return cameraIntent;

}
 
開發者ID:smartbeng,項目名稱:PaoMovie,代碼行數:10,代碼來源:MyWebChromeClient.java

示例7: openCamera

public void openCamera(Context context) {


        boolean image = mConfiguration.isImage();

        Intent captureIntent = image ? new Intent(MediaStore.ACTION_IMAGE_CAPTURE) : new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
        if (captureIntent.resolveActivity(context.getPackageManager()) == null) {
            Toast.makeText(getContext(), R.string.gallery_device_camera_unable, Toast.LENGTH_SHORT).show();
            return;
        }

        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHmmss", Locale.CHINA);
        String filename = String.format(image ? IMAGE_STORE_FILE_NAME : VIDEO_STORE_FILE_NAME, dateFormat.format(new Date()));
        Logger.i("openCamera:" + mImageStoreDir.getAbsolutePath());
        File fileImagePath = new File(mImageStoreDir, filename);
        mImagePath = fileImagePath.getAbsolutePath();

        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) {
            captureIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(fileImagePath));
        } else {
            ContentValues contentValues = new ContentValues(1);
            contentValues.put(MediaStore.Images.Media.DATA, mImagePath);
            Uri uri = getContext().getContentResolver().insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, contentValues);
            captureIntent.putExtra(MediaStore.EXTRA_OUTPUT, uri);
        }
        // video : 1: 高質量  0 低質量
//        captureIntent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 1);
        startActivityForResult(captureIntent, TAKE_IMAGE_REQUEST_CODE);
    }
 
開發者ID:Loofer,項目名稱:Watermark,代碼行數:29,代碼來源:MediaGridFragment.java

示例8: takeVideo

static void takeVideo(Map message) {
    if (message.containsKey("broadcast")) {
        broadcast = (Boolean) message.get("broadcast");
    }

   Intent takeVideoIntent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
   Activity activity = org.qtproject.qt5.android.QtNative.activity();
   if (takeVideoIntent.resolveActivity(activity.getPackageManager()) != null) {
       activity.startActivityForResult(takeVideoIntent, TAKE_VIDEO_ACTION );
   }
}
 
開發者ID:benlau,項目名稱:androidnative.pri,代碼行數:11,代碼來源:VideoPicker.java

示例9: TakeVideo

void TakeVideo() {
    File fTemp;
    File storageDir = getActivity().getExternalFilesDir(Environment.DIRECTORY_PICTURES);

    try {
        if (!fCheckImagePermissions(CAMERA_PERMISSION_VIDEO))
            return;
        fTemp = File.createTempFile(TEMP_IMG_FILE_NAME, ".mp4", storageDir);
        fTemp.deleteOnExit();
        m_TempFilePath = fTemp.getAbsolutePath(); // need to save this for when the picture comes back

        SharedPreferences mPrefs = getActivity().getPreferences(Activity.MODE_PRIVATE);
        SharedPreferences.Editor ed = mPrefs.edit();
        ed.putString(keyTempFileInProgress, m_TempFilePath);
        ed.apply();

        Uri uriImage = FileProvider.getUriForFile(this.getContext(), "com.example.android.fileprovider", fTemp);

        Intent intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
        intent.putExtra(MediaStore.EXTRA_OUTPUT, uriImage);
        intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 1);
        startActivityForResult(intent, CAPTURE_VIDEO_ACTIVITY_REQUEST_CODE);
    } catch (IOException e) {
        Log.e(MFBConstants.LOG_TAG, Log.getStackTraceString(e));
        MFBUtil.Alert(getActivity(), getString(R.string.txtError), getString(R.string.errNoCamera));
    }
}
 
開發者ID:ericberman,項目名稱:MyFlightbookAndroid,代碼行數:27,代碼來源:ActMFBForm.java

示例10: recordVideo

/**
 * 錄製視頻
 */
public void recordVideo(Activity activity, int requestCode) {
    Intent takePictureIntent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
    takePictureIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    if (takePictureIntent.resolveActivity(activity.getPackageManager()) != null) {

        if (Utils.existSDCard())
            takeImageFile = new File(Environment.getExternalStorageDirectory(), "/DCIM/Video/");
        else takeImageFile = Environment.getDataDirectory();
        takeImageFile = createFile(takeImageFile, "Video_", ".mp4");
        if (takeImageFile != null) {
            Uri fileUri;
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
                fileUri = FileProvider.getUriForFile(activity, activity.getPackageName(), takeImageFile);
                takePictureIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
                takePictureIntent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
            } else {
                fileUri = Uri.fromFile(takeImageFile);
            }
            // 默認情況下,即不需要指定intent.putExtra(MediaStore.EXTRA_OUTPUT, uri);
            // 照相機有自己默認的存儲路徑,拍攝的照片將返回一個縮略圖。如果想訪問原始圖片,
            // 可以通過dat extra能夠得到原始圖片位置。即,如果指定了目標uri,data就沒有數據,
            // 如果沒有指定uri,則data就返回有數據!
            takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri);
        }
    }
    activity.startActivityForResult(takePictureIntent, requestCode);
}
 
開發者ID:angcyo,項目名稱:RLibrary,代碼行數:30,代碼來源:ImagePicker.java

示例11: takeVideo

/**
 * 拍攝視頻
 */
public static void takeVideo(Activity activity, int code) {
    Intent intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);// 創建一個請求視頻的意圖
    intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 0.95);// 設置視頻的質量,值為0-1,
    intent.putExtra(MediaStore.EXTRA_DURATION_LIMIT, 15);// 設置視頻的錄製長度,s為單位
    intent.putExtra(MediaStore.EXTRA_SIZE_LIMIT, 5 * 1024 * 1024L);// 設置視頻文件大小,字節為單位
    activity.startActivityForResult(intent, code);// 設置請求碼,在onActivityResult()方法中接收結果
}
 
開發者ID:StickyTolt,項目名稱:ForeverLibrary,代碼行數:10,代碼來源:MediaUtil.java

示例12: videoCapture

/**
 * Record videos.
 *
 * @param activity    activity.
 * @param requestCode code.
 * @param outPath     file path.
 * @param quality     currently value 0 means low quality, suitable for MMS messages, and  value 1 means high quality.
 * @param duration    specify the maximum allowed recording duration in seconds.
 * @param limitBytes  specify the maximum allowed size.
 */
public static void videoCapture(@NonNull Activity activity, int requestCode, File outPath,
                                @IntRange(from = 0, to = 1) int quality,
                                @IntRange(from = 1, to = Long.MAX_VALUE) long duration,
                                @IntRange(from = 1, to = Long.MAX_VALUE) long limitBytes) {
    Intent intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
    Uri uri = getUri(activity, outPath);
    intent.putExtra(MediaStore.EXTRA_OUTPUT, uri);
    intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, quality);
    intent.putExtra(MediaStore.EXTRA_DURATION_LIMIT, duration);
    intent.putExtra(MediaStore.EXTRA_SIZE_LIMIT, limitBytes);
    activity.startActivityForResult(intent, requestCode);
}
 
開發者ID:WeiXinqiao,項目名稱:Recognize-it,代碼行數:22,代碼來源:AlbumUtils.java

示例13: launchVideoRecord

private void launchVideoRecord() {
    final Intent intent =
            new Intent(MediaStore.ACTION_VIDEO_CAPTURE);

    if (intent.resolveActivity(getPackageManager()) != null) {
        startActivityForResult(intent, REQUEST_VIDEO);
    }
}
 
開發者ID:aws-samples,項目名稱:aws-mobile-simple-video-transcoding,代碼行數:8,代碼來源:MainActivity.java

示例14: recordVideo

public void recordVideo(View view) {
    // Capture video
    Intent takeVideoIntent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
    if(takeVideoIntent.resolveActivity(getPackageManager()) != null) {
        startActivityForResult(takeVideoIntent, REQUEST_VIDEO_CAPTURE);
    }
}
 
開發者ID:Jiikuy,項目名稱:VelocityCalculator,代碼行數:7,代碼來源:MainActivity.java

示例15: dispatchTakeVideoIntent

private void dispatchTakeVideoIntent(){
    Intent takePictureIntent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
    if(takePictureIntent.resolveActivity(getPackageManager()) != null)
        startActivityForResult(takePictureIntent,REQUEST_VIDEO_CAPTURE);
}
 
開發者ID:zhuangzaiku,項目名稱:AndroidCollection,代碼行數:5,代碼來源:CameraActivity.java


注:本文中的android.provider.MediaStore.ACTION_VIDEO_CAPTURE屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。