Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to make audio streaming in android app?

 
Jonathan Herrera
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi to everyone, I need some documentation or API to audio streaming, I want to develop an android app that stream MP3, AAC+ and can be possible have ore of radio stations in the same app.

thanks for your help

ciao
 
D. Smith
Author
Greenhorn
Posts: 25
5
Android IntelliJ IDE Objective C
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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:
https://developer.android.com/reference/android/media/MediaPlayer.html
https://developer.android.com/guide/components/services.html
 
Jonathan Herrera
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks D. Smith your post was very helpful, from tomorrow I start to read the documentation

Thanks for your help
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic