The Sound of Music

It was a dark and stormy night…. There goes the starting shot, and they’re off…. The crowd goes wild as State sinks a three-pointer with one second remaining….

Audio cues permeate the environment and set the tempo for our emotions. Think of sound as another way to get into your user’s head. Just like you use graphics on the display to convey some information to the user, you can use audio to back that up and reinforce it.

Android supports music output through the MediaPlayer class in the android.media package.[47] Let’s try it by adding some background music to the opening scene in the Tic-Tac-Toe game.

First we need some music. You can use whatever you like, but a great place to find audio is a site called freesound.org. ...

Get Hello, Android, 4th Edition 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.