Is there a notification that I can listen to that will tell me when an iPhone's volume is turned up?
I know about the AVSystemController_SystemVolumeDidChangeNotification
, but it is essential that the notification only be triggered when the volume has been turned up, not up or down.
Secondly, how can I hide the translucent view that appears when the volume up button is pressed, showing the system's volume? Camera+ has implemented this.
To restart your iPhone, press and hold down the Power and Volume buttons until a slider appears on-screen. If restarting doesn't work, you can trigger a "force restart" by pressing Volume Up, Volume Down, and then Power.
But for a workaround, we do have volume_watcher: ^2.0. 1, which gives a callback when the volume is changed. Note: Volume carries from 0 to 1, where 0 means no volume and 1 means max volume. Show activity on this post.
When you're on the phone or listening to songs, movies, or other media on iPhone, you can use the buttons on the side of your device to adjust the audio volume. Otherwise, the buttons control the volume for the ringer, alerts, and other sound effects. You can also use Siri to turn the volume up or down.
Make Sure Your iPhone's Volume Buttons Are Enabled To check this, head to Settings > Sounds & Haptics and enable Change with Buttons. If this isn't enabled, this is why your volume buttons aren't working. If it's already enabled, proceed to the next fix.
If you want an event you can register a listener on the "outputVolume" property:
- (void)viewWillAppear:(BOOL)animated {
AVAudioSession* audioSession = [AVAudioSession sharedInstance];
[audioSession setActive:YES error:nil];
[audioSession addObserver:self
forKeyPath:@"outputVolume"
options:0
context:nil];
}
-(void) observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context {
if ([keyPath isEqual:@"outputVolume"]) {
NSLog(@"volume changed!");
}
}
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