I'm writing an application for iOS4. Is there any fast way to launch an mp3 file from code? I need to loop on an mp3 file as long as the app is running.
Thank you.
Use the AVAudioPlayer:
NSString *path = [[NSBundle mainBundle] pathForResource:@"sound" ofType:@"mp3"];
AVAudioPlayer *audioPlayer = [[AVAudioPlayer alloc ] initWithContentsOfURL:[NSURL fileURLWithPath:path] error:NULL];
audioPlayer.numberOfLoops = -1; // infinite loops
[audioPlayer play];
This does the job.