iOS use the volume buttons as input - iphone

I've recently downloaded an app that uses the 'Volume -' button to toggle a value, and it uses the 'Volume +' button to start/stop recording of video. The app is called SloPro, and can be found in the app store. I thought it wasn't allowed to modify the behaviour of the iPhone's hardware. Any ideas on how this is done?

See the Audio Session Services References for more details, but basically you start an audio session with AudioSessionInitialize. Then you make it active with AudioSessionSetActive. Then listen for changes in the volume with AudioSessionAddPropertyListener where you can pass a callback that has type AudioSessionPropertyListener.
Check the following website out for an example:
http://fredandrandall.com/blog/2011/11/18/taking-control-of-the-volume-buttons-on-ios-like-camera/

Related

iPhone:don't want to exit game while ring/silent switch turns on from turns off mode

I am working on app in which audio file playing very vital role.
for playing audio file I am using AVaudioPlayer in my app.
but one problem is suppose device is in silent mode and user starts running the app
and suppose he/she turns on silent/ring switch in the middle of the app.
right now he/she must exit the game but I want such kind of functionality in
which He/she should not exit the app and in the middle of the app user should be
able to hear the sound when he turns on the ring/silent switch from the device.
iOS apps have the ability to play music in the background whether they be games or not, since multitasking was introduced in iOS.
See the following tutorial.
http://mobile.tutsplus.com/tutorials/iphone/ios-sdk_background-audio/
Whether its legit for a game to do this I seriously question. But thats your call.

How to add some more custom controls in iPod background?

when we press on the Home button two times then we see the all the apps running in the background.if no apps is running in the background then there are only two controls by default.So my question is can we add same functionality in our app? means i want to add some more controls on the background. if yes then how?
You cannot add background functionality to your app.
The only ways an application can be controlled in the background are via:
Audio events. Your app registers and audio session and the user can press play/pause, next, and previous on the lock screen, task bar, or remote headphones. Unless you're doing audio-specific programming, however, you shouldn't use this.
Push notifications. Your app receives messages from a remote server via Apple's APN, triggered by one of your servers - maybe by a website application.
Sensor listening. It's possible to have your application process in the background inputs from hardware sensors, such as the accelerometer, compass, or GPS. However, this kills battery life and is discouraged unless it is absolutely necessary.
So to answer your question, no.

No delegates were triggered if app is in backgroundmode

I am at the beginning with RestKit-development. I develop an app that
get data from a Server and map these in objects. With a trick of
silence music, is it possible to send request to the backend, if the
app is in background mode . If I
leave the app the request will send, but the delegate of "finish with
objectmapping" will not throw, but if I start (activate the app) the
app, the delegates
will fire. Is there are a way, to map the json if the app is in
background mode?
I've provided an answer to your other post which I think will help you here. See link:
Your other post
Yes, if you configure your application to have a background mode that plays music and play audio while you want your application to continue to run. You can use a silent audio file if you don't actually want to play music so long as you don't want to distribute it through the App Store, but Apple will not approve it for the App Store unless there is actual music as an actual feature in your application.

How to create a "return to app" status bar when app goes to the background?

When my app moves to the background while either playing audio or recording audio, I would like to provide something like the the green "In Call" status bar that appears when you are in a call and swap out to another app, giving you a quick "return to app" capability.
I thought this might be a private API, but I noticed the Griffin iTalk app does this when it is recording audio (see picture) - so I know it can be done, but I have not been able to figure out what the API is (the Info.plist setting, the AVAudioSession, the UIApplication/Delegate or the whatever) to make this magic happen. My app is currently working and recording audio in the background and works just fine, I assume there is some bit somewhere I'm not setting to get this behavior.
Can someone either point me to the right docs or sample code that exhibits this behavior? (I've scoured the Audio docs and haven't been able to find it).
Thanks!
There may be a private API to do this, but if you want to get into the App Store, the thing to do is to register as a VOIP app, which gets you the in-call status bar, like Skype or (I imagine) iTalk.
Actually the red-bar actually only appears when the application is recording audio in the background. I've only ever done this when marking the application VOIP and Audio.
You may be able to do this by only marking is as background Audio application only, but I haven't tried this.

iPhone headphone click detection

I've tried looking through the documentation, but I can't seem to find (or recognize) what I'm looking for.
The iPhone and iPod Touch have a momentary switch on the headphones, which I believe is called the "remote" (please correct me if I'm wrong). It is used to start/stop/forward/back for music or to pickup/end a phone call. I'd like to know when this switch is clicked in my native application.
In which framework and classes would I find this?
I don't believe this functionality is supported by any current framework.
If your application has iPod playback during execution you could register for MPMusicPlayerController notifications - Music Player Notifications
This will notify you of the playback state changes you mention above. However, it will not tell you whether the state was changed via the remote or the UI. But it's the only way that I know of to 'guess' if the remote button was clicked - I use this method in one of my own apps.