The only possible work-around I can think of would be to mute the iphone sound when they press the "take picture" button, and then un-mute it a second later.
Method 1: Not sure if this will work, but try playing a blank audio file right before you send the capture event.
To play a clip, add the Audio Toolbox framework, #include <AudioToolbox/AudioToolbox.h>
and play the audio file like this immediately before you take the picture:
Method 2: There's also an alternative if this doesn't work. As long as you don't need to have a good resolution, you can grab a frame from the video stream, thus avoiding the picture sound altogether.
A common trick in such cases is to find out if the framework invokes a certain method for this event, and then to overwrite that method temporarily, thereby voiding its effect.
I'm sorry but I am not a good enough hack to tell you right away if that works in this case. You could try the "nm" command on the framework executables to see if there's a named function that has a suitatable name, or use gdb with the Simulator to trace where it goes.
Once you know what to overwrite, there are those low level ObjC dispatching functions that you can use to redirect the lookup for functions, I believe. I think I've done that once a while ago, but can't remember the details.
Hopefully, you can use my hints to google a few solutions paths to this. Good luck.
I live in in Japan, so I can not mute the audio when we take photos for security reason. In video, however audio turns off. I don't understand why.
The only way I take a photo without shutter sound is using AVCaptureVideoDataOutput or AVCaptureMovieFileOutput. For analyze still image AVCaptureVideoDataOutput is only way. In AVFoundatation sample code,
AVCaptureVideoDataOutput *output = [[[AVCaptureVideoDataOutput alloc] init] autorelease];
// If you wish to cap the frame rate to a known value, such as 15 fps, set
// minFrameDuration.
output.minFrameDuration = CMTimeMake(1, 15);
In my 3GS it is very heavy when I set CMTimeMake(1, 1); // One frame per second.
In WWDC 2010 Sample code, FindMyiCone, I found following code,
[output setAlwaysDiscardsLateVideoFrames:YES];
When this API is used, the timing is not granted, but API is called sequentially. I this it is best solutions.
Then I used third-party app to extract photoShutter.caf from Documents directory (DiskAid for Mac). Next step I opened photoShutter.caf in Audacity audio editor and applied inversion effect, it looks like this on high zoom:
Then I saved this sound as photoShutter2.caf and tried to play this sound right before captureStillImageAsynchronouslyFromConnection:
I was able to get this to work by using this code in the snapStillImage function and it works perfectly for me on iOS 8.3 iPhone 5. I have also confirmed that Apple won't reject your app if you use this (they didn't reject mine)
MPVolumeView* volumeView = [[MPVolumeView alloc] init];
//find the volumeSlider
UISlider* volumeViewSlider = nil;
for (UIView *view in [volumeView subviews]){
if ([view.class.description isEqualToString:@"MPVolumeSlider"]){
volumeViewSlider = (UISlider*)view;
break;
}
}
// mute it here:
[volumeViewSlider setValue:0.0f animated:YES];
[volumeViewSlider sendActionsForControlEvents:UIControlEventTouchUpInside];
Just remember to be nice and unmute it when your app returns!
AVCapturePhotoCaptureDelegate methods will be invoked.
And the system tries to play shutter sound after willCapturePhotoFor invoked.
So you can dispose of system sound in willCapturePhotoFor method.