I'm currently using AudioServicesPlaySystemSound(_soundID) to play sound clips. My understanding is that this can only be used to play clips under 30 seconds.
What is the standard way of playing longer sound clips?
AVAudioPlayer
Related
In my iPhone application I need to play custom sound while vibration.
I have found here: http://gregheo.com/blog/simple-audio/ that I should use AVAudioPlayer. But how can I play system sound of vibration using AVAudioPlayer? If there is another way to play custom sound and vibration together?
Update
I have found that I can use AVAudioPlayer to play custom sound and Audiosession to play vibro system sound. But maybe someone can advise me a better solution?
This SO post seems to deal with the exact opposite of your issue so it might give you the answer you are looking for:
How to play system sound on iOS without vibration?
I have to play 2 sounds in my app...one for background and one for when user clicks any button.....Not i have only one sound for background and too many sounds for that button click.....all sounds are in mp3 format....
I am using AVAudioPlayer to play these sounds...
My questions are
1- Can i play these 2 mp3 sounds at same time Or should i convert that background sound to any other format....
2- I am using AVAudioPlayer to play these sounds.....so can i use 2 instances of AVAudioPlayer in same class......
Please Note that i want that background music continuously playing.....
Please help....
1., Yes, you can even more..
2., Yes you can use AVAudioPlayer to play these, each sound source have to be allocated separately.
If you have short sounds that does not need to be stereo, you can use system sound framework to make them play.
Have a look to below look, will helpful for you.
2 mp3 sounds at the same time in iphone?
and blog tutorial
http://brainwashinc.wordpress.com/2009/08/14/iphone-playing-2-sounds-at-once/
I am playing sounds in loop in my app. So it should continue playing through out the app. but sometimes it stops after playing sound for 3/4 times.I don't understand whats happening.
I am using audio-toolbox framework for playing sound. creating audio queue and then playing sounds in loop. I am also playing sound from ipod library using mediaplayer. Same thing happening with song from ipod.
I have set [musicPlayer setRepeatMode: MPMusicRepeatModeOne]; but still it stops after 3/4 times.
How exactly are you playing the sound? Show us the code. Do you use System Sound Services? They are not meant to play longer sounds, quote Audio Toolbox Reference:
You can use System Sound Services to
play short (30 seconds or less)
sounds.
This could be the source of your problem. But until you show us the code we can’t but guess.
I am wondering if there is some way to fade in and out audio using AVAudioPlayer in CocoaTouch, with a pause command once the music finishes fading and then a play command once the fading begins. I have heard that one can use NSTimer for this purpose, but I am unsure of the easiest way to accomplish this.
Thanks for any help!
There is a good video tutorial to do this here: Playing a sound, and fading a sound using AVAudioPlayer on iPhone.
Duplicate:
use more then one sound in my iphone application using cocos2d
Hi,
All of the member of this forums.I need to help yours for doing my game project.I want to play some sound in my gaming project.When this game is started a background sound is playing continuously until the game is stop (exit). When game is played that time some action button are work and every action one sound is play for few second but background sound did not stop that time. How can i do this if anyone have a solution than reply with answer please.
If you are using cocos2d 0.82, then you can use denshion for this.
Play background music:
[[SimpleAudioEngine sharedEngine] playBackgroundMusic:#"somemusic.mp3"];
Play SOUND EFFECT:
[[SimpleAudioEngine sharedEngine] playEffect:#"mysound.wav"]
You can find this and more at http://www.cocos2d-iphone.org/wiki/doku.php/cocosdenshion:cookbook
You could, if you implemented your own mixer. Just playback a buffer and mix the audio yourself. It' basically boils down to just averaging two different amplitudes. In some cases it's a bit more advanced.
Check out the AVAudioPlayer class. It will do what you need.
One thing to be aware of is that this class will only play one mp3 format sound at one time. I suggest converting to IMA4 format if you are using mp3 and need to play multiple sounds at once.
You can use the afconvert command to convert between sound file formats.
AVAudioPlayer is available in firmware 2.2+.