Sound is a great way to grab user attention, give interface feedback or immerse a player in a game. Imagine if multiple apps all tried to play sounds at the same time. This would result in an unintelligible cacophony and make users reach for the mute button. Android provides a simple API to play music and audio effects and manage different sources. The Android audio focus API lets an app request ‘audio focus’ and lets the app know if it has lost focus so it can react. In this tutorial I will show how to use these APIs in your own apps.
You can find the final code for this tutorial on GitHub.
Source: https://www.sitepoint.com/managing-multiple-sound-sources-in-android-with-audio-focus/
Submitted by: Arnfried Walbrecht
Comments are closed.