Question

I´m a bit confused about this. Searched and found topics related how to stream audio and video using MMS protocol, but what I want is to listen from it, in ANDROID (Like a radio client, only audio is needed, in this case).

My target url is this: mms://stream.radio.com.pt/ROLI-ENC-452
(The above URL works. But just to be sure, I´ve copy/pasted it to my Firefox Browser, then it asks for a player, "Widows Media Player" or "VLC", and plays like a charm in both. You can try it too.)

1) I´ve tried this code: (Using MediaPlayer - The result is: Silent, nothing happens)

String target = "mms://stream.radio.com.pt/ROLI-ENC-452";
MediaPlayer mp = new MediaPlayer();
mp.setDataSource(target);
mp.prepare();
mp.start();

2) And this code: (Using MediaPlayer - The result is: Crash - Null Pointer Exception)

Uri target = Uri.parse("mms://stream.radio.com.pt/ROLI-ENC-452");
MediaPlayer.create(context, target).start();

Note: All activities and internet permissions are registered in "AndroidManifest.xml".

QUESTION: am I in the right path, using MediaPlayer for MMS protocols?... If so, what am I doing wrong? (I know that MediaPlayer handles HTTP and RTSP protocols, not sure about MMS)

Was it helpful?

Solution

SOLUTION: (Sort of) OK, after tried lots and lots of code and after try a bunch of stuff around there, posted in many forums out there, my resume is:

Fact: MediaPlayer just can´t handle the mms protocol natively.
a) Supported formats: http://developer.android.com/guide/appendix/media-formats.html
b) MMS is deprecated: http://en.wikipedia.org/wiki/Microsoft_Media_Server

An option: I could go for the "Vitamio" library. (Many people goes for this solution, as I could see)

My decision: I was go for the ".pls" and ".acc" files, since they are MediaPlayer compatible. Modern audio compression and encoding scheme, with better audio quality. And (the most important, for me) the code ended to be as simple as the one in the following example:

// Both urls for audio stream (radio):
// Try this as an "PLS" example: http://tsf.pt/emdirecto.pls
// Try this as an "AAC" example: http://euronews-02.ice.infomaniak.ch/euronews-02.aac   

VideoView vv = (VideoView) findViewById(R.id.myVideoView); // In a layout xml file
MediaController mc = new MediaController(context){};

Uri path = Uri.parse("http://euronews-02.ice.infomaniak.ch/euronews-02.aac");
vv.setMediaController(mc);
vv.setVideoURI(path);
vv.requestFocus();
vv.start();

Hopefully this could give a "beep" for someone lost in this "silent", too... ;)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top