MediaRecorder setPreviewDisplay - 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 setPreviewDisplay method.

This code example shows how to use the following methods:prepare, release, reset, setPreviewDisplay, start
        myMediaRecorder.setProfile(targetProfile);
    } 
    
    private boolean realyStart() { 
         
        myMediaRecorder.setPreviewDisplay(myCamSHolder.getSurface());
        try { 
        	myMediaRecorder.prepare();
	    } catch (IllegalStateException e) {
	        releaseMediaRecorder();	 
	        Log.d("TEAONLY", "JAVA:  camera prepare illegal error");
            return false; 
	    } catch (IOException e) {
	        releaseMediaRecorder();	     
	        Log.d("TEAONLY", "JAVA:  camera prepare io error");
            return false; 
	    } 
	     
        try { 
            myMediaRecorder.start();

6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:prepare, setAudioSource, setMaxDuration, setMaxFileSize, setOutputFile
		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 { 

6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:prepare, setOutputFile, setPreviewDisplay
		  
		// recorder.setMaxDuration(10000); 
	} 
 
	public void surfaceCreated(SurfaceHolder holder) {
		recorder.setOutputFile(outputFile);
		recorder.setPreviewDisplay(holder.getSurface());
		if (recorder != null) {
			try { 
				recorder.prepare();
			} catch (IllegalStateException e) {
				Log.e("IllegalStateException", e.toString());
			} catch (IOException e) {
				Log.e("IOException", e.toString());
			} 
		} 
	} 
	 
	public void surfaceChanged(SurfaceHolder holder, int format, int width,
			int height) {
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:setOutputFormat, setPreviewDisplay, setVideoEncoder, setVideoFrameRate, setVideoSize
	{						 
		if ( mRecorder != null){
			mRecorder.reset();
			mRecorder.release();
		} 
		mRecorder = new MediaRecorder();
		try { 
	    	mRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);  
	    	mRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
	        mRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.H264);
	        mRecorder.setVideoFrameRate(27);
	        mRecorder.setVideoSize(640, 480);   
		} catch(RuntimeException e) {
			Log.e(TAG, "Could not set camera settings",e );
			return; 
		} 
         
        if(mViewer.hasSurface)
		{			 
			mRecorder.setPreviewDisplay(mViewer.holder.getSurface());

6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:prepare, release, reset, setOutputFile, setPreviewDisplay
        mMediaRecorder.setProfile( targetProfile );
 
    } 
 
    public boolean startRecording( String targetFile ) {
        mMediaRecorder.setOutputFile( targetFile );
 
        return reallyStart(); 
    } 
 
    private boolean reallyStart() { 
 
        mMediaRecorder.setPreviewDisplay( mCameraSurfaceHolder.getSurface() );
        try { 
            mMediaRecorder.prepare();
        } catch ( IllegalStateException e ) {
            releaseMediaRecorder(); 
            Log.d( "TEAONLY", "JAVA:  camera prepare illegal error" );
            return false; 
        } catch ( IOException e ) {

6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:prepare, setAudioSource, setCamera, setOutputFile, setPreviewDisplay
    public synchronized void startVideoRecording(String outputFilePath, int quality) throws IllegalStateException, IOException {
        if ( mCamera == null ) {
            throw new IllegalStateException("Camera wasn't initialized");
        } 
        mCamera.unlock();
        mRecorder = new MediaRecorder();
        mRecorder.setCamera(mCamera);
        mRecorder.setAudioSource(MediaRecorder.AudioSource.CAMCORDER);
        mRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
        /** 
         *      
         *     Set the video output format and encoding. For Android 2.2 (API Level 8) and higher, use the MediaRecorder.setProfile method,  
         *     and get a profile instance using CamcorderProfile.get().  
         *     setOutputFile() - Set the output file, use getOutputMediaFile(MEDIA_TYPE_VIDEO).toString() from the example method in the Saving Media Files section. 
         *     setPreviewDisplay() - Specify the SurfaceView preview layout element for your application. Use the same object you specified for Connect Preview. 
         *     Caution: You must call these MediaRecorder configuration methods in this order, otherwise your application will encounter errors and the recording will fail. 
         *     Prepare MediaRecorder - Prepare the MediaRecorder with provided configuration settings by calling MediaRecorder.prepare(). 
         *     Start MediaRecorder - Start recording video by calling MediaRecorder.start(). 
         */ 
        mRecorder.setProfile(CamcorderProfile.get(quality));

6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:setAudioSource, setCamera, setOutputFile, setPreviewDisplay, setProfile
	 */ 
	private int setRecorder(String path) {
		if (mCamera == null) {
			return 0; 
		} 
		mMedRecorder.setCamera(mCamera);
		mMedRecorder.setAudioSource(MediaRecorder.AudioSource.CAMCORDER);
		mMedRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
		mMedRecorder.setProfile(CamcorderProfile.get(mVideoQuality));
		mMedRecorder.setOutputFile(path + ".mp4");
		 
		if (mSurHolder != null) {
			mMedRecorder.setPreviewDisplay(mSurHolder.getSurface());
		} 
		return 1; 
	} 
 
	/** 
	 * @return name: succeed, "FAIL" mean prepare fail 
	 */ 
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:prepare, setAudioSource, setMaxDuration, setMaxFileSize, setOutputFile
		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() { 

6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:prepare, setAudioSource, setOutputFile, setPreviewDisplay, setProfile
        surfaceHolder.addCallback(this);
        surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
    } 
    protected void startRecording() throws IOException  
    { 
        mrec = new MediaRecorder();  // Works well
//        mCamera.unlock(); 
 
//        mrec.setCamera(mCamera); 
 
        mrec.setPreviewDisplay(surfaceHolder.getSurface());
        mrec.setVideoSource(MediaRecorder.VideoSource.CAMERA);
        mrec.setAudioSource(MediaRecorder.AudioSource.MIC); 
 
        mrec.setProfile(CamcorderProfile.get(CamcorderProfile.QUALITY_HIGH));
        mrec.setPreviewDisplay(surfaceHolder.getSurface());
        mrec.setOutputFile(mFileName); 
 
        mrec.prepare();
        mrec.start();

5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:prepare, setAudioSource, setCamera, setOutputFile, setPreviewDisplay
            recorder.start();
        } 
    } 
 
    private void prepareRecorder() { 
        recorder = new MediaRecorder();
        recorder.setPreviewDisplay(holder.getSurface());
 
        camera.unlock();
        recorder.setCamera(camera);
 
        recorder.setAudioSource(MediaRecorder.AudioSource.DEFAULT);
        recorder.setVideoSource(MediaRecorder.VideoSource.DEFAULT);
 
        recorder.setProfile(camcorderProfile);
 
        Time now = new Time();
        now.setToNow();
        String filename = now.format("Video-%Y-%m-%d-%H:%M:%S.mp4");
 

5
CodeRank
Experience pair programming with AI  Get Codota for Java

Related MediaRecorder setPreviewDisplay Questions & Answers:

setPreviewDisplay Method Overview
Sets a Surface to show a preview of recorded media (video).
See Code Examples for other Android MediaRecorder Methods: