AVAudioPlayer on iPhone Simulator

AVAudioPlayerWith 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];

[audioPlayer setDelegate:self];

[audioPlayer prepareToPlay];

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!

Post Metadata

January 25th, 2009

Guvener Gokce

3 Trackbacks & Pingbacks

  1. April 30, 2014 3:25 pm

    More Information and facts :

  2. May 5, 2014 12:09 pm

    Nashville SEO :

  3. January 20, 2015 7:02 am

    luottoa :


  1. stationstops

    bless you sir.

    good god, how long would I have been a programmer without google?

  2. t

    Oh man. I’ve been wrestling with this for DAYS. Thank you kind sir.

  3. Rich

    This is great…I never would have figured that out. Thanks!

  4. Thanks for this example.This is simplest and exaplainful

    I have some other problem, and i think it is realted with AVAuidioPlayer class..

    I am workin on an application that allows users to play and record Audio/Video.
    But problem is that, functionality is working fine on simulator.. Its recording and playing too..

    But on iPhone, its not playing the file, even though file is getting recorded..

    Thanks in advance :)

  5. shiva


    I dont have any problem with AVAudioPlayer in simulator. But i am facing strange memory leak.

    In simulator :

    in Device

    Could any one give me some sample code..

    Thank you

  6. Hi Harinder,
    It is hard to find out real problem without checking the code but I think you should check the recording format. Because When targeting the Simulator, if you are using SpeakHere sample of Apple, SpeakHere uses linear PCM regardless of the format specified in the code. May be you should try other recording formats and see the results :)
    Other Recording formats:
    kAudioFormatLinearPCM, kAudioFormatAppleLossless, kAudioFormatAppleIMA4, kAudioFormatiLBC, kAudioFormatULaw,kAudioFormatALaw

    Hi Shiva,
    I have created a sample application for you,
    BTW you should also check Apple’s avTouch sample code.


  7. hi guvener,
    i downloaded apple’s avTouch.zip, but errors showing up when compiling in these lines:

    - (void)updateCurrentTime;
    - (void)updateViewForPlayerState; : error: expected `{’ before ‘-’ token
    - (void)updateViewForPlayerInfo; : error: expected `{’ before ‘-’ token

    - (void)setupAudioSession; : error: expected `{’ before ‘-’ token

    - (void)ffwd : error: expected `{’ before ‘-’ token
    - (void)rewind : error: expected `{’ before ‘-’ token

    - (void)awakeFromNib : error: expected `{’ before ‘-’ token

    and i did not chance anything inside the code!
    what is wrong there?


  8. Oh wow just what ya posted about really made me happier! (ok i know you’ll reckon im a retard haha!) You deserve to spend some time relaxing with some decent

  9. *Aw, this was a really nice post. In idea I would like to put in writing like this additionally – taking time and actual effort to make a very good article… but what can I say… I procrastinate alot and by no means seem to get something done.

  10. You completed certain nice points there. I did a search on the theme and found mainly people will consent with your blog.

  11. I will right away grab your rss as I can not find your e-mail subscription link or newsletter service. Do you’ve any? Kindly let me know in order that I could subscribe. Thanks.

  12. whoah this blog is wonderful i love reading your posts. Keep up the great work! You know, lots of people are looking around for this info, you can aid them greatly.

  13. That’s one of the most interesting websites I’ve read since I remember! You make it attractive and easy to understand - I love the way you do it. Keep on!

  14. Here is an example of an App that shows an mp3 list, you select one and it plays it. With progress bar, play, pause button.


  15. of course like your web site however you need to test
    the spelling on several of your posts. Several of them
    are rife with spelling issues and I in finding
    it very bothersome to tell the truth then again I will surely come back again.

  16. Wonderful goods from you, man. I’ve understand your stuff previous to
    and you’re just too magnificent. I actually
    like what you have acquired here, certainly like
    what you are stating and the way in which you say it. You make it enjoyable
    and you still take care of to keep it sensible.
    I cant wait to read far more from you. This is actually a wonderful site.

  17. Thanks for a marvelous posting! I seriously enjoyed reading it, you will be a great author.I will always bookmark your blog and will eventually come back sometime soon.
    I want to encourage one to continue your great writing, have a nice evening!

  18. Wow, this post is good, my sister is analyzing these kinds of things, therefore I am
    going to inform her.

    Visit my homepage … watch brick mansions

  19. I am regular visitor, how are you everybody? This article
    posted at this web site is really fastidious.

    my site belle full movie

  20. Right now it looks like BlogEngine is the best blogging platform
    out there right now. (from what I’ve read) Is that what you’re using on your blog?

    Here is my web-site download the amazing spider-man 2

  21. Класс)мне понра)особенно!

  22. I used to be able to find good advice from your blog posts.

  23. Your style is unique compared to other people I have read
    stuff from. Thank you for posting when you’ve got the opportunity, Guess
    I’ll just book mark this site.

    disney coloring pages mickey and minnie

  24. I believe everything typed was actually very reasonable.

    But, think on this, suppose you wrote a catchier title? I mean, I don’t want to tell you how to run your
    website, however suppose you added something to maybe get people’s attention? I mean AVAudioPlayer
    on iPhone Simulator | Guvener Gokce is kinda boring.
    You should peek at Yahoo’s home page and note how they create post
    headlines to get people to open the links. You might try
    adding a video or a picture or two to grab readers interested about what you’ve
    written. Just my opinion, it might bring your website a little bit more interesting.

  25. Just talk to the dealer about it as it definitely eliminates a lot of work on their end when you pay cash up front.
    This way, you will be reaching to more and more people, and increasing your chances for better money.

    That is why this is included as one of the best SUVs for tall drivers.

  26. It’s wonderful that you are getting thoughts from this
    piece of writing as well as from our discussion made at this place.

    Here is my web site: personal injury - Stephan,

  27. Hi there colleagues, its impressive post regarding teachingand
    fully explained, keep it up all the time.

Leave a Reply