How can I play the device-specific camera sound when taking a picture?

877 views Asked by At

Taking a picture on Android is quite trivial:

camera.takePicture(null, null, mPicture);

My only concern is that there is no sound or visual indication.

Creating a visual shutter animation on my layout sounds complicated, but I think I can handle it, but I would really like to play the original Android camera sound.

As this sound might be specific with different manufacturers I was just wondering if that's a sound that we could easily re-use in an app.

Thank for any help

Edit:

I have found this snippet, but believe there is a better way to achieve it:

        // Play the Shutter Sound
        AudioManager meng = (AudioManager) FullscreenActivity.this.getSystemService(
                Context.AUDIO_SERVICE);
        int volume = meng.getStreamVolume(AudioManager.STREAM_NOTIFICATION);


        if (volume != 0) {
            if (_shootMP == null)
                _shootMP = MediaPlayer
                        .create(FullscreenActivity.this,
                                Uri.parse("file:///system/media/audio/ui/camera_click.ogg"));
            if (_shootMP != null)
                _shootMP.start();
        }

Source: Alex Cohn

0

There are 0 answers