Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to play streamed audio in background on Android?

I have an Android application that plays streamed audio from the Internet using the MediaPlayer class.

How do I let it continue to play the audio on the background when the user hits the home button to run other applications?

While running other apps, I'd like it to continue to play the audio.

like image 546
neowinston Avatar asked Oct 10 '12 15:10

neowinston


1 Answers

You have to use something called Android Services.

From the docs:

"A Service is an application component representing either an application's desire to perform a longer-running operation while not interacting with the user or to supply functionality for other applications to use."

Here's the excellent official guide to using services to get you started: http://developer.android.com/guide/components/services.html

Here's a good tutorial on building an audio player: http://www.androidhive.info/2012/03/android-building-audio-player-tutorial/

Here's a video tutorial for building a streaming music player: http://www.youtube.com/watch?v=LKL-efbiIAM

like image 193
Anup Cowkur Avatar answered Oct 15 '22 14:10

Anup Cowkur