MPVolume on ipodtouch/iphone - 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.

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];

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

How do i set the iPod volume without affecting other sound levels?

I tried setting the iPod volume level before, but it affected the volume of my app, which uses MPMusicPlayer. Any solution to this?
If your app is playing music locally (not affecting the iPod app) you can use MPMusicPlayerController to create an application music player and then set the volume property to whatever you want.
MPMusicPlayerController Class Reference

want to build an alarm app in iphone

I want to build an alarm application for iphone. I want to ignore iphone device state and volume buttons state. I want to play sound anyhow in full volume and also want that user cant modify volume using iphone hardware buttons while sound is played. Does anybody know how to implement it? Please post the code here.......
Thankx in Advance.......
This is not possible (without jailbreaking).
You cannot force the iPhone to change its volume or intercept the hardware buttons. Also you cannot "ignore device state", as you cannot run background apps. So if your app is not running you can't execute any code

iPod app stops responding after iPod returns from standby mode

The GUI of my application stops responding after the iPod has been in standby mode. The application I have made is based on the "Utility application" template from the wizard in xcode - but the original application still works after the iPod returns from standby.
My application plays music (AudioUnit) and when the iPod enters standby the music stops but when the iPod leaves standby mode the music starts playing again but as mentioned the GUI does not respond to touches anymore. All I can do is to shut it down.
I have read about this problem here:
What happens to an iPhone app when iPhone goes into stand-by mode?
but that did not help me enough to solve the problem.
Sounds like your Audio Unit has been stopped.
If your GUI relies on the AU's progress then that would explain the problem.
Check your AU's state in applicationDidBecomeActive.
I didn't think standby mode stopped AUs, I thought only audio interruptions
did that. Anyway, you should probably look at AudioSessions as well, as you'll
find that phone calls, alarms, SMSs and ipod music will also stop your Audio Unit.
Good luck.
Actually, I've been running into this problem on the iPod application itself, in just general daily use. That is, if you are using the 3.0 firmware OS, then this is most likely a bug in the iPhone. I guess you can relax, and know that it's probably not your own code that is causing the problem. I'd file a radar ticket with Apple if you haven't already so that they can address it in the next bug fix release.
It all happens just because I have an UISlider in an UIToolbar. If I remove the UISlider from my GUI it still responds after waking up from standby/sleep mode.
Can someone explain me why that causes this problem (is it a bug in Apple's code)?
The solution is here:
http://www.iphonedevsdk.com/forum/iphone-sdk-development/4558-app-crashing-upon-quit.html
Simply don't put a slider in a toolbar. Make a work around so it looks like the slider is in the toolbar instead. It is a bug in Apple's code.