6.3.5. Adding Sound with SoundPool and AudioManager

An app’s sound effects are managed with a SoundPool (package android.media), which can be used to load, play and unload sounds. Sounds are played using one of Android’s audio streams for alarms, music, notifications, phone rings, system sounds, phone calls and more. The Android documentation recommends that games use the music audio stream to play sounds. We use the Activity’s setVolumeControlStream method to specify that the game’s volume can be controlled with the device’s volume keys. The method receives a constant from class AudioManager (package android.media), which provides access to the device’s volume and phone ringer controls.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset