In the documentation of AudioServicesPlayAlertSound, it says I can disable vibration when playing a sound:
iPhone—plays the specified sound. If the user has configured the
Settings application for vibration on ring, also invokes vibration.
However, the device does not vibrate if your app’s audio session is
configured with the AVAudioSessionCategoryPlayAndRecord or
AVAudioSessionCategoryRecord audio session category.
However, I still feel vibration on my iPhone 4S (iOS 5.1.1) even after setting my category to "play and record". It rings and vibrates at the same time.
#import <AudioToolbox/AudioServices.h>
#import <AVFoundation/AVAudioSession.h>
NSError* error;
[[AVAudioSession sharedInstance]
setCategory:AVAudioSessionCategoryPlayAndRecord
error:&error];
if (error == nil) {
AudioServicesPlayAlertSound(1000);
}
I've also tried AudioServicesPlaySystemSound
, but the results are the same. The reason why I want to disable vibration is because I am making an app where the user must place her phone far away and the phone should not topple over due to vibration.
Best Answer
I tested this with my iPhone 4s and it does exactly what you want.
Use
AudioServicesCreateSystemSoundID
to create aSystemSoundID
using the filename of the system sound. Then useAudioServicesPlaySystemSound()
to play the sound with no vibration. Filenames of the other system sounds can be found at the link below.http://iphonedevwiki.net/index.php/AudioServices