views:

288

answers:

1

From http://stackoverflow.com/questions/2111866/iphone-can-i-do-audioservicesplaysystemsound-looping-with-scheduler

MPMusicPlayerController doesn't work because it is about iPod music library and I can't add a music file to it since I'm doing an iPhone game and not interacting with the outside iPod library.

Does AVAudioPlayer works in iPhoneSimulator?

+1  A: 

Hi,

Check out following code its a simple AVAudioPlayer example and its work on iPhone simulator too ..

AVAudioPlayer *audioPlayer;

NSURL *url = [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/azan1.mp3", [[NSBundle mainBundle] resourcePath]]];

NSError *error;
audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:&error];
audioPlayer.numberOfLoops = -1;

[audioPlayer play];
Mohammad Asif