当前位置: 首页>>代码示例>>Java>>正文


Java CameraConfiguration.MEDIA_ACTION_VIDEO属性代码示例

本文整理汇总了Java中com.sandrios.sandriosCamera.internal.configuration.CameraConfiguration.MEDIA_ACTION_VIDEO属性的典型用法代码示例。如果您正苦于以下问题:Java CameraConfiguration.MEDIA_ACTION_VIDEO属性的具体用法?Java CameraConfiguration.MEDIA_ACTION_VIDEO怎么用?Java CameraConfiguration.MEDIA_ACTION_VIDEO使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在com.sandrios.sandriosCamera.internal.configuration.CameraConfiguration的用法示例。


在下文中一共展示了CameraConfiguration.MEDIA_ACTION_VIDEO属性的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setup

public void setup(int mediaAction) {
    this.mediaAction = mediaAction;

    if (CameraConfiguration.MEDIA_ACTION_VIDEO == mediaAction) {
        recordButton.setup(mediaAction, this);
        flashSwitchView.setVisibility(GONE);
    } else {
        recordButton.setup(CameraConfiguration.MEDIA_ACTION_PHOTO, this);
    }

    if (CameraConfiguration.MEDIA_ACTION_BOTH != mediaAction) {
        mediaActionSwitchView.setVisibility(GONE);
    }
    //这里让切换Icon消失
    else mediaActionSwitchView.setVisibility(GONE);
}
 
开发者ID:MartinRGB,项目名称:android_camera_experiment,代码行数:16,代码来源:CameraControlPanel.java

示例2: getOutputMediaFile

public static File getOutputMediaFile(Context context, @CameraConfiguration.MediaAction int mediaAction) {
    File mediaStorageDir = context.getFilesDir();

    if (!mediaStorageDir.exists()) {
        if (!mediaStorageDir.mkdirs()) {
            Log.d(TAG, "Failed to create directory.");
            return null;
        }
    }

    String timeStamp = new SimpleDateFormat("yyyy_MM_dd_HH_mm_ss", Locale.ENGLISH)
            .format(new Date());
    File mediaFile;
    if (mediaAction == CameraConfiguration.MEDIA_ACTION_PHOTO) {
        mediaFile = new File(mediaStorageDir.getPath() + File.separator +
                "IMG_" + timeStamp + ".jpg");
    } else if (mediaAction == CameraConfiguration.MEDIA_ACTION_VIDEO) {
        mediaFile = new File(mediaStorageDir.getPath() + File.separator +
                "VID_" + timeStamp + ".mp4");
    } else {
        return null;
    }

    return mediaFile;
}
 
开发者ID:sandrios,项目名称:sandriosCamera,代码行数:25,代码来源:CameraHelper.java

示例3: onProcessBundle

@Override
protected void onProcessBundle(Bundle savedInstanceState) {
    super.onProcessBundle(savedInstanceState);

    extractConfiguration(getIntent().getExtras());
    currentMediaActionState = mediaAction == CameraConfiguration.MEDIA_ACTION_VIDEO ?
            MediaActionSwitchView.ACTION_VIDEO : MediaActionSwitchView.ACTION_PHOTO;
}
 
开发者ID:MartinRGB,项目名称:android_camera_experiment,代码行数:8,代码来源:BaseSandriosActivity.java

示例4: setIcon

private void setIcon() {
    if (CameraConfiguration.MEDIA_ACTION_VIDEO == mediaAction) {
        if (READY_FOR_RECORD_STATE == currentState) {
            setImageDrawable(startRecordDrawable);
            setIconPadding(iconPadding);
        } else if (RECORD_IN_PROGRESS_STATE == currentState) {
            setImageDrawable(stopRecordDrawable);
            setIconPadding(iconPaddingStop);
        }
    } else {
        setImageDrawable(takePhotoDrawable);
        setIconPadding(iconPadding);
    }
}
 
开发者ID:MartinRGB,项目名称:android_camera_experiment,代码行数:14,代码来源:RecordButton.java

示例5: setup

