首页 > 代码库 > Android -- Camera.ShutterCallback
Android -- Camera.ShutterCallback
干货
相机拍照的回调
/** * Equivalent to takePicture(shutter, raw, null, jpeg). * * @see #takePicture(ShutterCallback, PictureCallback, PictureCallback, PictureCallback) */ public final void takePicture(ShutterCallback shutter, PictureCallback raw, PictureCallback jpeg) { takePicture(shutter, raw, null, jpeg); }
那么,让拍照的时候有“咔嚓”的声音,就需要去处理这个ShutterCallback
Camera.ShutterCallback shutterCallback = new Camera.ShutterCallback() { @Override public void onShutter() { try { AudioManager meng = (AudioManager) TakePhotoActivity.this.getSystemService(Context.AUDIO_SERVICE); int volume = meng.getStreamVolume(AudioManager.STREAM_NOTIFICATION); if (volume != 0) { if (mShootSound == null) { mShootSound = MediaPlayer.create(TakePhotoActivity.this, Uri.parse("file:///system/media/audio/ui/camera_click.ogg")); } if (mShootSound != null) { mShootSound.start(); } } } catch (Exception e) { e.getStackTrace(); } } };
我是天王盖地虎的分割线
Android -- Camera.ShutterCallback
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。