There are some posts/examples online on how to detect the current volume of the mater bus. This code (below), for example, returns 0 when nothing is playing in side an application or greater than zero if something is playing inside the application.
But this code only reports what your application is sending to the operating system. It does not report if the user is able to hear anything that you are playing. So if the phone's volume button is set to 0, or the phones mute button is muted, this code will not help.
Sometimes users complain sound is not working because they forget their phone is muted. I have seen a few apps detect if the phone is muted and warn the users. Is there a way to detect if a phone is muted?
func check_volume():
if spectrum == null:
spectrum = AudioServer.get_bus_effect_instance(0, 0)
if spectrum == null:
print("cant get volume")
return -999
var volume = spectrum.get_magnitude_for_frequency_range(0, 10000).length()
return volume