public void setup(int mediaAction) {
    this.mediaAction = mediaAction;
    if (CameraConfiguration.MEDIA_ACTION_VIDEO == mediaAction) {
        recordButton.setup(mediaAction, this);
        flashSwitchView.setVisibility(GONE);
    } else {
        recordButton.setup(CameraConfiguration.MEDIA_ACTION_PHOTO, this);
    }

    if (CameraConfiguration.MEDIA_ACTION_BOTH != mediaAction) {
        mediaActionSwitchView.setVisibility(GONE);
    } else mediaActionSwitchView.setVisibility(VISIBLE);
}
 
开发者ID:sandrios,项目名称:sandriosCamera,代码行数:13,代码来源:CameraControlPanel.java

示例6: startPreview

private void startPreview(SurfaceHolder surfaceHolder) {
        try {
            Camera.CameraInfo cameraInfo = new Camera.CameraInfo();
            Camera.getCameraInfo(currentCameraId, cameraInfo);
            int cameraRotationOffset = cameraInfo.orientation;

            Camera.Parameters parameters = camera.getParameters();
            setAutoFocus(camera, parameters);
            setFlashMode(configurationProvider.getFlashMode());

            if (configurationProvider.getMediaAction() == CameraConfiguration.MEDIA_ACTION_PHOTO
                    || configurationProvider.getMediaAction() == CameraConfiguration.MEDIA_ACTION_BOTH)
                turnPhotoCameraFeaturesOn(camera, parameters);
            else if (configurationProvider.getMediaAction() == CameraConfiguration.MEDIA_ACTION_PHOTO)
                turnVideoCameraFeaturesOn(camera, parameters);

            int rotation = ((WindowManager) context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay().getRotation();
            int degrees = 0;
            switch (rotation) {
                case Surface.ROTATION_0:
                    degrees = 0;
                    break; // Natural orientation
                case Surface.ROTATION_90:
                    degrees = 90;
                    break; // Landscape left
                case Surface.ROTATION_180:
                    degrees = 180;
                    break;// Upside down
                case Surface.ROTATION_270:
                    degrees = 270;
                    break;// Landscape right
            }

            if (cameraInfo.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) {
                displayRotation = (cameraRotationOffset + degrees) % 360;
                displayRotation = (360 - displayRotation) % 360; // compensate
            } else {
                displayRotation = (cameraRotationOffset - degrees + 360) % 360;
            }

            this.camera.setDisplayOrientation(displayRotation);

            if (Build.VERSION.SDK_INT > 13
                    && (configurationProvider.getMediaAction() == CameraConfiguration.MEDIA_ACTION_VIDEO
                    || configurationProvider.getMediaAction() == CameraConfiguration.MEDIA_ACTION_BOTH)) {
//                parameters.setRecordingHint(true);
            }

            if (Build.VERSION.SDK_INT > 14
                    && parameters.isVideoStabilizationSupported()
                    && (configurationProvider.getMediaAction() == CameraConfiguration.MEDIA_ACTION_VIDEO
                    || configurationProvider.getMediaAction() == CameraConfiguration.MEDIA_ACTION_BOTH)) {
                parameters.setVideoStabilization(true);
            }

            parameters.setPreviewSize(previewSize.getWidth(), previewSize.getHeight());
            parameters.setPictureSize(photoSize.getWidth(), photoSize.getHeight());

            camera.setParameters(parameters);
            camera.setPreviewDisplay(surfaceHolder);
            camera.startPreview();

        } catch (IOException error) {
            Log.d(TAG, "Error setting camera preview: " + error.getMessage());
        } catch (Exception ignore) {
            Log.d(TAG, "Error starting camera preview: " + ignore.getMessage());
        }
    }
 
开发者ID:MartinRGB,项目名称:android_camera_experiment,代码行数:68,代码来源:Camera1Manager.java

示例7: extractConfiguration

private void extractConfiguration(Bundle bundle) {
    if (bundle != null) {
        if (bundle.containsKey(CameraConfiguration.Arguments.REQUEST_CODE))
            requestCode = bundle.getInt(CameraConfiguration.Arguments.REQUEST_CODE);

        if (bundle.containsKey(CameraConfiguration.Arguments.MEDIA_ACTION)) {
            switch (bundle.getInt(CameraConfiguration.Arguments.MEDIA_ACTION)) {
                case CameraConfiguration.MEDIA_ACTION_PHOTO:
                    mediaAction = CameraConfiguration.MEDIA_ACTION_PHOTO;
                    break;
                case CameraConfiguration.MEDIA_ACTION_VIDEO:
                    mediaAction = CameraConfiguration.MEDIA_ACTION_VIDEO;
                    break;
                default:
                    mediaAction = CameraConfiguration.MEDIA_ACTION_BOTH;
                    break;
            }
        }

        if (bundle.containsKey(CameraConfiguration.Arguments.MEDIA_QUALITY)) {
            switch (bundle.getInt(CameraConfiguration.Arguments.MEDIA_QUALITY)) {
                case CameraConfiguration.MEDIA_QUALITY_AUTO:
                    mediaQuality = CameraConfiguration.MEDIA_QUALITY_AUTO;
                    break;
                case CameraConfiguration.MEDIA_QUALITY_HIGHEST:
                    mediaQuality = CameraConfiguration.MEDIA_QUALITY_HIGHEST;
                    break;
                case CameraConfiguration.MEDIA_QUALITY_HIGH:
                    mediaQuality = CameraConfiguration.MEDIA_QUALITY_HIGH;
                    break;
                case CameraConfiguration.MEDIA_QUALITY_MEDIUM:
                    mediaQuality = CameraConfiguration.MEDIA_QUALITY_MEDIUM;
                    break;
                case CameraConfiguration.MEDIA_QUALITY_LOW:
                    mediaQuality = CameraConfiguration.MEDIA_QUALITY_LOW;
                    break;
                case CameraConfiguration.MEDIA_QUALITY_LOWEST:
                    mediaQuality = CameraConfiguration.MEDIA_QUALITY_LOWEST;
                    break;
                default:
                    mediaQuality = CameraConfiguration.MEDIA_QUALITY_MEDIUM;
                    break;
            }
            passedMediaQuality = mediaQuality;
        }

        if (bundle.containsKey(CameraConfiguration.Arguments.VIDEO_DURATION))
            videoDuration = bundle.getInt(CameraConfiguration.Arguments.VIDEO_DURATION);

        if (bundle.containsKey(CameraConfiguration.Arguments.VIDEO_FILE_SIZE))
            videoFileSize = bundle.getLong(CameraConfiguration.Arguments.VIDEO_FILE_SIZE);

        if (bundle.containsKey(CameraConfiguration.Arguments.MINIMUM_VIDEO_DURATION))
            minimumVideoDuration = bundle.getInt(CameraConfiguration.Arguments.MINIMUM_VIDEO_DURATION);

        if (bundle.containsKey(CameraConfiguration.Arguments.SHOW_PICKER))
            showPicker = bundle.getBoolean(CameraConfiguration.Arguments.SHOW_PICKER);

        if (bundle.containsKey(CameraConfiguration.Arguments.ENABLE_CROP))
            enableImageCrop = bundle.getBoolean(CameraConfiguration.Arguments.ENABLE_CROP);

        if (bundle.containsKey(CameraConfiguration.Arguments.FLASH_MODE))
            switch (bundle.getInt(CameraConfiguration.Arguments.FLASH_MODE)) {
                case CameraConfiguration.FLASH_MODE_AUTO:
                    flashMode = CameraConfiguration.FLASH_MODE_AUTO;
                    break;
                case CameraConfiguration.FLASH_MODE_ON:
                    flashMode = CameraConfiguration.FLASH_MODE_ON;
                    break;
                case CameraConfiguration.FLASH_MODE_OFF:
                    flashMode = CameraConfiguration.FLASH_MODE_OFF;
                    break;
                default:
                    flashMode = CameraConfiguration.FLASH_MODE_AUTO;
                    break;
            }
    }
}
 
开发者ID:MartinRGB,项目名称:android_camera_experiment,代码行数:78,代码来源:BaseSandriosActivity.java

示例8: onCreate

@Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_preview);
        mContext = this;
        surfaceView = (SurfaceView) findViewById(R.id.video_preview);

        //隐藏掉Seekbar
