Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iPhone - Capture device button push

I know you cannot control device volume from within your application, but I would like the device volume to be able to affect the UIScrollBar I have in my application to control volume.

I know this is possible because the Last.fm application does it, I would like to implement this behaviour.

I can find very little information on the interwebs. Anyone here can help me maybe? :)

like image 825
adam Avatar asked Mar 12 '09 17:03

adam


People also ask

What is the capture button on iPhone?

On an iPhone with Face ID: Simultaneously press and then release the side button and volume up button. On an iPhone with a Home button: Simultaneously press and then release the Home button and side button.

How do you capture on an iPhone?

Press the Side button and the Home button at the same time. Quickly release both buttons. After you take a screenshot, a thumbnail appears temporarily in the bottom left-hand corner of your screen. Tap the thumbnail to open it or swipe left to dismiss it.

How do I make my iPhone button click?

1) Go to Settings → General → Home Button on your iPhone. 2) You'll see the same “Choose Your Click” assistant like in the iOS setup assistant. Again, you get to choose between three degrees of “clickeness” for the Home button— Light (1), Medium (2) and Heavy (3).


1 Answers

It's easy with a listener callback

void audioVolumeChangeListenerCallback (void *inUserData, AudioSessionPropertyID inID, UInt32 inDataSize, const void *inData)
{
    RootViewController *controller = (RootViewController *) inUserData;
    Float32 newGain = *(Float32 *)inData;
    [controller setGainManual:newGain]; 
}

which gets initialized in my view controller's viewDidLoad like this

AudioSessionAddPropertyListener (kAudioSessionProperty_CurrentHardwareOutputVolume ,audioVolumeChangeListenerCallback, self );

This is all SDK/App Store friendly too.

like image 200
John Fricker Avatar answered Oct 16 '22 04:10

John Fricker