play sound while sliding finger on iphone - iphone

i like to add the function playing sounds when either sliding fingers on the surface to my iphone app. the sounds are playing now only when pushing buttons.
i suppose this works with TouchesMoved, but i don't know how to implement the "AVAudioPlayer" code to the touches event code.
please any code sample, thanks!

As far as I'm aware, TouchesMoved is used to trigger events on the screen (when 'moved over') which in turn can trigger sound events. I don't beleive there is a way you can produce a sound when the user is just 'sliding' around the screen and not interacting with any objects.
This is something I've looked into myself but didn't come up with a solution, but I'll hopefully be corrected in this thread if wrong!

You can instantiate an AVAudioPlayer inside of the touchesMoved:withEvent: method and play a sound. You need to keep a strong reference to each AVAudioPlayer you create or else you will not hear a thing.
To keep track of multiple AVAudioPlayers store them in an array, and remove them from the array when they are finished playing (which you can find out using the audioPlayerDidFinishPlaying:successfully: delegate method).
Keep in mind that touchesMoved:withEvent: may be triggered in a super high tempo, so your array may grow too large. It's wise to only play a sound when something acutally happens on the screen, such as the next piano key being touched, or to keep a counter and only play a sound every n touches.

Related

iPhone UIControlEvent when touches have ended

I have a volume slider in my application that I'd like to have a sound effect play when the user changes the value. The standard valueChanged event works well here, and I'd like to use it in conjunction with a touches ended signal to trigger the sound at the end. Is there a control event here that I'm missing that would run my method when the touches finish? It doesn't seem like there is a UIControlEventTouchesEnded...
Some code samples would help, but I guess you're looking for UIControlEventTouchUpInside. I'm not sure, if it works with a slider.
One possibility would be to set the slider's continuous to NO. Now it emits just one valueChanged event, namely when the user is all finished - just what you want to know.

seamless dynamic audio loop on iPhone

Ok,
So I am trying to seamlessly loop together three sound files with the second file being looped against itself n times. Let's assume I can get them to loop seemlessly together in another program by butting them together. however when I use audioPlayerDidFinishPlaying delegate method of avaudioplayer there is a slight delay in the butting together (even with using the "prepareToPlay" method. The other bit of complexity is that the middle sound needs to continue looping n times AKA as long as the touchesDidEnd method has not been called, at which point the program would play the 3rd and final clip to end the sound "playlist."
As an example think an audience giving applause after a show. sound file A would contain the initial swell of applause, sound file 2 would contain a loopable sample of the crowd cheering at a continuous rate until the user lifts up on the button, at which time the program should kick into the 3rd sound file, which would be the applause of the crowd tailing off.
So my initial attempt using AVAudioPlayer seemed not quick enough to loop back to back without delay so I need another quicker way to do this, suggestions?
For the looping, check out the numberOfLoops property of AVAudioPlayer. Works better than trying to handle the loop logic yourself using the player's delegate.
As for fading smoothly from one looping sample to a 'tail' sample, that's going to be difficult to pull off with AVAudioPlayer. Probably your best bet is to start another player with the trailing sound file and use a timer to rapidly cross fade between the two using the volume property of each.
If that's not satisfactory (and I suspect it may not be) I don't think you'll have much choice but to drop down to the AudioQueue API to pull this off.

Making fire effect on iPhone

I'll describe ways that I already know, and can do, and want to hear another suggestions, or may be even solutions :)
Create N frames of fire with semi-transparent pictures (PNGs)
Like at this site
Create pixel-based fire - line by line with shifting up. (not the best way I think)
Like here
Any other solutions?
Mr.doob's fire effect in flash is very clever.
Particles Fire Prototype by Nicolas Goles
Chapter 7 of iPhone Games Projects begins with a discussion of fire effects.
A movie with the fire animation playing, or maybe an animated .gif image.

UISlider with sound effect and vibration

I need to do a lot of things with UISlider. First of all I want to know what are all the things are possible and what are not. Please give me ideas for the doable ones.
I need to add a slider control in my iPhone application (that should resemble the one which is displayed in the iphone when the phone is getting charged).
Can the round button of the UISlider be changed to any other shape. Can any image be added on top of that round button?
When the UISlider is being moved, we need ad a sound effect(for example car stating sound) and when the sliding ends the sound should be stopped. is this possible? if yes, please gimme ideas to do this. 3. vibration should also happen while sliding (possible?)
Thanks in advance!!!
All of these can be done via the public API. Read the docs :-)
The button is called the "thumb image"; there's a property to replace the image.
Assign a delegate and set the 'continuous' property on the slider.
See the Application Programming Guide for more on delegates.
As far as question number 2, just write up the methods to accomplish playing a sound and vibrating and then have them fire when the value changes on the slider.

Playing quicktime files with pause points via Keynote (forward and backward)

I have a quicktime file (.mov) generated by Keynote. When played in quicktime, it pauses itself at dozens of pre-defined points waiting for user input. It is basically a slide show with transitions pre-rendered to video.
I want to wrap this in an iPhone app, but see no methods on an MPMoviePlayerController to do anything other than play, which does not pause at the pause points.
Also, I want to be able to play backwards to a prior stop point if the user taps elsewhere on the phone.
Is there a better library for this than MPMoviePlayerController or (deprecated?) UIMoviePlayerController? Or am I overlooking methods that would allow this?
If you think about what you're trying to do, this is actually a fairly complex task. What you're really asking for is the ability to hook up an arbitrary movie playing UI tied to unique gestures, based on the specifics of your movie. I don't think either of the classes in question is going to get you there.
The easiest solution here might be content-based: generate one quicktime movie per "group" of Keynote slides, where each group ends at a pause point, and then it should be pretty easy to interpret gestures to either advance to the next movie (or load it automatically when you reach the end of the last one), or return to the start of the currently playing movie.