ios开发技术——播放系统wav格式的音乐

来源:互联网 发布:抓包8888端口干嘛的 编辑:程序博客网 时间:2024/05/16 04:43


需要导入的框架: AudioToolbox.framework


-(void)startWinPlayer

{

    //定义URl,要播放的音乐文件是win.wav

    NSURL *audioPath = [[NSURLalloc]initFileURLWithPath:[[NSBundlemainBundle]pathForResource:@"win"ofType:@"wav"]];

    //定义SystemSoundID

   SystemSoundID soundId;

    //C语言的方法调用

    //注册服务

    AudioServicesCreateSystemSoundID((__bridgeCFURLRef)audioPath, &soundId);

    //增添回调方法

    AudioServicesAddSystemSoundCompletion(soundId,NULL,NULL, PlayFinishCallBack,NULL);

    //开始播放

    AudioServicesPlayAlertSound(soundId);

}


原创粉丝点击