//        surfaceView.setOnTouchListener(new View.OnTouchListener() {
//            @Override
//            public boolean onTouch(View v, MotionEvent event) {
//                if (mediaController == null) return false;
//                if (mediaController.isShowing()) {
//                    mediaController.hide();
//                    showButtonPanel(true);
//                } else {
//                    showButtonPanel(false);
//                    mediaController.show();
//                }
//                return false;
//            }
//        });

        videoPreviewContainer = (AspectFrameLayout) findViewById(R.id.previewAspectFrameLayout);
        photoPreviewContainer = (FrameLayout) findViewById(R.id.photo_preview_container);
        imagePreview = (UCropView) findViewById(R.id.image_view);
        buttonPanel = (ViewGroup) findViewById(R.id.preview_control_panel);
        View confirmMediaResult = findViewById(R.id.confirm_media_result);
        View reTakeMedia = findViewById(R.id.re_take_media);
        View cancelMediaAction = findViewById(R.id.cancel_media_action);

        findViewById(R.id.crop_image).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                UCrop.Options options = new UCrop.Options();
                options.setToolbarColor(ContextCompat.getColor(mContext, android.R.color.black));
                options.setStatusBarColor(ContextCompat.getColor(mContext, android.R.color.black));
                Uri uri = Uri.fromFile(new File(previewFilePath));
                UCrop.of(uri, uri)
                        .withOptions(options)
                        .start(mContext);
            }
        });

        if (confirmMediaResult != null)
            confirmMediaResult.setOnClickListener(this);

        if (reTakeMedia != null)
            reTakeMedia.setOnClickListener(this);

        if (cancelMediaAction != null)
            cancelMediaAction.setOnClickListener(this);

        Bundle args = getIntent().getExtras();

        mediaAction = args.getInt(MEDIA_ACTION_ARG);
        previewFilePath = args.getString(FILE_PATH_ARG);
        showCrop = args.getBoolean(SHOW_CROP);

        if (mediaAction == CameraConfiguration.MEDIA_ACTION_VIDEO) {
            displayVideo(savedInstanceState);
        } else if (mediaAction == CameraConfiguration.MEDIA_ACTION_PHOTO) {
            displayImage();
        } else {
            String mimeType = Utils.getMimeType(previewFilePath);
            if (mimeType.contains(MIME_TYPE_VIDEO)) {
                displayVideo(savedInstanceState);
            } else if (mimeType.contains(MIME_TYPE_IMAGE)) {
                displayImage();
            } else finish();
        }
    }
 
