/** * Iitializes the {@link MediaRecorder} ad relies on its lifecycle and requirements. * * @param saveToFile the File object to record into. Assumes the calling program has * permission to write to this file * @param displayWidth the Width of the display * @param displayHeight the Height of the display * @param errorListener optional {@link MediaRecorder.OnErrorListener} for recording state callbacks * @param infoListener optional {@link MediaRecorder.OnInfoListener} for info callbacks * @see MediaRecorder */ @SuppressWarnings({"all"}) public void initRecorder(File saveToFile, int displayWidth, int displayHeight, MediaRecorder.OnErrorListener errorListener, MediaRecorder.OnInfoListener infoListener) throws IOException { initRecorder(saveToFile, displayWidth, displayHeight, 0, errorListener, infoListener); }
private void stopRecording() { mRecordBtn.setText("Record"); Log.e(TAG, "Stopping"); mRecordableSurfaceView.stopRecording(); try { mOutputFile = getVideoFile(); android.graphics.Point size = new android.graphics.Point(); getWindowManager().getDefaultDisplay().getRealSize(size); mRecordableSurfaceView.initRecorder(mOutputFile, size.x, size.y, null, null); } catch (IOException ioex) { Log.e(TAG, "Couldn't re-init recording", ioex); } mIsRecording = false; Toast.makeText(this, "File recording complete: " + getVideoFile().getAbsolutePath(), Toast.LENGTH_LONG).show(); }
@Override public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { super.onRequestPermissionsResult(requestCode, permissions, grantResults); // Note that order matters - see the note in onPause(), the reverse applies here. mGLView.resume(); try { mOutputFile = createVideoOutputFile(); android.graphics.Point size = new android.graphics.Point(); getWindowManager().getDefaultDisplay().getRealSize(size); mGLView.initRecorder(mOutputFile, size.x, size.y, null, null); } catch (IOException ioex) { Log.e(TAG, "Couldn't re-init recording", ioex); } }
private void stopRecording() { if (mIsRecording) { mTimeElapsedTextView.setText("0:00"); mRecordableSurfaceView.stopRecording(); try { mCurrentVideoFile = getVideoFile(); android.graphics.Point size = new android.graphics.Point(); getWindowManager().getDefaultDisplay().getRealSize(size); mRecordableSurfaceView.initRecorder(mCurrentVideoFile, size.x, size.y, null, null); } catch (IOException ioex) { Log.e(TAG, "Couldn't re-init recording", ioex); } mIsRecording = false; } mRecordButton.setBackgroundResource(R.drawable.record_off); mRecordButton.setEnabled(true); //restart the camera with anew surface Toast.makeText(this, "File recording complete: " + getVideoFile().getAbsolutePath(), Toast.LENGTH_LONG).show(); }
@Override protected void onResume() { super.onResume(); // The following call resumes a paused rendering thread. // If you de-allocated graphic objects for onPause() // this is a good place to re-allocate them. if (PermissionsHelper.hasPermissions(this)) { // Note that order matters - see the note in onPause(), the reverse applies here. mGLView.resume(); try { mOutputFile = createVideoOutputFile(); android.graphics.Point size = new android.graphics.Point(); getWindowManager().getDefaultDisplay().getRealSize(size); mGLView.initRecorder(mOutputFile, size.x, size.y, null, null); } catch (IOException ioex) { Log.e(TAG, "Couldn't re-init recording", ioex); } } else { PermissionsHelper.requestPermissions(this); } }
@Override public boolean onOptionsItemSelected(MenuItem item) { if (mIsRecording) { mGLView.stopRecording(); Uri contentUri = FileProvider.getUriForFile(this, "com.example.android.opengl.fileprovider", mOutputFile); share(contentUri); mIsRecording = false; mIsRecording = false; mOutputFile = createVideoOutputFile(); try { int screenWidth = mGLView.getWidth(); int screenHeight = mGLView.getHeight(); mGLView.initRecorder(mOutputFile, (int) screenWidth, (int) screenHeight, null, null); } catch (IOException ioex) { Log.e(TAG, "Couldn't re-init recording", ioex); } item.setTitle("Record"); } else { mGLView.startRecording(); Log.v(TAG, "Recording Started"); item.setTitle("Stop"); mIsRecording = true; } return true; }
getWindowManager().getDefaultDisplay().getRealSize(size); try { mRecordableSurfaceView.initRecorder(mOutputFile, size.x, size.y, null, null); } catch (IOException ioex) { Log.e(TAG, "Couldn't re-init recording", ioex);
private void setReady() { getImage(getIntent()); android.graphics.Point size = new android.graphics.Point(); getWindowManager().getDefaultDisplay().getRealSize(size); //then setup our camera renderer mRenderer = new LipFlipRenderer(this, size.x, size.y); mBitmapHandler = new BitmapHandler(this); mRenderer.setBitmapHandler(mBitmapHandler); mRenderer.setInitialBitmap(mInitialBitmap); Bitmap theMap = mPaintView.getDrawingCopy(size.x, size.y); mRenderer.setPaintTexture(theMap); setupCameraFragment(mRenderer); //now that renderer is created and ready, await new bitmaps mPaintView.setOnNewBitmapReadyListener(this); mPaintView.hintSize(size.x, size.y); //initial config if needed mRecordableSurfaceView.resume(); try { mOutputFile = getFile("lipflip_"); mRecordableSurfaceView.initRecorder(mOutputFile, size.x, size.y, null, null); mVideoFragment.setVideoRenderer(mRenderer); } catch (IOException ioex) { Log.e(TAG, "Couldn't re-init recording", ioex); } }
mRecordableSurfaceView.initRecorder(mCurrentVideoFile, size.x, size.y, null, null);