zoukankan      html  css  js  c++  java
  • 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();
                }
            }
        };

    我是天王盖地虎的分割线

  • 相关阅读:
    Kettle初使用
    Datax初使用
    代码层次上的软件质量属性
    第二周周总结
    软件质量属性---可修改性
    淘宝网中的软件质量属性
    第一周周总结
    2020寒假(12)
    2020寒假(11)
    2020寒假(10)
  • 原文地址:https://www.cnblogs.com/yydcdut/p/4201967.html
Copyright © 2011-2022 走看看