开发者ID:MartinRGB,项目名称:android_camera_experiment,代码行数:72,代码来源:PreviewActivity.java

示例9: startPreview

private void startPreview(SurfaceHolder surfaceHolder) {
    try {
        Camera.CameraInfo cameraInfo = new Camera.CameraInfo();
        Camera.getCameraInfo(currentCameraId, cameraInfo);
        int cameraRotationOffset = cameraInfo.orientation;

        Camera.Parameters parameters = camera.getParameters();
        setAutoFocus(camera, parameters);
        setFlashMode(configurationProvider.getFlashMode());

        if (configurationProvider.getMediaAction() == CameraConfiguration.MEDIA_ACTION_PHOTO
                || configurationProvider.getMediaAction() == CameraConfiguration.MEDIA_ACTION_BOTH)
            turnPhotoCameraFeaturesOn(camera, parameters);
        else if (configurationProvider.getMediaAction() == CameraConfiguration.MEDIA_ACTION_PHOTO
                || configurationProvider.getMediaAction() == CameraConfiguration.MEDIA_ACTION_BOTH)
            turnVideoCameraFeaturesOn(camera, parameters);

        int rotation = ((WindowManager) context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay().getRotation();
        int degrees = 0;
        switch (rotation) {
            case Surface.ROTATION_0:
                degrees = 0;
                break; // Natural orientation
            case Surface.ROTATION_90:
                degrees = 90;
                break; // Landscape left
            case Surface.ROTATION_180:
                degrees = 180;
                break;// Upside down
            case Surface.ROTATION_270:
                degrees = 270;
                break;// Landscape right
        }

        if (cameraInfo.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) {
            displayRotation = (cameraRotationOffset + degrees) % 360;
            displayRotation = (360 - displayRotation) % 360; // compensate
        } else {
            displayRotation = (cameraRotationOffset - degrees + 360) % 360;
        }

        this.camera.setDisplayOrientation(displayRotation);

        if (Build.VERSION.SDK_INT > 14
                && parameters.isVideoStabilizationSupported()
                && (configurationProvider.getMediaAction() == CameraConfiguration.MEDIA_ACTION_VIDEO
                || configurationProvider.getMediaAction() == CameraConfiguration.MEDIA_ACTION_BOTH)) {
            parameters.setVideoStabilization(true);
        }

        parameters.setPreviewSize(previewSize.getWidth(), previewSize.getHeight());
        parameters.setPictureSize(photoSize.getWidth(), photoSize.getHeight());

        camera.setParameters(parameters);
        camera.setPreviewDisplay(surfaceHolder);
        camera.startPreview();
        safeToTakePicture = true;

    } catch (IOException error) {
        Log.d(TAG, "Error setting camera preview: " + error.getMessage());
    } catch (Exception ignore) {
        Log.d(TAG, "Error starting camera preview: " + ignore.getMessage());
    }
}
 
开发者ID:sandrios,项目名称:sandriosCamera,代码行数:64,代码来源:Camera1Manager.java

示例10: onCreate

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_preview);
    mContext = this;
    surfaceView = (SurfaceView) findViewById(R.id.video_preview);
    surfaceView.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            if (mediaController == null) return false;
            if (mediaController.isShowing()) {
                mediaController.hide();
                showButtonPanel(true);
            } else {
                showButtonPanel(false);
                mediaController.show();
            }
            return false;
        }
    });

    videoPreviewContainer = (AspectFrameLayout) findViewById(R.id.previewAspectFrameLayout);
    photoPreviewContainer = (FrameLayout) findViewById(R.id.photo_preview_container);
    imagePreview = (UCropView) findViewById(R.id.image_view);
    buttonPanel = (ViewGroup) findViewById(R.id.preview_control_panel);
    View confirmMediaResult = findViewById(R.id.confirm_media_result);
    View reTakeMedia = findViewById(R.id.re_take_media);
    View cancelMediaAction = findViewById(R.id.cancel_media_action);

    findViewById(R.id.crop_image).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            UCrop.Options options = new UCrop.Options();
            options.setToolbarColor(ContextCompat.getColor(mContext, android.R.color.black));
            options.setStatusBarColor(ContextCompat.getColor(mContext, android.R.color.black));
            Uri uri = Uri.fromFile(new File(previewFilePath));
            UCrop.of(uri, uri)
                    .withOptions(options)
                    .start(mContext);
        }
    });

    if (confirmMediaResult != null)
        confirmMediaResult.setOnClickListener(this);

    if (reTakeMedia != null)
        reTakeMedia.setOnClickListener(this);

    if (cancelMediaAction != null)
        cancelMediaAction.setOnClickListener(this);

    Bundle args = getIntent().getExtras();

    mediaAction = args.getInt(MEDIA_ACTION_ARG);
    previewFilePath = args.getString(FILE_PATH_ARG);
    showCrop = args.getBoolean(SHOW_CROP);

    if (mediaAction == CameraConfiguration.MEDIA_ACTION_VIDEO) {
        displayVideo(savedInstanceState);
    } else if (mediaAction == CameraConfiguration.MEDIA_ACTION_PHOTO) {
        displayImage();
    } else {
        String mimeType = Utils.getMimeType(previewFilePath);
        if (mimeType.contains(MIME_TYPE_VIDEO)) {
            displayVideo(savedInstanceState);
        } else if (mimeType.contains(MIME_TYPE_IMAGE)) {
            displayImage();
        } else finish();
    }
}
 
开发者ID:sandrios,项目名称:sandriosCamera,代码行数:70,代码来源:PreviewActivity.java


注:本文中的com.sandrios.sandriosCamera.internal.configuration.CameraConfiguration.MEDIA_ACTION_VIDEO属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。