AudioServicesPlaySystemSound volume control - iphone

I wanted to ask if there is any way to control the volume of the system sound effect. When I press the volume control toggle (up and down) in the game, the system sound effects does not get affected. I also read that this should be affected by the ringer volume. But the weird thing is that when I press the volume up and down, I do not see the little ringer text on top of the speaker icon. I only see the speaker icon without ringer on top when I press the volume control. Does anyone know why?
Thanks.

If audio is playing on your device using audioQueue, iPod or some other form other than system sounds, the volume adjusted by the side buttons will be the device volume. If the device is otherwise silent, adjusting the side buttons will adjust the ringer volume.

if you want to affected,you can use this
[[AVAudioSession sharedInstance]
setCategory:AVAudioSessionCategoryPlayAndRecord
withOptions:AVAudioSessionCategoryOptionDefaultToSpeaker
error:nil];

Related

How to increase iPhone volume programmatically

In my app I have to play the siren sound on tapping the button, I can able to play it when ringer volume is set to some value, but my problem is when user kept their ringer volume to zero, how can I play it with maximum sound?
Officially you can't do this. As a smartphones user, I wouldn't appreciate to set my volume at 10% and have an app that rings at max volume.
You can however try to use Celestial.framework, but your application will be rejected from the App Store.
try this code ,it only work in device
[[MPMusicPlayerController applicationMusicPlayer] setVolume:setvalue];

How can I hide the Iphone volume box while changing the volume with a UISlider?

I'm trying to change the volume in my app with a UISlider. The code I'm using for this is:
[[MPMusicPlayerController applicationMusicPlayer] setVolume:_volumeSlider.value];
The problem with this code is that it shows the volume box from the iPhone the same one that appears when you press the volume up or volume down buttons in the left part of the iPhone. For my app I need to hide this box, because the only thing I care is changing the volume.
Use an MPVolumeView. It stays in sync with the system volume (adjusting itself when the user, e.g., hits one of the hardware volume buttons), and, more relevantly, suppresses the volume bezel when adjusted.

LocalPushNotification sound and iPhone's volume buttons

I implement UILocalNotification in my app which will play 16-seconds-length sound.
I notice that while the sound is being played,
if I press the side Volume buttons (on iPhone/ iPod) to increase or decrease the volume,
the sound is stopped immediately.
Do you know how to not stopped the Local Notification sound when user presses the side Volume buttons on iPhone/ iPod?
Thank you.
EDIT:
I like to do the same like this i-iQ Timer app, when UILocalNotification sound is playing, if user adjust the side volume buttons, the sound keeps playing.
No, the standard APIs give you no control over what happens when the volume buttons are pressed. The only sound-related thing about a UILocalNotification that you can control is to choose which sound plays.}

iPhone - Can't adjust sound volume with hard buttons

When my app is launched (no sound emitted, Ambiant category set for AudioSession), using the up and down volume button on the iPhone does not do anything :
- on screen, nothing is displayed (I mean, the iOS black and white "slider" overlay does not appear to show me that volume is changing).
- in app, after playing with hard buttons, no impact on the sound volume when some sound is played (I use an AVAudioPlayer)
- this is the same if I quit the app, adjust the sound volume (onscreen "slider"overlay shows up to show me that the sound level have decreased for example), kill the app and relaunch it : same sound level that before
Using those hard buttons work though on the springboard and into other apps ("slider" overlay is displayed and volume is changing).
What is the problem with my app ?
As far as I've seen, many app, and angry birds for an example, make sounds, does not have a hard slider to change it's volume when playing game, and sound can be adjusted just playing with hard buttons.
I got some users of my app with the same problem, it was not my code but their iPhone settings:
Go to Settings->Sound->Change with Buttons and set it to Off
How your app behaves with that stuff depends on how you have set up your audio session. There are as I recall five different categories to choose from. Which category you choose affects how your app behaves with respect to hardware buttons, volume, backgrounding, and so on.
Best bet is to have a look at the Apple docs here:
http://developer.apple.com/library/ios/#DOCUMENTATION/Audio/Conceptual/AudioSessionProgrammingGuide/Configuration/Configuration.html#//apple_ref/doc/uid/TP40007875-CH3-SW1
Also, there is a really great tutorial video by Apple that covers this stuff really well. Here's the link:
https://developer.apple.com/videos/iphone/#video-advanced-audiodev

MPVolume on ipodtouch/iphone

i'm using the code of this link: http://blog.stormyprods.com/2008/09/proper-usage-of-mpvolumeview-class.html
it is working on an ipod touch, but NOT on iphones.
what can be the reason for that?
Two things:
I think iPhone OS 3.0 does a better job of syncing the MPVolumeView slider with changes to the system volume received from the buttons on side. So the workaround on that blog (listening for NSNotifications) may no longer be necessary.
On the iPhone, volume changes are contextual. If your app is currently playing sound, then hitting the volume buttons (or, presumably, MPVolumeView) affects the volume level of your app's audio. But if your app isn't producing sound, then you are just changing the ringer volume. This might explain why your current code works on touches, which don't have ringers.