O'Reilly logo

Mastering Android Game Development by Raul Portales

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Playing music

The other type of sound that a game contains is background music. These tracks are usually longer than the sound effects and are played in a loop. In some cases there may be more than one track, for example, if we want a music for the menu and another one for the level, or if we want several levels with different background music tracks. We will work with a single one, but it is very easy to extend it to multiple tracks.

We are going to use MediaPlayer to play the background music in our game and we are going to abstract it via SoundManager as well, providing methods to pause and resume the music when the activity is paused and resumed.

Obtaining music

As with sound effects, we need some tracks to work with. When it comes to making ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required