I'm using AudioSessionSetActive
(true) and AudioSessionSetActive
(false) for setting the AudioSession
to true or false in my iOS app.
At any point, I want to find out whether the session is active or not. Is there a way to do that?
Just ran into the same thing! There is no AudioSessionProperty key for querying whether or not the session is active. I believe this is another one of those set it and forget it deals where Apple believes apps should behave a certain way. Eg. most apps shouldn't need to know the state they should just set it as they need audio and kill it unconditionally as they are done playing audio. Of course this only works for the 90%. Apologies as this is not the best answer, I'm only reporting my suspicions. Maybe others have a better idea?
You can check if any audio is playing as it was launched by another app by inspecting the otherAudioPlaying
property when you launch the app.
For internal tracking perhaps you could use a boolean when you do the AudioSessionSetActive(BOOL setActive)
call. Though use of BOOL does not sound as a wonderful approach. Given my current knowledge I couldnt find any other way of determining if the AudioSession is active or not.
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