The easiest way to play an audio RTMP stream in Android

Zakaria picture Zakaria · Jun 14, 2011 · Viewed 25.6k times · Source

I found some Android RTMP libraries (like this : http://rtmpdump.mplayerhq.hu/).

The problem is that there is no accurate documentation on how we can use it.

In my case, I have a simple RTMP live audio stream (ex: rtmp://myserver/myapp/myliveaudio).

What is the easiest way to read it in my Android app?

Please, I don't want links: I need some pieces of code or some accurate step-by-step explanation.

Thank you very much.

Answer

Femi picture Femi · Jun 14, 2011

It is unfortunately non-trivially difficult to do. Right now your best bet is to look at the code in http://code.google.com/p/android-rtmp-client/: specifically look at http://code.google.com/p/android-rtmp-client/source/browse/trunk/example/com/ryong21/example/recorder/RecorderClient.java and http://code.google.com/p/android-rtmp-client/source/browse/trunk/example/com/ryong21/example/recorder/Recorder.java. These walk through taking in a streamed MP3 file and recording its contents to an FLV file on disk.

You would need to modify the RecorderClient.java file (specifically around line 193) to play the audio data out the speakers.