I've read quite a few posts on the subject but the answers are not 100% clear. I'm looking for clarity here.
My app plays a short AVAudioPlayer sound periodically. The problem is, I can only set the volume after the first sound is played.
After reading stackoverflow, everyone seems to suggest that I play a dummy (silent) AVAudioPlayer sound at the start of the app to "link" the device's volume buttons to the "app volume".
Said another way, when the app starts, it's the "Ringer" volume that is controlled by default and only after the first sound is played will the device's volume buttons finally control the "app volume" (AVAudioPlayer volume) (it's the image without any label). Unfortunately by the time this happens, the user doesn't hear the first sound and now sees the app as broken.
My question is, is this the answer? Do I simply play a short dummy sound once at the start of the app to "link" the device's volume buttons to the app?
You don't have to play a dummy sound. Using the AudioToolbox framework you can set the AudioSessionActive as follows:
This will allow the volume buttons to control the app volume.
See this question: Cannot Control Volume of AVAudioPlayer via Hardware Buttons when AudioSessionActive is NO for more information on this approach.