0
votes

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.

But 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 ?

1

1 Answers

1
votes

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