O'Reilly logo

Pro Android 4 by Satya Komatineni, Dave MacLean

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 Media

To get started, we'll show you how to build a simple application that plays an MP3 file located on the Web (see Figure 24–3). After that, we will talk about using the setDataSource() method of the MediaPlayer class to play content from the .apk file or the SD card. MediaPlayer isn't the only way to play audio, though, so we'll also cover the SoundPool class, as well as JetPlayer, AsyncPlayer, and, for the lowest level of working with audio, the AudioTrack class. After that, we will discuss some of the shortfalls of the MediaPlayer class. Finally, we'll see how to play video content.

Playing Audio Content

Figure 24–3 shows the user interface for our first example. This application will demonstrate some of the fundamental uses of ...

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