开发者

Problem while playing sound using AVAudioPlayer?

In my app, I am playing sound from library directory.

Here sounds are stored in different folders with different naming conventions.

For example,

Folders like : Test , Test 2

Now when I try to play sound from Test, it plays sound.

B开发者_StackOverflow社区ut when I try to play sound from Test 2, It is not playing any sound.

I am using following code for playing sound :

recordFile : "/Users/taxsmart2/Library/Application Support/iPhone Simulator/4.3/Applications/E2F2C422-605A-4EC7-A40A-7429A966351C/Library/List13-Test/rec212:13:21.caf" // Play sound

recordFile : "/Users/taxsmart2/Library/Application Support/iPhone Simulator/4.3/Applications/E2F2C422-605A-4EC7-A40A-7429A966351C/Library/List13-Test 2/rec212:13:21.caf" // Does not Playing sound

// May be because of space `Test 2`

AVAudioPlayer *player = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL URLWithString:recordFile] error:nil];

[player prepareToPlay];

And on the button click I am having following code :

[player play];

How can I solve this issue ?


Use [NSURL fileURLWithPath:recordFile] instead of URLWithString:.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