本文整理汇总了Java中android.media.MediaRecorder.setProfile方法的典型用法代码示例。如果您正苦于以下问题:Java MediaRecorder.setProfile方法的具体用法?Java MediaRecorder.setProfile怎么用?Java MediaRecorder.setProfile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.media.MediaRecorder
的用法示例。
在下文中一共展示了MediaRecorder.setProfile方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: configureRecorder
import android.media.MediaRecorder; //导入方法依赖的package包/类
protected void configureRecorder(int quality, MediaRecorder recorder) {
Camera.CameraInfo info = new Camera.CameraInfo();
Camera.getCameraInfo(cameraInfo.cameraId, info);
int displayOrientation = getDisplayOrientation(info, false);
recorder.setOrientationHint(displayOrientation);
int highProfile = getHigh();
boolean canGoHigh = CamcorderProfile.hasProfile(cameraInfo.cameraId, highProfile);
boolean canGoLow = CamcorderProfile.hasProfile(cameraInfo.cameraId, CamcorderProfile.QUALITY_LOW);
if (canGoHigh && (quality == 1 || !canGoLow)) {
recorder.setProfile(CamcorderProfile.get(cameraInfo.cameraId, highProfile));
} else if (canGoLow) {
recorder.setProfile(CamcorderProfile.get(cameraInfo.cameraId, CamcorderProfile.QUALITY_LOW));
} else {
throw new IllegalStateException("cannot find valid CamcorderProfile");
}
isVideo = true;
}
示例2: _startRecording
import android.media.MediaRecorder; //导入方法依赖的package包/类
private synchronized void _startRecording(Camera camera, String outPutFile, int rotationHint, int maxdurationMillis, CamcorderProfile profile)
{
/**
* IMPORTANT - Do not change the order of the steps in this function. Code
* taken from the google camcoder sample
*
*/
Log.d(ImagingUtils.TAG, "start recording video");
mIsRecording = true;
// Step 1: Unlock and set camera to MediaRecorder
mRecorder = new MediaRecorder();
camera.unlock();
mRecorder.setCamera(camera);
// Step 2: Set sources
mRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
mRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
// Step 3: Set a CamcorderProfile (requires API Level 8 or higher)
mRecorder.setProfile(profile);
// Step 4: Set rotation and max duration
//clckwise rotation for composition matrix as opposed to the 90degree anti-clockwise
//rotation for the camera viewfinder
//NOTE : This only works on some media players. Eg: works on VLC windows but not on VLC Linux
mRecorder.setOrientationHint(rotationHint);
mRecorder.setMaxDuration(maxdurationMillis + 1000);
// Step 5 : set the file
mRecorder.setOutputFile(outPutFile);
// Step 6 : Prepare
try
{
mRecorder.prepare();
}
catch (IOException e)
{
//Log.e("MediaRecorder prepare failed");
e.printStackTrace();
}
mRecorder.start();
}