MediaRecorder setMaxDuration - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for MediaRecorder setMaxDuration method.

This code example shows how to use the following methods:setAudioSource, setMaxDuration, setMaxFileSize, setOutputFile, setProfile
		cameraView.setClickable(true);
		cameraView.setOnClickListener(this);
	} 
 
	private void initRecorder() { 
		recorder.setAudioSource(MediaRecorder.AudioSource.DEFAULT);
		recorder.setVideoSource(MediaRecorder.VideoSource.DEFAULT);
 
		CamcorderProfile cpHigh = CamcorderProfile
				.get(CamcorderProfile.QUALITY_HIGH);
		recorder.setProfile(cpHigh);
		recorder.setOutputFile("/sdcard/videocapture_example.mp4");
		recorder.setMaxDuration(50000); // 50 seconds
		recorder.setMaxFileSize(5000000); // Approximately 5 megabytes
	} 
 
	private void prepareRecorder() { 
		recorder.setPreviewDisplay(holder.getSurface());
 
		try { 
8
CodeRank
This code example shows how to use the following methods:setAudioSource, setMaxDuration, setMaxFileSize, setOutputFile, setProfile
		// TODO Auto-generated method stub 
 
	} 
 
	private void initMediaRecorder() { 
		mediaRecorder.setAudioSource(MediaRecorder.AudioSource.DEFAULT);
		mediaRecorder.setVideoSource(MediaRecorder.VideoSource.DEFAULT);
		CamcorderProfile camcorderProfile_HQ = CamcorderProfile
				.get(CamcorderProfile.QUALITY_HIGH);
		CamcorderProfile camcorderProfile_LOW = CamcorderProfile
				.get(CamcorderProfile.QUALITY_LOW);
		mediaRecorder.setProfile(camcorderProfile_LOW);
		mediaRecorder.setOutputFile("/sdcard/hookupvideo.mp4");
		mediaRecorder.setMaxDuration(30000); // Set max duration 60 sec.
		mediaRecorder.setMaxFileSize(5000000); // Set max file size 5M
	} 
 
	private void prepareMediaRecorder() { 
		mediaRecorder.setPreviewDisplay(surfaceHolder.getSurface());
		try { 
7
CodeRank
This code example shows how to use the following methods:setAudioSource, setMaxDuration, setOutputFile, setProfile, setVideoSource
         WindowManager.LayoutParams.FLAG_FULLSCREEN);
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
 
        String videoPath = "";
         
        recorder = new MediaRecorder();// Instantiate our media recording object
        initRecorder(videoPath);
        //setContentView(R.layout.view); 
 
        SurfaceView cameraView = null;// (SurfaceView) findViewById(R.id.surface_view);
        holder = cameraView.getHolder();
        holder.addCallback(this);
        holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
 
        cameraView.setClickable(true);// make the surface view clickable
        cameraView.setOnClickListener((OnClickListener) this);// onClicklistener to be called when the surface view is clicked
    } 
 
 
    private void initRecorder (String path)

7
CodeRank
This code example shows how to use the following methods:setAudioSource, setMaxDuration, setMaxFileSize, setOutputFile, setProfile
		Log.v(TAG, "onCreate finished");
	} 
 
	private void initRecorder() { 
		Log.v(TAG, "in initRecorder");
		recorder.setAudioSource(MediaRecorder.AudioSource.DEFAULT);
		Log.v(TAG, "set audio src");
		recorder.setVideoSource(MediaRecorder.VideoSource.DEFAULT);
		Log.v(TAG, "set video src");
 
		CamcorderProfile cpHigh = CamcorderProfile
				.get(CamcorderProfile.QUALITY_HIGH);
		recorder.setProfile(cpHigh);
		recorder.setOutputFile(Environment.getExternalStorageDirectory().getPath() + "/videocapture_example.mp4");
		recorder.setMaxDuration(50000); // 50 seconds
		recorder.setMaxFileSize(5000000); // Approximately 5 megabytes
		Log.v(TAG, "recorder initialized");
	} 
 
	private void prepareRecorder() { 
		recorder.setPreviewDisplay(holder.getSurface());
7
CodeRank
This code example shows how to use the following methods:setAudioEncoder, setAudioSource, setMaxDuration, setOutputFile, setOutputFormat
	private boolean isRecording = false;
	private Context mContext;
 
	//////// ********* Constructor ********* ////////// 
	public RecordingHelper(File mPath, Context _context) {
		mRecorder = new MediaRecorder();
		if (android.os.Environment.getExternalStorageState().equals(android.os.Environment.MEDIA_MOUNTED)) {
			mRecorder.setAudioSource(MediaRecorder.AudioSource.DEFAULT);
			mRecorder.setOutputFormat(MediaRecorder.OutputFormat.RAW_AMR);
			mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
			mRecorder.setOutputFile(mPath.toString());
			mRecorder.setMaxDuration(60000 * 60);
		} else { 
			Toast.makeText(mContext, "sdcard not available", Toast.LENGTH_LONG).show();
		} 
	} 
 
	/////// ********* Function to start recording ********* ///////// 
	public void startRecording() { 
		if (android.os.Environment.getExternalStorageState().equals(android.os.Environment.MEDIA_MOUNTED)) {
7
CodeRank
This code example shows how to use the following methods:setAudioSource, setMaxDuration, setMaxFileSize, setOutputFile, setProfile
	    
 
	    private void initRecorder()  
	    { 
	    	Log.d(TAG, "initRecorder called");
	        recorder.setAudioSource(MediaRecorder.AudioSource.DEFAULT);
	        recorder.setVideoSource(MediaRecorder.VideoSource.DEFAULT);
 
	        CamcorderProfile cpHigh = CamcorderProfile
	                .get(CamcorderProfile.QUALITY_LOW);
	        recorder.setProfile(cpHigh);
	        recorder.setOutputFile(Environment.getExternalStorageDirectory()+"/videocapture_example.mp4");
	        recorder.setMaxDuration(6000); // 6 seconds
	        recorder.setMaxFileSize(500000); // Approximately 5 megabytes
//	        new Handler().postDelayed(new Runnable() 
//	       	 { 
//	 
//					@Override 
//					public void run()  
//					{ 
6
CodeRank
This code example shows how to use the following methods:setAudioSource, setMaxDuration, setMaxFileSize, setOutputFile, setProfile
    cameraView.setClickable(true);
    cameraView.setOnClickListener(this);
} 
 
private void initRecorder() { 
    recorder.setAudioSource(MediaRecorder.AudioSource.DEFAULT);
    recorder.setVideoSource(MediaRecorder.VideoSource.DEFAULT);
 
    CamcorderProfile cpHigh = CamcorderProfile
            .get(CamcorderProfile.QUALITY_HIGH);
    recorder.setProfile(cpHigh);
    recorder.setOutputFile("/sdcard/capture.mp4");
    recorder.setMaxDuration(5000); // 5 seconds
    recorder.setMaxFileSize(5000000); // Approximately 5 megabytes
     
} 
 
private void prepareRecorder() { 
    recorder.setPreviewDisplay(holder.getSurface());
 
6
CodeRank
This code example shows how to use the following methods:setAudioSource, setMaxDuration, setMaxFileSize, setOutputFile, setProfile
    } 
 
    //CVM01_V01 - to start the recorder... 
    // CVM02_V01 encoding 
    private void initRecorder() { 
        recorder.setAudioSource(MediaRecorder.AudioSource.DEFAULT);
        recorder.setVideoSource(MediaRecorder.VideoSource.DEFAULT);
 
        CamcorderProfile cpHigh = CamcorderProfile
                .get(CamcorderProfile.QUALITY_HIGH);
        recorder.setProfile(cpHigh);
        recorder.setOutputFile(filePath);
        recorder.setMaxDuration(5000); // 50 seconds
        recorder.setMaxFileSize(5000000); // Approximately 5 megabytes
    } 
 
    private void prepareRecorder() { 
        recorder.setPreviewDisplay(holder.getSurface());
 
        try { 
6
CodeRank
This code example shows how to use the following methods:setAudioSource, setMaxDuration, setMaxFileSize, setOutputFile, setProfile
        } 
    } 
 
    private void initRecorder(File file) {
         
        recorder.setAudioSource(MediaRecorder.AudioSource.DEFAULT);
        recorder.setVideoSource(MediaRecorder.VideoSource.DEFAULT);
 
        CamcorderProfile cpHigh = CamcorderProfile
                .get(CamcorderProfile.QUALITY_HIGH);
        recorder.setProfile(cpHigh);
        recorder.setOutputFile(file.getPath());
        recorder.setMaxDuration(50000); // 50 seconds
        recorder.setMaxFileSize(5000000); // Approximately 5 megabytes
    } 
 
} 
6
CodeRank
This code example shows how to use the following methods:setAudioSource, setMaxDuration, setMaxFileSize, setOutputFile, setProfile
		 
	 
	} 
	 
	private void initRecorder() { 
		recorder.setAudioSource(MediaRecorder.AudioSource.DEFAULT);
		recorder.setVideoSource(MediaRecorder.VideoSource.DEFAULT);
 
		CamcorderProfile cpHigh = CamcorderProfile
				.get(CamcorderProfile.QUALITY_HIGH);
		recorder.setProfile(cpHigh);
 
		recorder.setOutputFile(OutputFile.getAbsolutePath()+video+count+".mp4");
		//recorder.setOutputFile("/sdcard/videocapture_example.mp4"); 
		recorder.setMaxDuration(50000); // 50 seconds
		recorder.setMaxFileSize(50000000); // Approximately 5 megabytes
	} 
	 
	private void prepareRecorder() { 
		recorder.setPreviewDisplay(holder.getSurface());
 
6
CodeRank

Related MediaRecorder setMaxDuration Questions & Answers:

setMaxDuration Method Overview
Sets the maximum duration (in ms) of the recording session.
See Code Examples for other Android MediaRecorder Methods: