Hey guys,
I'm experiencing an odd problem with AVAudioPlayer class. Everytime I try to access one of it's properties they are null.
// Get the file path to the song to play.
NSString *filePath = [[[NSBundle mainBundle] pathForResource:pSound.fileName
ofType:pSound.fileType] retain];
// Convert the file path to a URL.
NSURL *fileURL = [[NSURL alloc] initFileURLWithPath:filePath];
NSError* err;
//Initialize the AVAudioPlayer
self.audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:fileURL error:&err];
if( err ){
NSLog(@"Initializing failed with reason: %@", [err localizedDescription]);
}
else{
[self.audioPlayer setDelegate:self];
[self.audioPlayer prepareToPlay];
self.playCount = self.playCount + 1;
NSLog(@"%@", [self.audioPlayer isPlaying]); //this displays null; also if I call it at a later time
};
[filePath release];
[fileURL release];
Any Ideas?
EDIT: Oddly enough when I save isPlaying to a bool and print the bool I get a value...