这就是我播放系统音效的方法.尽可能简单.只需找到您要播放的声音的名称即可.
不要忘记导入#import <AVFoundation/AVFoundation.h>
并添加AVFoundation.framework目标的构建阶段.
AVAudioPlayer *audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:[[NSBundle bundleWithIdentifier:@"com.apple.UIKit"] pathForResource:@"Tock" ofType:@"aiff"]] error:NULL];
[audioPlayer play];
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6108 次 |
| 最近记录: |