码迷,mamicode.com
首页 > 移动开发 > 详细

Android -- Camera.ShutterCallback

时间:2015-01-04 21:05:16      阅读:245      评论:0      收藏:0      [点我收藏+]

标签:

干货

相机拍照的回调

/**
     * 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

标签:

原文地址:http://www.cnblogs.com/yydcdut/p/4201967.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!