OC语言读取wav文件

OC语言读取wav文件,第1张

用AudioServicesPlaySystemSound进行播轮逗放,代码如下:(wav文件名为end.wav)稿睁

SystemSoundID ph

id sndpath = [[NSBundle mainBundle]pathForResource:@"end" ofType:@"wav" inDirectory:@"/"腊敬卖]

CFURLRef baseUrl = (__bridge CFURLRef)[NSURL fileURLWithPath:sndpath]

AudioServicesCreateSystemSoundID(baseUrl, &ph)

AudioServicesPlaySystemSound(ph)

由于Xcode和MacBook pro经常自己更新,所以我的自己的APP不打算走本地代理了,准备写到本地json

1首先创建路径

//获取文件路径

NSString *filePath = [[NSBundle mainBundle] pathForResource:@"路径名称渣罩派"闷毁 ofType:@"json"]

2读取如贺data

//根据文件路径读取数据

NSData *data = [[NSData alloc] initWithContentsOfFile:filePath]

3data专程json

NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:nil]

options的几种类型

https://javenl.github.io/ios/2015/06/29/NSJSONSerialization.html


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/tougao/12291925.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-24
下一篇 2023-05-24

发表评论

登录后才能评论

评论列表(0条)

保存