ios播放声音和震动

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

// 播放声音
    static SystemSoundID soundID = 0;
    NSString * path = [[NSBundle mainBundle] pathForResource:@"glass" ofType:@"wav"];
    if (path) {
        AudioServicesCreateSystemSoundID((__bridge CFURLRef)[NSURL fileURLWithPath:path], &soundID );
    }
    AudioServicesPlaySystemSound (soundID);
    
// 播放震动
    AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);

猜你喜欢

转载自quding0308.iteye.com/blog/1940090
今日推荐