views:

27

answers:

1

Hello guys!

Here's my code to play sound:

NSString *filePath = [[NSBundle mainBundle] pathForResource:@"Feel" ofType:@"mp3"];
NSURL *fileURL = [[NSURL alloc] initFileURLWithPath:filePath];
AVAudioPlayer *_audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:fileURL error:nil];
[_audioPlayer prepareToPlay];
_audioPlayer.numberOfLoops = -1;
[fileURL release];
_audioPlayer.currentTime = 0;
[_audioPlayer play];

My problem is to how to vibrate while playing this sound?

+1  A: 

For vibration, read the "System Sound Services Reference" documentation, especially the AudioServicesPlaySystemSound() method, with the constant kSystemSoundID_Vibrate.

Don't forget to link your project to the AudioToolbox framework.

Guillaume
This vibrates only 2-3 seconds. Is there a way to play continuos?
Infinity
Maybe should I register a callback and invoke the function again?
Infinity
Careful with that. Continuous vibration is a potential cause of rejection. Cf. http://stackoverflow.com/questions/308479/reasons-for-rejecting-iphone-application-by-apple-store
Guillaume
Than you think there is no way to vibrate during a sound plays?
Infinity