iPhone播放声音也振动问题

时间:2010-07-08 09:54:57

标签: objective-c iphone

这是播放声音的代码:

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];

我的问题是如何在播放这种声音时振动?

1 个答案:

答案 0 :(得分:1)

对于振动,请阅读“System Sound Services Reference”文档,尤其是AudioServicesPlaySystemSound()方法,并使用常量kSystemSoundID_Vibrate。

不要忘记将您的项目链接到AudioToolbox框架。