本文整理汇总了Java中android.media.MediaRecorder.setMaxDuration方法的典型用法代码示例。如果您正苦于以下问题:Java MediaRecorder.setMaxDuration方法的具体用法?Java MediaRecorder.setMaxDuration怎么用?Java MediaRecorder.setMaxDuration使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.media.MediaRecorder
的用法示例。
在下文中一共展示了MediaRecorder.setMaxDuration方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: startRecorderInternal
import android.media.MediaRecorder; //导入方法依赖的package包/类
private boolean startRecorderInternal() throws Exception {
shutdownCamera();
if (!initCamera())
return false;
switchCamera.setVisibility(View.GONE);
mediaRecorder = new MediaRecorder();
camera.unlock();
mediaRecorder.setCamera(camera);
mediaRecorder.setAudioSource(MediaRecorder.AudioSource.CAMCORDER);
mediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
setCamcorderProfile();
mediaRecorder.setPreviewDisplay(surfaceHolder.getSurface());
mediaRecorder.setMaxDuration(1000 * VIDEO_TIMES);
mediaRecorder.setOutputFile(filename);
setVideoOrientation();
mediaRecorder.prepare();
mediaRecorder.start();
return true;
}
示例2: startRecording
import android.media.MediaRecorder; //导入方法依赖的package包/类
public static void startRecording(Context context, MediaRecorder recorder, String word) {
recorder.reset();
recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
recorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC);
recorder.setMaxDuration(10000);
recorder.setAudioSamplingRate(16000);
recorder.setAudioEncodingBitRate(16000*4*1);
recorder.setAudioSamplingRate(44100);
recorder.setAudioChannels(1);
recorder.setOutputFile(context.getFilesDir().getAbsolutePath() + "/" + word + ".aac");
try {
recorder.prepare();
} catch (IOException e) {
e.printStackTrace();
}
recorder.start();
}
示例3: doInBackground
import android.media.MediaRecorder; //导入方法依赖的package包/类
@Override
protected String doInBackground(String... params) {
MediaRecorder recorder = new MediaRecorder();;
SimpleDateFormat sdf = new SimpleDateFormat("yyyy_MM_dd_HH_mm");
String currentDateandTime = sdf.format(new Date());
String filename =currentDateandTime + ".3gp";
File diretory = new File(PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).getString("File", "") + File.separator + "Audio");
diretory.mkdirs();
File outputFile = new File(diretory, filename);
recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
recorder.setMaxDuration(Integer.parseInt(i));
recorder.setMaxFileSize(1000000);
recorder.setOutputFile(outputFile.toString());
try
{
recorder.prepare();
recorder.start();
} catch (IOException e) {
Log.i("com.connect", "io problems while preparing");
e.printStackTrace();
}
return "Executed";
}
示例4: _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();
}