Mirwais Maarij
Mirwais Maarij

Reputation: 205

How do I play mms:// link in android media player

I want to play this radio in my android app: http://www.voadeewaradio.com/ where it says "LIVE AUDIO"

I went in the source code for that page, I found the link that plays the radio, its .asx format:

  <a href="http://www.voanews.com/wm/live/radiodeewa.asx">Live Audio</a>

I used Cocsoft StreamDown to chagne the .asx format to a normal url:port which will then be read by

player.setDataSource("mms://a1314.l211036239.c2110.g.lm.akamaistream.net/D/1314/2110/v0001/reflector:36239");

And as you can see Cocsoft StreamDown gave me the link above, which when I paste in a browser, it opens the radio in mediaplayer. Though however in android this link doesnt work.

Upvotes: 4

Views: 9749

Answers (2)

Dan Brough
Dan Brough

Reputation: 3025

I had luck with the http://vitamio.org software.

I downloaded vitamio-Android-3.0.7z from their website and created a test project containing:

import io.vov.vitamio.MediaPlayer;

...
public class MainActivity extends Activity {

  private static final String TAG = "MainActivity";

  String mms_url = "mms://streaming.radionz.co.nz/national-mbr";

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (!io.vov.vitamio.LibsChecker.checkVitamioLibs(this))
      return;

    Button button = new Button(this);
    button.setText("Hit me");
    setContentView(button);

    final MediaPlayer player = new MediaPlayer(MainActivity.this);

    button.setOnClickListener(new View.OnClickListener() {

      @Override
      public void onClick(View v) {
        Log.i(TAG, "playing a mms stream ...");
        try {
          player.setDataSource(mms_url);
          player.prepare();
          player.start();
        } catch (Exception e) {
          Log.e(TAG, e.getMessage(), e);
        }
      }
    });
  }
}

I tested this on a Android4.2 armeabi-v7a based emulator.

The demo application they had didn't compile and it was for playing video.

Here is the demo application I created: https://www.dropbox.com/s/u2ub1jwne3qjuxd/vitamio_mms_test.tar.bz2?n=127293939

Upvotes: 1

Lukas Knuth
Lukas Knuth

Reputation: 25755

First, instead of hard-coding the URL into your application, simply read the .asx-file and parse the URL from it, it's a simple XML format.

This way, you won't need to update your application if the stream-URL changes.


For the playback of MMS streams, this is not supported by Android's MediaPlayer. You'll need a third-party library to do that: Java library to read a Microsoft Media Server (MMS) stream

Upvotes: 1

Related Questions