j'initialiser une instance de AVAudioPlayer:AVAudioPlayer ne répond pas
NSString* path = [[NSBundle mainBundle] pathForResource:@"foo" ofType:@"wav"];
AVAudioPlayer* player =[[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:path] error:nil]; //Returned object not nil, indicating that the file has loaded successfully
BOOL b = [player prepareToPlay]; //returns TRUE
BOOL b2 = [player play];
//returns TRUE, goes immediately to the next line since asynchronous
[NSThread sleepUntilDate:[NSDate dateWithTimeIntervalSinceNow:1]; //wait 1 sec
printf("%10.4f\n",player.duration); //duration is 2s
printf("%10.4f\n",player.currentTime); //position remains 0
/* There is no sound output, player is also stuck since position==0 */
Est-ce que quelqu'un sait pourquoi le AVAudioPlayer ne répond pas? Y a-t-il quelque chose que je néglige pendant l'initialisation, en jouant l'audioplayer? Code de Boilerplate peut-être? Je cours ceci sur le simulateur d'iPhone. En outre, AudioServicesPlaySystemSound() fonctionne pour le même fichier, ce qui est déroutant, mais cela indique que la lecture audio peut également fonctionner avec AVAudioPlayer.