简体   繁体   English

iPhone播放声音并振动问题

[英]iPhone play sound and also vibrate problem

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? 我的问题是播放声音时如何振动?

For vibration, read the " System Sound Services Reference " documentation, especially the AudioServicesPlaySystemSound() method, with the constant kSystemSoundID_Vibrate. 对于振动,请使用常量kSystemSoundID_Vibrate阅读“ 系统声音服务参考 ”文档,尤其是AudioServicesPlaySystemSound()方法。

Don't forget to link your project to the AudioToolbox framework. 不要忘记将您的项目链接到AudioToolbox框架。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM