Objective-C - Adding sound on iPhone - iphone

I'm making a sound for the iPhone and I'm interested in adding background music and background sounds.
Is CoreAudio right for the job?
And if so, how do I use it?

If you're just playing background music and doesn't need advanced controls, try AVAudioPlayer.
For sound effects, use AudioServicesPlaySystemSound.

Related

Background iPod music Volume mixed with sound effects

What would the best method be for mixing background iPod music with sound effects? The sound effects need to be adjustable and sometimes much louder than the background music. When I use MPMusicPlayerController the volume is system-wide and reduces the effects volume as well. I have been reading about AVPlayer and AVAudipPlayer but can't seem to locate a viable solution.
Any help and suggestions would be greatly appreciated.
The problem is that you cannot play much louder sound over iPod music library because as you wrote iPod music use system volume. Unless the music files in your iPod library is compressed with very low volume.
Cocos 2D framework integrates very nice way how to mix-up more sound sources, but again it uses AVAudioPlayer for background music and Open AL for other sounds.
Have you looked at AVAudioSession Categories? I think that could help you with your problem. The docs at Apple.

Play audio in background

I want my app will play music when she is in the background too,
there is any way to do it? i try to use apple documentation but it didn't work.
it is possible that because i am now using the avplayer i cant play audio in background?
i play the music with
ExtAudioFileSeek(mExtAFRef, finalFrames);
I think playing audio in background is possible only for streaming audio. For normal audio we can only play when screen is locked.
You should look at documentation of using background tasks like:
http://developer.apple.com/library/ios/#DOCUMENTATION/iPhone/Conceptual/iPhoneOSProgrammingGuide/BackgroundExecution/BackgroundExecution.html
and specially the:
http://developer.apple.com/library/ios/#DOCUMENTATION/iPhone/Conceptual/iPhoneOSProgrammingGuide/BackgroundExecution/BackgroundExecution.html#//apple_ref/doc/uid/TP40007072-CH5-SW14

UIAudioPickerController for iPhone App?

Not sure what to call this, but I'd like to offer a way for users to pick and control their music from within my app. I've seen a few apps that offer an "iPod" button that appears to bring up the iPod app. Is this a built in control like the UIImagePickerController or have they simply duplicated all the functionality?
Check out the MediaPlayer framework. In particular, you're talking about the MPMediaPickerController
What I'm doing in Couch to 5k is inserting a UIView with a toolbar, labels, and an image view. The toolbar has the standard buttons for controlling the iPod music player. Then I'm using MPMusicPlayerController to control the iPod music playback.
Here's some sample code to get the iPod music player and what's playing:
musicPlayer = [MPMusicPlayerController iPodMusicPlayer];
item = musicPlayer.nowPlayingItem;
And then I register for NSNotification using the code provided in Apple's documentation on MPMusicPlayerController.

Can videos be played without controls?

I'm planning on making a game for the iPhone and want to have the background constantly animated. I figured rather than looping a series of images, I'd play a video. Is it possible for me to play a video (with no controls popping up), and have graphics overtop of it (the actual game)? Or would I just be better off with looping images?
(I figured SO would be a better place to ask this than Game Development)
Yes, using AVFoundation, or even the MPMoviePlayerController with the controls property turned off.
You can have anything you like overlaying the video. The performance for that is much better in iOS4 than earlier OS versions.
You can use MPMoviePlayerController and set the control style to none.
MPMoviePlayerController control style and MPMoviePlayerController control style list

Overriding iPhone shutter sound through SDK

In my iPhone app, I am using the UIImagePickerController with source type UIImagePickerControllerSourceTypeCamera. When the user takes a picture, the phone plays the familiar camera shutter sound. How can I replace this with my own custom sound? I know it's possible because I've seen other apps from the App Store do it (e.g. Red Laser).
I am quite certain it's not possible. AFAIK, Red Laser doesn't actually take a "normal" picture but uses UIGetScreenImage() (undocumented but nevertheless allowed for App Store apps) to make a screenshot of the live video feed. Since the OS does not play sound on this occasion, they are free to play their own sound.
Edit for clarification: As of OS 3.1, you are free to substitute the standard camera interface with your own controls. So you could place your own shutter button on the screen and play your own sound when the user taps it, but AFAIK there is now way to get rid of the OS's standard shutter sound.
AFAIK the standard camera shutter sound cannot be changed via SDK.
This answer supports that. You can replace your own sound by switching sound files, but not in an app.
Some answers such as this one suggest using AVCapture, but this method takes video screenshots, which reduces the image quality. I
t appears that you can't change the shutter sound because you could make it a silent sound, and capturing images covertly is against the App Store policy. See this answer.
TLDR:
The only way to change the shutter sound is to use a video screen grab.