符合中小企业对网站设计、功能常规化式的企业展示型网站建设
本套餐主要针对企业品牌型网站、中高端设计、前端互动体验...
商城网站建设因基本功能的需求不同费用上面也有很大的差别...
手机微信网站开发、微信官网、微信商城网站...
小编给大家分享一下java中如何初始化MediaRecorder,相信大部分人都还不怎么了解,因此分享这篇文章给大家参考一下,希望大家阅读完这篇文章后大有收获,下面让我们一起去了解一下吧!
成都创新互联公司专注于网站建设|成都网站维护|优化|托管以及网络推广,积累了大量的网站设计与制作经验,为许多企业提供了网站定制设计服务,案例作品覆盖成都轻质隔墙板等行业。能根据企业所处的行业与销售的产品,结合品牌形象的塑造,量身建设品质网站。
java中初始化MediaRecorder
实现代码:
private boolean initializeVideo() { Log.v(TAG, "initializeVideo"); if (mSurfaceHolder == null) { Log.v(TAG, "SurfaceHolder is null"); return false; } mMediaRecorderRecording = true; if (mMediaRecorder == null) mMediaRecorder = new MediaRecorder(); else mMediaRecorder.reset(); if (mCamera != null) { if (Integer.parseInt(Build.VERSION.SDK) >= 8) VideoCameraNew2.reconnect(mCamera); mCamera.release(); mCamera = null; } if (useFront && Integer.parseInt(Build.VERSION.SDK) >= 5) { if (isAvailableSprintFFC) { try { Method method = Class.forName("android.hardware.HtcFrontFacingCamera").getDeclaredMethod("getCamera", null); mCamera = (Camera) method.invoke(null, null); } catch (Exception ex) { Log.d(TAG, ex.toString()); } } else { mCamera = Camera.open(); Camera.Parameters parameters = mCamera.getParameters(); parameters.set("camera-id", 2); mCamera.setParameters(parameters); } VideoCameraNew.unlock(mCamera); mMediaRecorder.setCamera(mCamera); mVideoPreview.setOnClickListener(this); } mVideoPreview.setOnLongClickListener(this); mMediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA); mMediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP); mMediaRecorder.setOutputFile(sender.getFileDescriptor()); mMediaRecorder.setVideoFrameRate(20); if (videoQualityHigh) { mMediaRecorder.setVideoSize(352,288); } else { mMediaRecorder.setVideoSize(176,144); } mMediaRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.H263); mMediaRecorder.setPreviewDisplay(mSurfaceHolder.getSurface()); try { mMediaRecorder.prepare(); mMediaRecorder.setOnErrorListener(this); mMediaRecorder.start(); } catch (IOException exception) { releaseMediaRecorder(); finish(); return false; } return true; }
private boolean initializeVideo() { Log.v(TAG, "initializeVideo"); if (mSurfaceHolder == null) { Log.v(TAG, "SurfaceHolder is null"); return false; } mMediaRecorderRecording = true; if (mMediaRecorder == null) mMediaRecorder = new MediaRecorder(); else mMediaRecorder.reset(); if (mCamera != null) { if (Integer.parseInt(Build.VERSION.SDK) >= 8) VideoCameraNew2.reconnect(mCamera); mCamera.release(); mCamera = null; } if (useFront && Integer.parseInt(Build.VERSION.SDK) >= 5) { if (isAvailableSprintFFC) { try { Method method = Class.forName("android.hardware.HtcFrontFacingCamera").getDeclaredMethod("getCamera", null); mCamera = (Camera) method.invoke(null, null); } catch (Exception ex) { Log.d(TAG, ex.toString()); } } else { mCamera = Camera.open(); Camera.Parameters parameters = mCamera.getParameters(); parameters.set("camera-id", 2); mCamera.setParameters(parameters); } VideoCameraNew.unlock(mCamera); mMediaRecorder.setCamera(mCamera); mVideoPreview.setOnClickListener(this); } mVideoPreview.setOnLongClickListener(this); mMediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA); mMediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP); mMediaRecorder.setOutputFile(sender.getFileDescriptor()); mMediaRecorder.setVideoFrameRate(20); if (videoQualityHigh) { mMediaRecorder.setVideoSize(352,288); } else { mMediaRecorder.setVideoSize(176,144); } mMediaRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.H263); mMediaRecorder.setPreviewDisplay(mSurfaceHolder.getSurface()); try { mMediaRecorder.prepare(); mMediaRecorder.setOnErrorListener(this); mMediaRecorder.start(); } catch (IOException exception) { releaseMediaRecorder(); finish(); return false; } return true; }
private void releaseMediaRecorder() { Log.v(TAG, "Releasing media recorder."); if (mMediaRecorder != null) { mMediaRecorder.reset(); if (mCamera != null) { if (Integer.parseInt(Build.VERSION.SDK) >= 8) VideoCameraNew2.reconnect(mCamera); mCamera.release(); mCamera = null; } mMediaRecorder.release(); mMediaRecorder = null; } } public void onError(MediaRecorder mr, int what, int extra) { if (what == MediaRecorder.MEDIA_RECORDER_ERROR_UNKNOWN) { finish(); } }
private void releaseMediaRecorder() { Log.v(TAG, "Releasing media recorder."); if (mMediaRecorder != null) { mMediaRecorder.reset(); if (mCamera != null) { if (Integer.parseInt(Build.VERSION.SDK) >= 8) VideoCameraNew2.reconnect(mCamera); mCamera.release(); mCamera = null; } mMediaRecorder.release(); mMediaRecorder = null; } } public void onError(MediaRecorder mr, int what, int extra) { if (what == MediaRecorder.MEDIA_RECORDER_ERROR_UNKNOWN) { finish(); } }
private void stopVideoRecording() { Log.v(TAG, "stopVideoRecording"); if (mMediaRecorderRecording || mMediaRecorder != null) { Receiver.listener_video = null; t.interrupt(); RtpStreamSender.delay = 0; if (mMediaRecorderRecording && mMediaRecorder != null) { try { mMediaRecorder.setOnErrorListener(null); mMediaRecorder.setOnInfoListener(null); mMediaRecorder.stop(); } catch (RuntimeException e) { Log.e(TAG, "stop fail: " + e.getMessage()); } mMediaRecorderRecording = false; } releaseMediaRecorder(); } }
以上是“java中如何初始化MediaRecorder”这篇文章的所有内容,感谢各位的阅读!相信大家都有了一定的了解,希望分享的内容对大家有所帮助,如果还想学习更多知识,欢迎关注创新互联行业资讯频道!