Chapter 7. Playing Sound with OpenSL ES
Multimedia is not only about graphics, it is also about sound and music. Applications in this domain are among the most popular in the Android market. Indeed, music has always been a strong engine for mobile device sales and music lovers are a target of choice. This is why an OS like Android could probably not go far without some musical talent! Open Sound Library for Embedded Systems, more frequently called OpenSL ES, is the pendant of OpenGL for sound. Although rather low-levewl, it is a first-class API for all sound-related tasks, either input or output.
When talking about sound on Android, we should distinguish Java from the native world. Indeed, both sides feature completely different APIs: MediaPlayer, SoundPool, AudioTrack, and JetPlayer on one hand, and OpenSL ES on the other hand:
- MediaPlayer is more high level and easy to use. It handles not only music but also video. It is the way to go when a simple file playback is sufficient...