2011-12-15 15:40:25 -08:00
|
|
|
|
page.title=Managing Audio Playback
|
2013-11-14 11:41:19 -08:00
|
|
|
|
page.tags=audio,media
|
2011-12-13 18:24:34 -08:00
|
|
|
|
|
|
|
|
|
trainingnavtop=true
|
|
|
|
|
startpage=true
|
|
|
|
|
|
|
|
|
|
@jd:body
|
|
|
|
|
|
|
|
|
|
<div id="tb-wrapper">
|
|
|
|
|
<div id="tb">
|
|
|
|
|
|
|
|
|
|
<h2>Dependencies and prerequisites</h2>
|
|
|
|
|
<ul>
|
|
|
|
|
<li>Android 2.0 (API level 5) or higher</li>
|
|
|
|
|
<li>Experience with <a href="{@docRoot}guide/topics/media/mediaplayer.html">Media
|
|
|
|
|
Playback</a></li>
|
|
|
|
|
</ul>
|
|
|
|
|
|
|
|
|
|
<h2>You should also read</h2>
|
|
|
|
|
<ul>
|
2012-06-21 17:14:39 -07:00
|
|
|
|
<li><a href="{@docRoot}guide/components/services.html">Services</a></li>
|
2011-12-13 18:24:34 -08:00
|
|
|
|
</ul>
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<p>If your app plays audio, it’s important that your users can control the audio in a predictable
|
|
|
|
|
manner. To ensure a great user experience, it’s also important that your app manages the audio focus
|
|
|
|
|
to ensure multiple apps aren’t playing audio at the same time.</p>
|
|
|
|
|
|
|
|
|
|
<p>After this class, you will be able to build apps that respond to hardware audio key presses,
|
|
|
|
|
which request audio focus when playing audio, and which respond appropriately to changes in audio
|
|
|
|
|
focus caused by the system or other applications.</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<h2>Lessons</h2>
|
|
|
|
|
|
|
|
|
|
<!-- Create a list of the lessons in this class along with a short description of each lesson.
|
|
|
|
|
These should be short and to the point. It should be clear from reading the summary whether someone
|
|
|
|
|
will want to jump to a lesson or not.-->
|
|
|
|
|
|
|
|
|
|
<dl>
|
|
|
|
|
<dt><b><a href="volume-playback.html">Controlling Your App’s Volume and
|
|
|
|
|
Playback</a></b></dt>
|
|
|
|
|
<dd>Learn how to ensure your users can control the volume of your app using the hardware or
|
|
|
|
|
software volume controls and where available the play, stop, pause, skip, and previous media
|
|
|
|
|
playback keys.</dd>
|
|
|
|
|
|
|
|
|
|
<dt><b><a href="audio-focus.html">Managing Audio Focus</a></b></dt>
|
|
|
|
|
<dd>With multiple apps potentially playing audio it's important to think about how they should
|
|
|
|
|
interact. To avoid every music app playing at the same time, Android uses audio focus to moderate
|
|
|
|
|
audio playback. Learn how to request the audio focus, listen for a loss of audio focus, and how to
|
|
|
|
|
respond when that happens.</dd>
|
|
|
|
|
|
|
|
|
|
<dt><b><a href="audio-output.html">Dealing with Audio Output Hardware</a></b></dt>
|
|
|
|
|
<dd>Audio can be played from a number of sources. Learn how to find out where the audio is being
|
|
|
|
|
played and how to handle a headset being disconnected during playback.</dd>
|
2013-11-14 11:41:19 -08:00
|
|
|
|
</dl>
|