react-native-vision-camera icon indicating copy to clipboard operation
react-native-vision-camera copied to clipboard

❓ shutter sound not playing on Android

Open albert-pjj opened this issue 3 years ago • 9 comments

Question

The camera shutter sound plays in ios, but the shutter sound does not play in Android.

What I tried

<Camera
        ref={camera}
        device={device}
        format={formats[0]}
        isActive={isActive}
       photo={true}
       orientation="portrait"
/>

const result = await camera.current?.takePhoto({
        enableAutoStabilization: true,
        skipMetadata: Platform.OS === 'android',
        qualityPrioritization: 'speed',
        flash: 'off',
});
buildToolsVersion = "31.0.0"
minSdkVersion = 23
compileSdkVersion = 31
targetSdkVersion = 31
ndkVersion = "21.4.7075529"

react-native: 0.68.0

VisionCamera Version

2.13.3

Additional information

albert-pjj avatar May 13 '22 06:05 albert-pjj

I don't think there is any default shutter sound effect on Android?

mrousavy avatar May 24 '22 09:05 mrousavy

@mrousavy You are correct in that sense. I think the issue comes from people who are moving over from RN Camera to RNVC, as IIRC RN Camera had a shutter sound implemented for Android.

A disclaimer in the documentation might be a good idea. Since people testing on both types of devices will probably get thrown off by it?

Or, I was considering making a PR that would add this feature since there is technically a default sound for this in the Android OS if you'd be open to that. https://developer.android.com/reference/android/media/MediaActionSound#SHUTTER_CLICK

kesteer avatar Jun 05 '22 12:06 kesteer

from their docs:

The sound used by Camera.takePicture to indicate still image capture.

Why doesn't it play then? I think this would be a cool option for VisionCamera. It's configurable both on iOS and Android

mrousavy avatar Jun 05 '22 13:06 mrousavy

Why doesn't it play then? I think this would be a cool option for VisionCamera. It's configurable both on iOS and Android

True, I would assume it'd play anyways. A bit more annecdotal evidence, but in my recent implementation of VisionCamera on Android it also was not playing on my phone when taking a picture.

Looking back at the old code for RN Camera, it seems they manually called the sound directly instead of using it from Camera.takePicture. I wonder if something else is happening here?

https://github.com/react-native-camera/react-native-camera/pull/1441/files

kesteer avatar Jun 05 '22 13:06 kesteer

any update? i need to reproduce shutter sound

wilav-dev avatar Jul 26 '22 17:07 wilav-dev

+1, we just switched from RNC to RCVC, the missing shutter sound makes our client unhappy. 😭

uniquejava avatar Aug 18 '22 06:08 uniquejava

+1, please add shutter sound

bdobreav avatar Aug 18 '22 08:08 bdobreav

Stop spamming +1. If you want me to work on VisionCamera to make your client happy, pay me to do so.

mrousavy avatar Aug 18 '22 09:08 mrousavy

@mrousavy Based on the code from RN Camera shared by @kesteer and the fact that android docs also point to MediaActionSound, seems like shutter sound should be called manually. I will try to take a look at this next weekend, and open a PR with the fix (possibly based on RN Camera solution).

Keep up the good work, this library is awesome!

robsonbbs avatar Aug 31 '22 19:08 robsonbbs

On android some devices, flash and shutter is not working.

2sem avatar May 19 '23 05:05 2sem

Hey! I just implemented this in V3! :) https://github.com/mrousavy/react-native-vision-camera/pull/1702

mrousavy avatar Aug 21 '23 13:08 mrousavy