A game feels incomplete without sound. In this chapter we will explore the different options for playing sound effects and music in Android, we will build a
SoundManager class to handle them, and we will see how it interacts with the
For sound effects we will use
SoundPool, which has been specifically designed for playing small sounds by preloading them in memory. To trigger the sound effects, we will introduce the concept of
GameEvent and learn how they are propagated through the
In the case of background music, we will use
MediaPlayer directly since long tracks do not work well with
MediaPlayer is the generic solution for playing all types of media files.
Finally, we will add ...