OK, just like this for a stream using HTTP.
I created a virtual folder called "Music" from IIS to WinXP and pointed it to a folder containing mp3 files. This is the complete action required to stream a file (the name is hard-coded).
BTW, it's called SimpleNetRadio since I initially started playing with Shoutcast streams.
package com.mycompany.SimpleNetRadio; import android.app.Activity; import android.media.AsyncPlayer; import android.media.AudioManager; import android.net.Uri; import android.os.Bundle; public class SimpleNetRadio extends Activity { private AsyncPlayer ap = null; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); } @Override protected void onStart() { super.onStart(); ap = (AsyncPlayer) getLastNonConfigurationInstance(); } @Override protected void onStop() { super.onStop(); if (ap != null) ap.stop(); } @Override protected void onResume() { super.onResume(); if (ap == null) { ap = new AsyncPlayer("Simple Player"); ap.play(this, Uri.parse("http://192.168.1.1/Music/02%20-%20Don't%20Stop%20Believin'.mp3"), true, AudioManager.STREAM_MUSIC); } } @Override public Object onRetainNonConfigurationInstance() { return ap; } }
You should also do this using MediaPlayer with even more code - it will better handle error conditions and will not require much more work.
source share