AVAudioPlayer on iPhone Simulator
With iPhone 2.2, AVAudioPlayer Class is introduced.
AVAudioPlayer simplifies making an object from a file, start/stop/pause media, volume control and looping.
You can find documentation of this class via Apple iPhone Developer site, here we will discuss an issue you’ll probably face while trying to use this class on simulator.
If you are facing problem, playing your media with AVAudioPlayer on Simulator.
Check your /Library/Quicktime directory.
Browse files in this directory and find third party add-ons like Perian, DivX etc.
Move these add-ons in to another folder while you are developing with AVAudioPlayer
Now Test your Application, AVAudioPlayer should run without any problem.
Don’t forget to move your add-ons back to Quicktime Directory after you finished development ;)
Here is a quick AVAudioPlayer usage example,
NSString *newAudioFile = [[NSBundle mainBundle] pathForResource:@”MusicFile” ofType:@”mp3″];
audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:newAudioFile] error:NULL];
BOOL plays = [audioPlayer play];
Thanks to Mert Yentur, for discovering and sharing that issue.
If you enjoyed this post, make sure you subscribe to my RSS feed!