全能型:AVFoundation
编解码:AudiotoolBox
底层:AudioUnit
3D: openAL
控制类VC:mediaPlayer
Audio systemsound
播放震动效果
播放系统音乐效果
播放提示音效果
震动效果:
NSString *device = [UIDevice currentDevice]model];
if (device isEqualToString:@”iPhone”){
AudioServicesPlaySystemSound(kSystemSoundID_vibrate);
}else{
提示
}
提示音:
//播放系统声音
- (void)playSystemSound{
NSString *filePath = [[NSBundle mainBundle] pathForResource:@”music” ofType:@”car”];
if (!filePath) {
return;
}
NSURL *url = [NSURL fileURLWithPath:filePath];
//
SystemSoundID system_id;
//绑定ID 和 URL
AudioServicesCreateSystemSoundID((__bridge CFURLRef) url, &system_id);
//注册回调
AudioServicesAddSystemSoundCompletion(system_id, NULL, NULL, AudioServicesSystemSoundFinish, NULL);
//播放
AudioServicesPlaySystemSound(system_id);
}
@end
void
AudioServicesSystemSoundFinish( SystemSoundID ssID,
void* __nullable clientData){
AudioServicesRemoveSystemSoundCompletion(ssID);
AudioServicesDisposeSystemSoundID(ssID);//手机静音的时候无效
}
播放提示音
NSString *filePath = [[NSBundle mainBundle] pathForResource:@”music” ofType:@”car”];
if (!filePath) {
return;
}
NSURL *url = [NSURL fileURLWithPath:filePath];
//
SystemSoundID system_id;
//绑定ID 和 URL
AudioServicesCreateSystemSoundID((__bridge CFURLRef) url, &system_id);
//注册回调
AudioServicesAddSystemSoundCompletion(system_id, NULL, NULL, AudioServicesSystemSoundFinish, NULL);
//播放
AudioServicesPlaySystemSound(system_id);
AudioServicesPlayAlertSound(system_id);//手机静音 播放声音 并震动