Hi Jonathan -
The simples option for media playback in the Android framework is MediaPlayer
, which can take either a local media file or a URL to a remote media source and play it back on the device. This is the easiest solution because it allows you to pass any encoded media that Android supports and it will do the rest. If you are able to decode the audio data yourself ahead of time, you could also look at AudioTrack
as another way of streaming the audio content, but you will need to do more of the back-end decoding work yourself.
From an architecture perspective, you are going to want to put the MediaPlayer
inside of a Service
component inside of your application, which will allow the playback to continue uninterrupted even if the user leaves the application to go do something else. Your user interface inside of an Activity
can communicate with this Service
to start/stop playback and change the audio data source, but you shouldn't house any of the playback code there. Activity
elements are meant only to interact with the user and not handle any long-running operations beyond when the user interaction ends.
Some documentation links: