ios 播放声音和震动

 使用AudioServicesPlaySystemSound 这个接口来进行声音和震动的播放, 当然需要在工程中加入AudioToolBox.framework


1. 播放震动

     

AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);



2. 播放特定的声音

static SystemSoundID soundIDTest = 0;

NSString * path = [[NSBundle mainBundle] pathForResource:@"test" ofType:@"wav"];

if (path) {

      AudioServicesCreateSystemSoundID( (CFURLRef)[NSURL fileURLWithPath:path], &soundIDTest );

}

    AudioServicesPlaySystemSound( soundIDTest );


你可能感兴趣的:(ios,Path)