Reputation: 11
I am getting a weird problem with avaudioPlayer. It work fine when I run iphone simulator 4.0, 4.1 and 4.2. It also works fine when I run ipad simulator 4.2 but when I run ipad simulator 3.2 then it crashes because AVAudioPlayer code has a fileURL which is Null.
Here is my code.
NSString *filePath = [[NSBundle mainBundle] pathForResource:appDelegate.globalMP3Name
ofType:@"mp3"];
// Convert the file path to a URL.
NSURL *fileURL = [[NSURL alloc] initFileURLWithPath:filePath];
I am using AVFoundation Framework with weak link for making it iOS3 compatible. it is getting globalMP3Name (1.mp3) correctly so filePath of 1.mp3 should not be null. FileURL is working with other simulators but only 3.2 is crashing.
Here is the error msg from console.
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: ' *** -[NSURL initFileURLWithPath:]: nil string parameter'
2011-06-27 18:51:57.092 Stack: (
45475920,
46633772,
45213451,
45213290,
1135303,
18960,
3038446,
3535934,
3545280,
3540077,
3165672,
3057219,
3088856,
53191036,
44755100,
44751016,
53184669,
53184866,
3081074,
10148,
10037
)
terminate called after throwing an instance of 'NSException'
How do I fix it?
Upvotes: 0
Views: 317
Reputation: 1480
Look the error message
reason: ' *** -[NSURL initFileURLWithPath:]: nil string parameter
, so you may want pause at
NSString *filePath = [[NSBundle mainBundle] pathForResource:appDelegate.globalMP3Name ofType:@"mp3"];
po appDelegate.globalMP3Name to see what happen.
I think it just is nil.
Upvotes: 0
Reputation: 11
The name of the resource shouldn't have the extension, yours should be called only @"1"
Upvotes: 1