У меня возникла странная проблема с классом AVAudioPlayer. Каждый раз, когда я пытаюсь получить доступ к одному из его свойств, они равны нулю.AVAudioPlayer isPlaying always return 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];
Любые идеи?
EDIT: Как ни странно, когда я сохранить isPlaying к BOOL и напечатать BOOL я получаю значение ...
ли вы когда-нибудь удалось решить эту проблему? У меня такая же проблема и я не могу понять. – Neeku