Currently, I'm setting the volume to max, and then checking if the volume is at max, or a lower value. If it's at a lower value, then the user must have a Volume Lock on their system.
This works fine, but I'm wondering if there is some method to call, or property to check which tells me this in code for free? I've been looking online as to how to do this, but I can't seem to find anything. Thanks in advance!
Edit: It turns out that my previous method of setting the max volume and then checking if it's lower to see if there is a Volume lock does not work on the device. It seems as though the volume is scaled with the Volume lock, instead of just being cut off.
Now I'm completely stuck on this. Is there even any private methods or properties that I can use in order to detect this?
I think what you are asking for is to find out if the iphone has a cap on the volume limit. I have looked for the answer but could not find one. Here is a way just to check the volume level, hope this helps.
In your XIB you can add a slider to check what the volume level is at, so basically you can tell if it is silent, and know the level of the volume. For more understanding of this class, here's the link http://blog.stormyprods.com/2008/09/proper-usage-of-mpvolumeview-class.html but try this first:
The following code will create something like a volume bar.
- (void)viewDidLoad {
// create a frame for MPVolumeView image
CGRect frame = volumeViewHolder.bounds; // CGRectMake(0, 5, 180, 0);
volumeView = [[[MPVolumeView alloc] initWithFrame:frame] autorelease];
[volumeView sizeToFit];
[volumeViewHolder addSubview:volumeView];
for (UIView *view in [volumeView subviews]){
if ([[[view class] description] isEqualToString:@"MPVolumeSlider"]) {
volumeViewSlider = view;
}
}
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(volumeChanged:)
name:@"AVSystemController_SystemVolumeDidChangeNotification"
object:nil];
}
- (void) volumeChanged:(NSNotification *)notify
{
[volumeViewSlider setValue:[[[notify userInfo] objectForKey:@"AVSystemController_AudioVolumeNotificationParameter"] floatValue]];
}
I heard that for some reason apple doesn't allow you to sell an app if you use a certain class (the one in my example) but I'm not too sure about this, I would double-check and make sure that you are 'allowed' to use it. But the code should work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With