How to use AVAudioPlayer to play a playlist in iPhone/iPad - iphone

Please I know how to play a sound in AVAudioPlayer but I would like to know how to give it a list of on-disk files to play one after the other (play list)
Anyone has any idea?

You have to manage this by yourself, using the 'audioPlayerDidFinishPlaying' method to know when the current song is over, and when to start a new one.

The Apple "AddMusic" sample program does exactly this, setting up a playlist of audio files using MPMusicPlayerController and AVAudioPlayer to do most of the work.

Related

AVAudioPlayer or MPMusicPlayerController for playing simentanously & in background

I have the following needs to audio: it needs to be able to play at least 2 local audio files and it need to support playing in the background, so the user can close the app and multitask while the audio still plays. What of the 2 options are the best bet?
AVAudioPlayer is your best bet. As mentioned in the comment "AFAIK MPMusicPlayerController is used for local files inside the iPod Library."
Having said that, can you please give more details about your problem?

Playing a movie file and then various audio files while movie is playing back. (iOS)

Is it possible to play some audio files while my movie is playing. I don't want it to interrupt or pause he movie. Just the audio to play at same time at various predetermined points.
Many Thanks,
-Code
You shouldn't have any problems with it.
If you want to synchronize or delay these players you should use
the code they provide in AvAudioPlayer Class Reference using
playAtTime: method.
Sadly MPMediaPlayback protocol doesn't provide the same method
so exact synchronizing with video is a bit harder task.
EDIT: RoLYroLLs mentions using MPMoviePlayerLoadStateDidChangeNotification to achieve this here and this approach seems promising.
Use two or three Audioplayer at same time . Play that audio when u need it

Combine two audio files together and play them in iPhone

I do not want any code but want to get a reference about my question mentioned below...
There is background music available and there is recording option in my app...
Once I start recording , application records my sound and when play button clicks , It will play the recording along with the background music...
I had use this Link but can not get as I want...
I think there is a mechanism like merging two audio files and make it one before playing....
How can I achieve this by coding... Is there any reference link or any sample code available?
Thnx in advance...
Most people mistake the one instance of AVAudioPlayer as the unit that plays the sound directly, but it doesnt. Mixing is done by the OS, not by the instance of AVAudioPlayer.
With other words:
No one says you can't have more then one AVAudioPlayer.
Create one for you background and let it play. Create another instance of AVAudioPlayer for you recorded sound and let it play. Voila

Playing An Audio File Through An App

Is there anyway to store audio on an iphone app and then grab that audio file and play it through code. Does anyone have a tutorial to point me to do something like this?
Check the AVAudioPlayer class here http://developer.apple.com/iphone/library/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/AudioandVideoTechnologies/AudioandVideoTechnologies.html#//apple_ref/doc/uid/TP40007072-CH19-SW1
Should tell you what you need to know.

How to use AVAudioPlayer to play MP4?

I want to use AVAudioPlayer to play MP4 files from iTunes generator. I could use UIWebView to play it and it worked, but I want to put an image of my choice on the background of the player instead of the "QuickTime"-logo.
Here is an example of the m4p file I want to play with AVAudioPlayer.
If your question is, "can someone help me figure out how to use AVAudioPlayer," then I'd recommend taking a look at Apple's avTouch sample app, the documentation for AVAudioPlayer, and the guide Getting Started with Audio & Video.
When it happened to me I had a missing '/' on the end of my url. Adding that cleared me right up.