How to change the shutter sound in iOS.

MLBoy
1 min readOct 3, 2020

Instead of AVFoundation’s shutter sound, you can play any sound you like.

procedure

  1. Initialize the audio player with the audio you want to play.
// path to your mp3 file.
guard let path = Bundle.main.path(forResource: "customSound", ofType: "mp3") else { print("Could not find sound file.") ; return }

// initialize the player.
do {
try audioPlayer = AVAudioPlayer(contentsOf: URL(fileURLWithPath: path))
} catch {
print("playerError")
}

2. Play the audio player in the delegate method called just before capturing the photo.

func photoOutput(_ output: AVCapturePhotoOutput, willCapturePhotoFor resolvedSettings: AVCaptureResolvedPhotoSettings) {
AudioServicesDisposeSystemSoundID(1108) // If you implement only this line, it will be silent shutter.
audioPlayer?.play()
}

(Even with custom voice, I passed the App Store review with my own app. When taking a photo, you need to tell the user that “the app captured photo” in some way. If you do not keep that in mind when you publish your app in App Store, your app may be rejected.)

🐣

Request for work: rockyshikoku@gmail.com

--

--