Java Code Examples for android.media.MediaRecorder#setOnInfoListener()
The following examples show how to use
android.media.MediaRecorder#setOnInfoListener() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OBGeneralAudioRecorder.java From GLEXP-Team-onebillion with Apache License 2.0 | 6 votes |
protected void initRecorder() { audioRecorder = new MediaRecorder(); audioRecorder.setAudioSource(MediaRecorder.AudioSource.MIC); audioRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP); audioRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC); audioRecorder.setAudioEncodingBitRate(128000); audioRecorder.setAudioSamplingRate(44100); audioRecorder.setOutputFile(recordingPath); audioRecorder.setOnInfoListener(new MediaRecorder.OnInfoListener() { @Override public void onInfo(MediaRecorder mediaRecorder, int i, int i1) { stopRecording(); } }); }
Example 2
Source File: SoundRecorder.java From appinventor-extensions with Apache License 2.0 | 6 votes |
RecordingController(String savedRecording) throws IOException { // pick a pathname if none was specified file = (savedRecording.equals("")) ? FileUtil.getRecordingFile("3gp").getAbsolutePath() : savedRecording; recorder = new MediaRecorder(); recorder.setAudioSource(MediaRecorder.AudioSource.MIC); recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP); recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB); Log.i(TAG, "Setting output file to " + file); recorder.setOutputFile(file); Log.i(TAG, "preparing"); recorder.prepare(); recorder.setOnErrorListener(SoundRecorder.this); recorder.setOnInfoListener(SoundRecorder.this); }
Example 3
Source File: StreamingRecorder.java From DeviceConnect-Android with MIT License | 6 votes |
/** * 動画撮影のための準備を行います. * * @throws IOException 動画撮影の準備に失敗した場合に発生 */ public synchronized void setUpMediaRecorder(File outputFile) throws IOException { if (DEBUG) { Log.e(TAG, "Set up MediaRecorder"); Log.e(TAG, " VideoSize: " + mSettings.getWidth() + "x" + mSettings.getHeight()); Log.e(TAG, " BitRate: " + mSettings.getBitRate()); Log.e(TAG, " FrameRate: " + mSettings.getFrameRate()); Log.e(TAG, " OutputFile: " + outputFile.getAbsolutePath()); } int rotation = getDisplayRotation(); mMediaRecorder = new MediaRecorder(); mMediaRecorder.setAudioSource(MediaRecorder.AudioSource.MIC); mMediaRecorder.setVideoSource(MediaRecorder.VideoSource.SURFACE); mMediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4); mMediaRecorder.setOutputFile(outputFile.getAbsolutePath()); mMediaRecorder.setVideoEncodingBitRate(mSettings.getBitRate()); mMediaRecorder.setVideoFrameRate(mSettings.getFrameRate()); mMediaRecorder.setVideoSize(mSettings.getWidth(), mSettings.getHeight()); mMediaRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.H264); mMediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC); mMediaRecorder.setOrientationHint(ORIENTATIONS[mSettings.getSensorOrientation()].get(rotation)); mMediaRecorder.setOnInfoListener(mOnInfoListener); mMediaRecorder.setOnErrorListener(mOnErrorListener); mMediaRecorder.prepare(); }
Example 4
Source File: VideoRecorder.java From VideoCamera with Apache License 2.0 | 5 votes |
@SuppressWarnings("deprecation") protected void configureMediaRecorder(final MediaRecorder recorder, android.hardware.Camera camera) throws IllegalStateException, IllegalArgumentException { recorder.setCamera(camera); recorder.setAudioSource(mCaptureConfiguration.getAudioSource()); recorder.setVideoSource(mCaptureConfiguration.getVideoSource()); CamcorderProfile baseProfile = mCameraWrapper.getBaseRecordingProfile(); baseProfile.fileFormat = mCaptureConfiguration.getOutputFormat(); RecordingSize size = mCameraWrapper.getSupportedRecordingSize(mCaptureConfiguration.getVideoWidth(), mCaptureConfiguration.getVideoHeight()); baseProfile.videoFrameWidth = size.width; baseProfile.videoFrameHeight = size.height; baseProfile.videoBitRate = mCaptureConfiguration.getVideoBitrate(); baseProfile.audioCodec = mCaptureConfiguration.getAudioEncoder(); baseProfile.videoCodec = mCaptureConfiguration.getVideoEncoder(); recorder.setProfile(baseProfile); recorder.setMaxDuration(mCaptureConfiguration.getMaxCaptureDuration()); recorder.setOutputFile(mVideoFile.getFullPath()); recorder.setOrientationHint(mCameraWrapper.getRotationCorrection()); try { recorder.setMaxFileSize(mCaptureConfiguration.getMaxCaptureFileSize()); } catch (IllegalArgumentException e) { CLog.e(CLog.RECORDER, "Failed to set max filesize - illegal argument: " + mCaptureConfiguration.getMaxCaptureFileSize()); } catch (RuntimeException e2) { CLog.e(CLog.RECORDER, "Failed to set max filesize - runtime exception"); } recorder.setOnInfoListener(this); }
Example 5
Source File: AudioRecorder.java From ChatMessagesAdapter-android with BSD 3-Clause "New" or "Revised" License | 5 votes |
private void initMediaRecorder() { recorder = new MediaRecorder(); recorder.setAudioSource(configurationBuilder.audioSource); recorder.setOutputFormat(configurationBuilder.outputFormat); recorder.setOutputFile(configurationBuilder.filePath); recorder.setAudioChannels(configurationBuilder.channels); recorder.setAudioEncoder(configurationBuilder.audioEncoder); recorder.setAudioEncodingBitRate(configurationBuilder.bitRate); recorder.setAudioSamplingRate(configurationBuilder.samplingRate); recorder.setMaxDuration(configurationBuilder.duration); recorder.setOnInfoListener(new OnInfoListenerImpl()); recorder.setOnErrorListener(new OnErrorListenerImpl()); }
Example 6
Source File: ApplozicAudioRecordManager.java From Applozic-Android-SDK with BSD 3-Clause "New" or "Revised" License | 5 votes |
public MediaRecorder prepareMediaRecorder() { audioRecorder = new MediaRecorder(); audioRecorder.setAudioSource(MediaRecorder.AudioSource.MIC); audioRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4); audioRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC); audioRecorder.setAudioEncodingBitRate(256); audioRecorder.setAudioChannels(1); audioRecorder.setAudioSamplingRate(44100); audioRecorder.setOutputFile(outputFile); audioRecorder.setOnInfoListener(this); audioRecorder.setOnErrorListener(this); return audioRecorder; }
Example 7
Source File: VideoRecorder.java From LandscapeVideoCamera with Apache License 2.0 | 5 votes |
@SuppressWarnings("deprecation") protected void configureMediaRecorder(final MediaRecorder recorder, android.hardware.Camera camera) throws IllegalStateException, IllegalArgumentException { recorder.setCamera(camera); recorder.setAudioSource(mCaptureConfiguration.getAudioSource()); recorder.setVideoSource(mCaptureConfiguration.getVideoSource()); CamcorderProfile baseProfile = mCameraWrapper.getBaseRecordingProfile(); baseProfile.fileFormat = mCaptureConfiguration.getOutputFormat(); RecordingSize size = mCameraWrapper.getSupportedRecordingSize(mCaptureConfiguration.getVideoWidth(), mCaptureConfiguration.getVideoHeight()); baseProfile.videoFrameWidth = size.width; baseProfile.videoFrameHeight = size.height; baseProfile.videoBitRate = mCaptureConfiguration.getVideoBitrate(); baseProfile.audioCodec = mCaptureConfiguration.getAudioEncoder(); baseProfile.videoCodec = mCaptureConfiguration.getVideoEncoder(); recorder.setProfile(baseProfile); recorder.setMaxDuration(mCaptureConfiguration.getMaxCaptureDuration()); recorder.setOutputFile(mVideoFile.getFullPath()); recorder.setOrientationHint(mCameraWrapper.getRotationCorrection()); recorder.setVideoFrameRate(mCaptureConfiguration.getVideoFPS()); try { recorder.setMaxFileSize(mCaptureConfiguration.getMaxCaptureFileSize()); } catch (IllegalArgumentException e) { CLog.e(CLog.RECORDER, "Failed to set max filesize - illegal argument: " + mCaptureConfiguration.getMaxCaptureFileSize()); } catch (RuntimeException e2) { CLog.e(CLog.RECORDER, "Failed to set max filesize - runtime exception"); } recorder.setOnInfoListener(this); }
Example 8
Source File: WhatsappCameraActivity.java From WhatsAppCamera with MIT License | 4 votes |
@SuppressLint("SimpleDateFormat") protected boolean prepareMediaRecorder() throws IOException { mediaRecorder = new MediaRecorder(); // Works well camera.stopPreview(); camera.unlock(); mediaRecorder.setCamera(camera); mediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA); mediaRecorder.setAudioSource(MediaRecorder.AudioSource.MIC); if (flag == 1) { mediaRecorder.setProfile(CamcorderProfile.get(1, CamcorderProfile.QUALITY_HIGH)); } else { mediaRecorder.setProfile(CamcorderProfile.get(CamcorderProfile.QUALITY_HIGH)); } mediaRecorder.setPreviewDisplay(surfaceHolder.getSurface()); mediaRecorder.setOrientationHint(mOrientation); if (Build.MODEL.equalsIgnoreCase("Nexus 6") && flag == 1) { if (mOrientation == 90) { mediaRecorder.setOrientationHint(mOrientation); } else if (mOrientation == 180) { mediaRecorder.setOrientationHint(0); } else { mediaRecorder.setOrientationHint(180); } } else if (mOrientation == 90 && flag == 1) { mediaRecorder.setOrientationHint(270); } else if (flag == 1) { mediaRecorder.setOrientationHint(mOrientation); } mediaFileName = "wc_vid_" + System.currentTimeMillis(); mediaRecorder.setOutputFile(folder.getAbsolutePath() + "/" + mediaFileName + ".mp4"); // Environment.getExternalStorageDirectory() mediaRecorder.setOnInfoListener(new MediaRecorder.OnInfoListener() { public void onInfo(MediaRecorder mr, int what, int extra) { // TODO Auto-generated method stub if (what == MediaRecorder.MEDIA_RECORDER_INFO_MAX_FILESIZE_REACHED) { long downTime = 0; long eventTime = 0; float x = 0.0f; float y = 0.0f; int metaState = 0; MotionEvent motionEvent = MotionEvent.obtain( downTime, eventTime, MotionEvent.ACTION_UP, 0, 0, metaState ); imgCapture.dispatchTouchEvent(motionEvent); Toast.makeText(WhatsappCameraActivity.this, "You reached to Maximum(25MB) video size.", Toast.LENGTH_SHORT).show(); } } }); mediaRecorder.setMaxFileSize(1000 * 25 * 1000); try { mediaRecorder.prepare(); } catch (Exception e) { releaseMediaRecorder(); e.printStackTrace(); return false; } return true; }