1.音频两个:音乐和音效(基于C语言的框架)
2.播放音效的步骤:
3.
1)引入框架 <AudioToolbox/AudioToolbox.h>
2)加载路径 NSString *str = [[NSBundle mainBundle]pathForResource:@"duanxin1.caf" ofType:nil]
3)类型转换 NSURL *url = [NSURL fileURLWithPath:str]
4)初始值 SystemSoundID sid = 0
5)创建 AudioServicesCreateSystemSoundID((__bridge CFURLRef _Nonnull)(url), &sid)
6)播放 AudioServicesPlayAlertSound(sid)
4.音乐播放
1)引入框架 <AVFoundation/AVFoundation.h>
2)获取路径 NSString *music = [[NSBundle mainBundle] pathForResource:[NSString stringWithFormat:@""] ofType:nil]
3)类型转换 NSURL *url = [NSURL fileURLWithPath:music]
4)循环次数 _player.numberOfLoops = -1
5)设置音量 _player.volume = 1
6)把音乐加入缓冲区 [_player prepareToPlay]
7)添加一个Button,实例化,背景色,名字,添加方法
8)Button方法,播放音乐[_player play]
5.音乐列表
1)停止音乐 [_player stop]
回到起始点 _player.currentTime = 0
2)暂停音乐 [_player pause]