I would like to present an alert if the sound is 0.
I found this library https://github.com/moshegottlieb/SoundSwitch, but it doesn't seem to work. At least not on a simulator
I would like to present an alert if the sound is 0.
I found this library https://github.com/moshegottlieb/SoundSwitch, but it doesn't seem to work. At least not on a simulator
Have you seen this question? They give various answers:
float vol = [[AVAudioSession sharedInstance] outputVolume];
NSLog(@"output volume: %1.2f dB", 20.f*log10f(vol+FLT_MIN));
Nonetheless it doesn't seems to work using the simulator (I'm trying and it always return the same value). This lead me to think maybe it's not something we can check from the simulator. Can you try on a real device? Let me know if it works.
EDIT: Ok so reading about it it seems there's no API avaiable to check silent mode. Anyway what people have found a workaround: Playing a short audio with no volume. If the time when it finishes (minus time when it started) is lower than the actual length of the audio is on mute mode (being in the silent mode the audio will last 0 seconds).
So, here somebody posted a class that do that for you. Let me know if it works