i want in my app to increase and decrease the app volume programmatically from the code and not to use MPVolumeView.
You cannot change the volume programmatically, and that's a deliberate design choice. Imagine an app that constantly sets the volume to the highest level, that would not only be annoying but could even damage your ears if you're wearing in-ear headphones.
You should show an MPVolumeView to the user so he can change the volume himself. You can walk its subview hierarchy and search for the UISlider and adjust its appearance like with any normal UISlider. This way you can adapt the MPVolumeView to your app design.
Officially: You can't.
If you really want to do so, link against Celestial.framework and use its controllers to change the volume - that is how SpringBoard and friends do it. I don't remember how to do it, but with a bit of research you should be able to find the answer. This will get your app rejected. If you're developing for a jailbroken device, this is the way to go.
If you want to go deeper you can do it via the vTable of the appropriate CoreAudio service. You also need Celestial.framework for that. And if you want to go even deeper, kill mediaserver and make your own implementation which should occupy your for the next few months.
Related
I am adding camera using {[UIImagePickerController availableMediaTypesForSourceType:UIImagePickerControllerSourceTypeCamera]} as a subview to a UIView with fixed boundaries in my app.
Everything is working fine. But all the examples i see shows displaying camera as a modalcontroller as single screen. My doubt is, are there any cases that APPLE will reject if the camera is added as an subview to a view?. Should it be only shown as a full screen modal controller?
There is no rule that says you may not use camera view as a subview. It's all down to the specifics of your requirements and your app. Apple probably won't reject your app just because of such use of the camera view.
For example, Layar app is using camera view as a background for their overlays - clearly not a modal controller.
At the same time, consider the user's experience. If you are providing your user with the ability to take a picture with the camera and then use this picture in further application logic, then using it as a modal controller may be a better approach, as it provides the user with a consistent experience across multiple apps: users do get used to certain experiences and you need to have a valid reason to go against those consistent experiences.
At the same time, if you do have a valid reason why you want to have camera view as a subview (for example, display an overlay layer over it or apply a filter to the preview, or whatever else), then this is a perfectly valid reason for your UI design decision.
So, to summarize, there's no rule against it, but keep the user's experience in mind. Also remember that Apple may choose to reject your app for any reason they choose - and they don't have to explain it to you. At least, that's what you're agreeing to when you join the developer's programme.
I have seen some apps where when you launch them for the first time after downloading (e.g. Chrome app on iPhone), it shows you a list of animated gestures on the screen, kind of giving you a tour of the app.
How do I build one something like that? And how does the app know to launch only for the first time after download and not since then? For the second question, I am guessing a "shown=TRUE" value can be saved inside a PList file and checking the value each time when the app finished launching. But I am more curious about the mechanism involved in creating a guided app tour.
You can use transparent and semi-transparent images with a UIImageView, so you can make up an image with arrows and notes and put over the whole screen. You could fade it out when the user taps.
To know if it's the first time running the app, you should use NSUserDefaults instead of a plist; it's much easier, and you should be app to find a quick tutorial on that fairly easily.
Also, you could check around on this site for controls like this one. I haven't used any of them myself, so I'm not sure how much they differ from a regular UIImageView. They look nice though.
I'm creating an app that shows a list of items one by one on the screen. Each item will have a name and phone number, and will be displayed in a view called person view. My project is similar to the iPod music player view:
However, instead of showing the album image, I want to show my person view. Could someone explain me how to achieve the navigation when the user hits |<< or >>|? Also, how can I build a similar view? Any code snippet/blueprint would be quite helpful. Thanks!
One thing to keep in mind is that Apple's app store review guidelines contain advice that apps that reproduce iPod controls may be rejected. My guess is that this is probably meant more to discourage apps from using a control like the traditional iPod jog wheel, but it's something you may want to be careful about.
I'm using
AudioSessionAddPropertyListener(kAudioSessionProperty_CurrentHardwareOutputVolume,
audioVolumeChangeListenerCallback, self);
to detect volume changes so i can take a picture with the volume rockers but if the phone is already at 100% i don't get an event. Is there a way to detect volume rocker pressed when the volume doesn't actually change?
I found a good answer with full source code here:
When the user presses the volume buttons in your app, you don’t want
the system volume to change. It would suck to have them taking
pictures and turn up their ringtone volume all the way or something.
So how do I pull that off? This is pretty hacky but it works.
Well you could set the volume lower after you've registered a volume button press to take a picture. That way the volume never reaches 100% and you can continue getting callbacks. Make sure to lower the volume by more than the volume changes in a single press of the volume button.
You will want to be careful to use some method to prevent receiving multiple notifications at once, but you are likely already doing that if you only take one photo per "button press".
I think I'm going to implement this feature (didn't think it was needed, but now I like the idea) in my app, and I'll post some code if I get it working, let me know if you get yours working as well.
I have an app with various views. The main menu does not have any sounds, but the next views play sounds using the AVAudioPlayer Class.
So when someone launches the app and is in the main menu, if he changes the volume on his device, he actually changes the "Ringer" volume. If he proceeds to the other views (where we have sound), when he changes the volume on the device he changes the volume of the game, not the ringer.
Is there a way to have them change the app volume every time, from the beginning of my app, before I create any instances of AVAudioPlayer??
(some misunderstood that. What I mean is that square that the OS overlays on the screen every time you press the volume buttons. If you are on the home screen, you change the "Ringer". When you are in a game, you change the app's volume).
PS:
I initialize the AudioSession on my main menu but that doesn't make any difference.
The only hack i have found is to actually create an instance of AVAudioPlayer on my main menu and set it to "preparedToPlay". But I would rather hear what the others are doing (a proper solution).
The volume buttons will affect the ringer volume if your application isn't currently playing audio. Some apps work around this by playing a silent audio file. Carefully consider how you do this, though - is adjusting the apps volume when it's not actually playing something actually useful?
It seems like you ought to be able to do what you want by modifying the AudioSession properties, but I haven't figured out how (if it is possible).
There is a class called MPVolumeView which is used for this purpose. Here's a good link explaining the use of MPVolumeView
Adding MPVolumeView to your view will create an iPod-like volume slider which will change when you change the volume using the rocker buttons. The value will automatically be used by the AVAudioPlayer class.
To keep track of volume without the slider
The rocker buttons by default change the app volume only when some audio is playing. There is a workaround to this problem - this SO thread discusses some workarounds.