1

I'm trying to measure the default vibration duration on iPhone, iOS 6:

@property (nonatomic, retain) NSDate *startDate;

- (void) runTest
{                
    AudioServicesAddSystemSoundCompletion(kSystemSoundID_Vibrate, NULL, NULL, playSoundFinished, self);    
    self.startDate = [NSDate date];
    AudioServicesPlayAlertSound(kSystemSoundID_Vibrate); 
}

void playSoundFinished(SystemSoundID soundID, void *data)
{
    MyClassName *foo = (MyClassName*)data;
    double vibrationDurationMs = [foo.startDate timeIntervalSinceNow] * -1000.0;
}

But it returns just 1-2 milliseconds, regardless of whether vibration is activated in system settings or not.

I heard the default duration should be 400 ms, followed by 100 ms of silence.

Is the above code correct?

4

0 回答 0