Playing sound effects with SoundPool

When you need sound effects in your application, SoundPool is usually a good starting point.

SoundPool is interesting in that it allows us to create special effects with our sounds by changing the play rate and by allowing multiple sounds to play simultaneously.

Popular audio file types supported include:

  • 3GPP (.3gp)
  • 3GPP (.3gp)
  • FLAC (.flac)
  • MP3 (.mp3)
  • MIDI Type 0 and 1 (.mid, .xmf, and .mxmf)
  • Ogg (.ogg)
  • WAVE (.wav)

See the Supported Media Formats link for a complete list, including network protocols.

As is common in Android, new releases to the OS bring changes to the APIs. The SoundPool is no exception and the original SoundPool constructor was deprecated in Lollipop (API 21). Rather than setting our minimum API to ...

Get Android Application Development Cookbook - Second 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.