Je rencontre un problème étrange avec la classe AVAudioPlayer. Chaque fois que j'essaie d'accéder à l'une de ses propriétés, elles sont nulles.AVAudioPlayer isPlaying retourne toujours une valeur nulle
// 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];
Une idée?
EDIT: Bizarrement quand j'économiser isPlaying à un bool et imprimer le bool je reçois une valeur ...
Avez-vous réussi jamais à résoudre ce problème? J'ai le même problème et je n'arrive pas à le comprendre. – Neeku