This code will tell you if Music is playing, although you won't be able to do anything about music playing from other apps as you won't have access to the player instance to turn it off. The best you could do is to turn the volume down.
If you just want to check before playing your own sounds, then this should work fine.
It uses the AudioManager API, and requires the Reflection library.
B4X:
Dim R As Reflector
R.Target=R.GetContext
R.Target=R.RunMethod2("getSystemService","audio","java.lang.String")
Label1.Text=R.RunMethod("isMusicActive")
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.