现在的位置: 首页 > 综合 > 正文

播放系统声音

2019年05月16日 ⁄ 综合 ⁄ 共 370字 ⁄ 字号 评论关闭

播放系统声音需要导入

#import <AudioToolbox/AudioToolbox.h>

        //———————————————————播放提示声音———————————————————————
        NSString *filePath = [[NSBundle mainBundle] pathForResource:@"msgcome" ofType:@"wav"];
        NSURL *url = [NSURL fileURLWithPath:filePath];
        
        //1.将声音文件注册成系统声音
        SystemSoundID soundID;
        AudioServicesCreateSystemSoundID((__bridge CFURLRef)(url), &soundID);
        //2.播放系统声音
        AudioServicesPlaySystemSound(soundID);

【上篇】
【下篇】

抱歉!评论已关闭.