[英]Problem while playing sound using AVAudioPlayer?
在我的应用程序中,我正在播放库目录中的声音。
此处,声音以不同的命名约定存储在不同的文件夹中。
例如,
文件夹,如: Test
, Test 2
现在,当我尝试播放Test
中的声音时,它会播放声音。
但是,当我尝试播放Test 2
声音时,它没有播放任何声音。
我正在使用以下代码播放声音:
recordFile:“ / Users / taxsmart2 / Library / Application Support / iPhone Simulator / 4.3 / Applications / E2F2C422-605A-4EC7-A40A-7429A966351C / Library / List13-Test / rec212:13:21.caf” //播放声音
recordFile:“ / Users / taxsmart2 / Library / Application Support / iPhone Simulator / 4.3 / Applications / E2F2C422-605A-4EC7-A40A-7429A966351C / Library /
List13-Test 2
/rec212:13:21.caf” //不播放声音
// May be because of space `Test 2`
AVAudioPlayer *player = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL URLWithString:recordFile] error:nil];
[player prepareToPlay];
然后在按钮上单击我具有以下代码:
[player play];
我该如何解决这个问题?
使用[NSURL fileURLWithPath:recordFile]
代替URLWithString:
[NSURL fileURLWithPath:recordFile]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.