AnsweredAssumed Answered

Android audio stream does not work

Question asked by Gregory Kim on Nov 13, 2013
Latest reply on Jan 26, 2014 by Gregory Kim

Hi, I want to audio stream in iMX6 board using Android(JB) MediaPlayer (Example :http://80.237.156.44/iloveradio1.mp3).
But it does not work.
Could you help me with this?


[Tested version]

IMX6_R13.41_ANDROID_DEMO_IMAGE

 

[Error Description]

Android MediaPlayer can not play network audio stream. Other Android devices work well.

I tested using simple application.

===============================================================

 

 

public class MainActivity extends Activity {
    MediaPlayer mp;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        if (mp == null)
            mp = new MediaPlayer();
      try {
          mp.setDataSource("http://80.237.156.44/iloveradio1.mp3");
      } catch (IllegalArgumentException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
      } catch (SecurityException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
      } catch (IllegalStateException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
      } catch (IOException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
      }
      try {
          mp.prepareAsync();
      } catch (IllegalStateException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
      }
      OnPreparedListener listener = new OnPreparedListener(){
          @Override
          public void onPrepared(MediaPlayer arg0) {
              Toast.makeText(getBaseContext(), "start", Toast.LENGTH_SHORT).show();
              arg0.start();
          }

      };
      mp.setOnPreparedListener(listener);
    }
}

 

[Reproducing Steps]

  1. Turn on device.
  2. Connect to network.
  3. Execute sample application.

Outcomes