Adding Music

Music for Android is exciting. Some interesting technology provides amazing functionality. Before you look into these options, let’s play a MIDI song file during game play. Your old friend the MediaPlayer class performs this perfectly because it’s designed to play all the media files in Android.

Although music is generally longer than a sound effect, and you use a different file format, it’s handled nearly identically to the sound effects in the previous sections.

To get free sound effects, you went to www.freesounds.org. For MIDI audios, I use www.midiworld.com. The site provides a large library of .midi files that you can use in your own creations. Under the Pop category, I found “Take a Chance on Me” by ABBA. Let’s add it to your ...

Get Beginning Android Tablet Games Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.